Save several arrays into a single file in compressed ``.npz`` format. Provide arrays as keyword arguments to store them under the corresponding name in the output file: ``savez_compressed(fn, x=x, y=y)``. If arrays are specified as positional arguments, i.e., ``savez_compresse
(file, *args, allow_pickle=True, **kwds)
| 680 | |
| 681 | @array_function_dispatch(_savez_compressed_dispatcher) |
| 682 | def savez_compressed(file, *args, allow_pickle=True, **kwds): |
| 683 | """ |
| 684 | Save several arrays into a single file in compressed ``.npz`` format. |
| 685 | |
| 686 | Provide arrays as keyword arguments to store them under the |
| 687 | corresponding name in the output file: ``savez_compressed(fn, x=x, y=y)``. |
| 688 | |
| 689 | If arrays are specified as positional arguments, i.e., |
| 690 | ``savez_compressed(fn, x, y)``, their names will be `arr_0`, `arr_1`, etc. |
| 691 | |
| 692 | Parameters |
| 693 | ---------- |
| 694 | file : file, str, or pathlib.Path |
| 695 | Either the filename (string) or an open file (file-like object) |
| 696 | where the data will be saved. If file is a string or a Path, the |
| 697 | ``.npz`` extension will be appended to the filename if it is not |
| 698 | already there. |
| 699 | args : Arguments, optional |
| 700 | Arrays to save to the file. Please use keyword arguments (see |
| 701 | `kwds` below) to assign names to arrays. Arrays specified as |
| 702 | args will be named "arr_0", "arr_1", and so on. |
| 703 | allow_pickle : bool, optional |
| 704 | Allow saving object arrays using Python pickles. Reasons for |
| 705 | disallowing pickles include security (loading pickled data can execute |
| 706 | arbitrary code) and portability (pickled objects may not be loadable |
| 707 | on different Python installations, for example if the stored objects |
| 708 | require libraries that are not available, and not all pickled data is |
| 709 | compatible between different versions of Python). |
| 710 | Default: True |
| 711 | kwds : Keyword arguments, optional |
| 712 | Arrays to save to the file. Each array will be saved to the |
| 713 | output file with its corresponding keyword name. |
| 714 | |
| 715 | Returns |
| 716 | ------- |
| 717 | None |
| 718 | |
| 719 | See Also |
| 720 | -------- |
| 721 | numpy.save : Save a single array to a binary file in NumPy format. |
| 722 | numpy.savetxt : Save an array to a file as plain text. |
| 723 | numpy.savez : Save several arrays into an uncompressed ``.npz`` file format |
| 724 | numpy.load : Load the files created by savez_compressed. |
| 725 | |
| 726 | Notes |
| 727 | ----- |
| 728 | The ``.npz`` file format is a zipped archive of files named after the |
| 729 | variables they contain. The archive is compressed with |
| 730 | ``zipfile.ZIP_DEFLATED`` and each file in the archive contains one variable |
| 731 | in ``.npy`` format. For a description of the ``.npy`` format, see |
| 732 | :py:mod:`numpy.lib.format`. |
| 733 | |
| 734 | |
| 735 | When opening the saved ``.npz`` file with `load` a `~lib.npyio.NpzFile` |
| 736 | object is returned. This is a dictionary-like object which can be queried |
| 737 | for its list of arrays (with the ``.files`` attribute), and for the arrays |
| 738 | themselves. |
| 739 |
nothing calls this directly
no test coverage detected
searching dependent graphs…