a
    R¹§e±  ã                   @   sJ   d dl mZ d dlZd dlZd dlZdd„ Zdd„ Zddd	„Zd
d„ ZdS )é    )ÚIterableNc                 C   s`   | dkrdS | dkrdS | dv r$dS | dkr0dS | d	kr<d
S | dkrHdS | dkrTdS t dƒ‚dS )zAConvert an extension mode to the corresponding integer code.
    Znearestr   Úwrapé   )Zreflectzgrid-mirroré   Zmirroré   Zconstanté   z	grid-wrapé   zgrid-constanté   zboundary mode not supportedN)ÚRuntimeError)Úmode© r   úM/var/www/sunrise/env/lib/python3.9/site-packages/scipy/ndimage/_ni_support.pyÚ_extend_mode_to_code%   s    r   c                 C   sH   t | tƒ}|s:t | tƒr:t| ƒ}t|ƒ|krDd}t|ƒ‚n
| g| }|S )z·If input is a scalar, create a sequence of length equal to the
    rank by duplicating the input. If input is a sequence,
    check if its length is equal to the length of array.
    z6sequence argument must have length equal to input rank)Ú
isinstanceÚstrr   ÚlistÚlenr
   )ÚinputZrankZis_strÚ
normalizedÚerrr   r   r   Ú_normalize_sequence:   s    


r   Fc                 C   s  |d u r|j }| d u rN|s.tj||jjd} nt |jtj¡}tj||d} n¼t| ttjfƒrš|rŠt | ¡j	dkrŠt
 d¡ t | tj¡} tj|| d} npt| tƒrÚtj|  } |rÊt | ¡j	dkrÊtdƒ‚tj|| d} n0| j |krîtdƒ‚n|r
| jj	dkr
tdƒ‚| S )N)ÚdtypeÚcz+promoting specified output dtype to complexzoutput must have complex dtypezoutput shape not correct)ÚshapeÚnumpyÚzerosr   ÚnameZpromote_typesZ	complex64r   ÚtypeÚkindÚwarningsÚwarnr   Z
sctypeDictr
   )Úoutputr   r   Zcomplex_outputZcomplex_typer   r   r   Ú_get_outputJ   s,    




r"   c                    sÀ   | d u rt tˆ ƒƒS t | ¡r,t | ¡f} npt| tƒr| D ]<}t dd„ | D ƒƒ} |ˆ  k sf|ˆ d kr:td|› dƒ‚q:t ‡ fdd„| D ƒƒ} nd}t|ƒ‚t	t t
| ƒƒƒt	| ƒkr¼tdƒ‚| S )	Nc                 s   s   | ]}t  |¡V  qd S )N)ÚoperatorÚindex©Ú.0Úaxr   r   r   Ú	<genexpr>l   ó    z_check_axes.<locals>.<genexpr>r   zspecified axis: z is out of rangec                 3   s"   | ]}|d k r|ˆ  n|V  qdS )r   Nr   r%   ©Úndimr   r   r(   o   r)   z6axes must be an integer, iterable of integers, or Nonezaxes must be unique)ÚtupleÚranger   Zisscalarr#   r$   r   r   Ú
ValueErrorr   Úset)Zaxesr+   r'   Úmessager   r*   r   Ú_check_axese   s    

r1   )NF)	Úcollections.abcr   r#   r   r   r   r   r"   r1   r   r   r   r   Ú<module>   s   
