
    0-Phn
                     :    d Z ddlZddlmZ  G d de          ZdS )a;  Read/Write NPZ files.

Backend: `Numpy <https://numpy.org/doc/stable/reference/generated/numpy.savez.html>`_

NPZ is a file format by numpy that provides storage of array data using gzip
compression. This imageio plugin supports data of any shape, and also supports
multiple images per file. However, the npz format does not provide streaming;
all data is read/written at once. Further, there is no support for meta data.

See the BSDF format for a similar (but more fully featured) format.

Parameters
----------
None

Notes
-----
This format is not available on Pypy.

    N   )Formatc                   j    e Zd ZdZd Zd Z G d dej                  Z G d dej                  ZdS )		NpzFormatzSee :mod:`imageio.plugins.npz`c                     |j         | j        v S N	extension
extensionsselfrequests     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/imageio/plugins/npz.py	_can_readzNpzFormat._can_read!        DO33    c                     |j         | j        v S r   r	   r   s     r   
_can_writezNpzFormat._can_write%   r   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )NpzFormat.Readerc                     t          j        | j                                                  | _        t          | j        t           j        j        j                  sJ t          | j        j
        d           | _        d S )Nc                 8    |                      d          d         S )N_)split)xs    r   <lambda>z(NpzFormat.Reader._open.<locals>.<lambda>1   s    R@P r   )key)nploadr   get_file_npz
isinstancelibnpyioNpzFilesortedfiles_namesr   s    r   _openzNpzFormat.Reader._open,   s`     5 5 7 788DIdi)=>>>>> 6P6PQQQDKKKr   c                 8    | j                                          d S r   )r"   closer*   s    r   _closezNpzFormat.Reader._close3   s    IOOr   c                 *    t          | j                  S r   )lenr)   r*   s    r   _get_lengthzNpzFormat.Reader._get_length6   s    t{###r   c                     |dk     s|t          | j                  k    rt          d          | j        | j        |                  }|i fS )Nr   z)Index out of range while reading from nzp)r0   r)   
IndexErrorr"   )r   indexims      r   	_get_datazNpzFormat.Reader._get_data9   sJ    qyyES%5%555 !LMMM4;u-.Br6Mr   c                      t          d          Nz*The npz format does not support meta data.RuntimeError)r   r4   s     r   _get_meta_datazNpzFormat.Reader._get_meta_dataA   s    KLLLr   N)__name__
__module____qualname__r+   r.   r1   r6   r;    r   r   Readerr   +   sg        	R 	R 	R	 	 		$ 	$ 	$	 	 		M 	M 	M 	M 	Mr   r@   c                   &    e Zd Zd Zd Zd Zd ZdS )NpzFormat.Writerc                     g | _         d S r   )_imagesr*   s    r   r+   zNpzFormat.Writer._openH   s     DLLLr   c                 b    t          j        | j                                        g| j        R   d S r   )r   savez_compressedr   r!   rD   r*   s    r   r.   zNpzFormat.Writer._closeM   s1     5 5 7 7G$,GGGGGGr   c                 :    | j                             |           d S r   )rD   append)r   r5   metas      r   _append_datazNpzFormat.Writer._append_dataQ   s    L#####r   c                      t          d          r8   r9   )r   rI   s     r   set_meta_datazNpzFormat.Writer.set_meta_dataT   s    KLLLr   N)r<   r=   r>   r+   r.   rJ   rL   r?   r   r   WriterrB   G   sX        	 	 	
	H 	H 	H	$ 	$ 	$	M 	M 	M 	M 	Mr   rM   N)	r<   r=   r>   __doc__r   r   r   r@   rM   r?   r   r   r   r      s        ((4 4 44 4 4M M M M M M M M8M M M M M M M M M Mr   r   )rN   numpyr   corer   r   r?   r   r   <module>rQ      sm    *          7M 7M 7M 7M 7M 7M 7M 7M 7M 7Mr   