
    
9j,                        S SK Jr  S SKrS SKrS SKr\R
                  R                  \R                  5      S:  r " S S5      r	S
S jr
SS jrS rS	 rg)    )annotationsNz1.10.0c                  2    \ rS rSrS rS rS rS rS rSr	g)	NpzFile   c                    Xl         g Nnpz_file)selfr
   s     F/home/wildlama/miniconda3/lib/python3.13/site-packages/cupy/_io/npz.py__init__NpzFile.__init__   s         c                :    U R                   R                  5         U $ r   )r
   	__enter__r   s    r   r   NpzFile.__enter__   s    !r   c                <    U R                   R                  XU5        g r   )r
   __exit__)r   typval	tracebacks       r   r   NpzFile.__exit__   s    s3r   c                L    U R                   U   n[        R                  " U5      $ r   )r
   cupyarray)r   keyarrs      r   __getitem__NpzFile.__getitem__   s    mmC zz#r   c                8    U R                   R                  5         g r   )r
   closer   s    r   r"   NpzFile.close   s    r   r	   N)
__name__
__module____qualname____firstlineno__r   r   r   r   r"   __static_attributes__ r   r   r   r      s    !4r   r   c                   [         (       a  Uc  SOUn[        R                  " XU5      nO/Ub  [        R                  " S5        [        R                  " X5      n[        U[        R                  5      (       a  [        R                  " U5      $ [        U[        R                  R                  R                  5      (       a  [        U5      $ U$ )a2  Loads arrays or pickled objects from ``.npy``, ``.npz`` or pickled file.

This function just calls ``numpy.load`` and then sends the arrays to the
current device. NPZ file is converted to NpzFile object, which defers the
transfer to the time of accessing the items.

Args:
    file (file-like object or string): The file to read.
    mmap_mode (None, 'r+', 'r', 'w+', 'c'): If not ``None``, memory-map the
        file to construct an intermediate :class:`numpy.ndarray` object and
        transfer it to the current device.
    allow_pickle (bool): Allow loading pickled object arrays stored in npy
        files. Reasons for disallowing pickles include security, as
        loading pickled data can execute arbitrary code. If pickles are
        disallowed, loading object arrays will fail.
        Please be aware that CuPy does not support arrays with dtype of
        `object`.
        The default is False.
        This option is available only for NumPy 1.10 or later.
        In NumPy 1.9, this option cannot be specified (loading pickled
        objects is always allowed).

Returns:
    CuPy array or NpzFile object depending on the type of the file. NpzFile
    object is a dictionary-like object with the context manager protocol
    (which enables us to use *with* statement on it).

.. seealso:: :func:`numpy.load`

F1allow_pickle option is not supported in NumPy 1.9)_support_allow_picklenumpyloadwarningswarn
isinstancendarrayr   r   libnpyior   )file	mmap_modeallow_pickleobjs       r   r.   r.   !   s    >  , 4u,jj,7#MMMNjj)#u}}%%zz#	C00	1	1s|
r   c                
   [         (       a4  Uc  SOUn[        R                  " U [        R                  " U5      U5        gUb  [
        R                  " S5        [        R                  " U [        R                  " U5      5        g)a  Saves an array to a binary file in ``.npy`` format.

Args:
    file (file or str): File or filename to save.
    arr (array_like): Array to save. It should be able to feed to
        :func:`cupy.asnumpy`.
    allow_pickle (bool): Allow saving object arrays using Python pickles.
        Reasons for disallowing pickles include security (loading pickled
        data can execute arbitrary code) and portability (pickled objects
        may not be loadable on different Python installations, for example
        if the stored objects require libraries that are not available,
        and not all pickled data is compatible between Python 2 and Python
        3).
        The default is True.
        This option is available only for NumPy 1.10 or later.
        In NumPy 1.9, this option cannot be specified (saving objects
        using pickles is always allowed).

.. seealso:: :func:`numpy.save`

NTr+   )r,   r-   saver   asnumpyr/   r0   )r5   r   r7   s      r   r:   r:   P   sY    , +3t

4c*L9#MMMN

4c*+r   c                    [        [        R                  U5      nU H  n[        R                  " X#   5      X#'   M     [        R                  " U /UQ70 UD6  g)a(  Saves one or more arrays into a file in uncompressed ``.npz`` format.

Arguments without keys are treated as arguments with automatic keys named
``arr_0``, ``arr_1``, etc. corresponding to the positions in the argument
list. The keys of arguments are used as keys in the ``.npz`` file, which
are used for accessing NpzFile object when the file is read by
:func:`cupy.load` function.

Args:
    file (file or str): File or filename to save.
    *args: Arrays with implicit keys.
    **kwds: Arrays with explicit keys.

.. seealso:: :func:`numpy.savez`

N)mapr   r;   r-   savezr5   argskwdsr   s       r   r>   r>   o   sF    " t||T"DLL+	 	KK$t$t$r   c                    [        [        R                  U5      nU H  n[        R                  " X#   5      X#'   M     [        R                  " U /UQ70 UD6  g)zSaves one or more arrays into a file in compressed ``.npz`` format.

It is equivalent to :func:`cupy.savez` function except the output file is
compressed.

.. seealso::
   :func:`cupy.savez` for more detail,
   :func:`numpy.savez_compressed`

N)r=   r   r;   r-   savez_compressedr?   s       r   rC   rC      sH     t||T"DLL+	 	4/$/$/r   )NNr   )
__future__r   r/   r-   r   r3   NumpyVersion__version__r,   r   r.   r:   r>   rC   r)   r   r   <module>rG      sR    "    //0A0ABhN  (,^,>%.0r   