MCPcopy Index your code
hub / github.com/numpy/numpy / _savez

Function _savez

numpy/lib/_npyio_impl.py:756–790  ·  view source on GitHub ↗
(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None)

Source from the content-addressed store, hash-verified

754
755
756def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None):
757 # Import is postponed to here since zipfile depends on gzip, an optional
758 # component of the so-called standard library.
759 import zipfile
760
761 if not hasattr(file, 'write'):
762 file = os.fspath(file)
763 if not file.endswith('.npz'):
764 file = file + '.npz'
765
766 namedict = kwds
767 for i, val in enumerate(args):
768 key = f'arr_{i}'
769 if key in namedict.keys():
770 raise ValueError(
771 f"Cannot use un-named variables and keyword {key}")
772 namedict[key] = val
773
774 if compress:
775 compression = zipfile.ZIP_DEFLATED
776 else:
777 compression = zipfile.ZIP_STORED
778
779 zipf = zipfile_factory(file, mode="w", compression=compression)
780 try:
781 for key, val in namedict.items():
782 fname = key + '.npy'
783 val = np.asanyarray(val)
784 # always force zip64, gh-10776
785 with zipf.open(fname, 'w', force_zip64=True) as fid:
786 format.write_array(fid, val,
787 allow_pickle=allow_pickle,
788 pickle_kwargs=pickle_kwargs)
789 finally:
790 zipf.close()
791
792
793def _ensure_ndmin_ndarray_check_param(ndmin):

Callers 2

savezFunction · 0.85
savez_compressedFunction · 0.85

Calls 6

zipfile_factoryFunction · 0.85
endswithMethod · 0.80
itemsMethod · 0.80
keysMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…