Unverified Commit 28c19eba authored by mvdbeek's avatar mvdbeek
Browse files

Assert that at least one file in npz zipfile ends with .npy

from https://pydoc.dev/numpy/latest/numpy.lib.npyio.NpzFile.html:

> NpzFile is used to load files in the NumPy .npz data archive format. It assumes that files in the archive have a .npy extension, other files are ignored.
parent ed69e0f8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -4135,8 +4135,8 @@ class Npz(CompressedArchive):

    def sniff(self, filename: str) -> bool:
        try:
            npz = np.load(filename)
            if isinstance(npz, np.lib.npyio.NpzFile):
            with np.load(filename) as npz:
                if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist):
                    return True
        except Exception:
            return False