o
    h                     @   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rdS | d	krd
S | dkr$dS | dkr*dS t d)zAConvert an extension mode to the corresponding integer code.
    nearestr   wrap   )reflectzgrid-mirror   mirror   constant   z	grid-wrap   zgrid-constant   zboundary mode not supported)RuntimeError)mode r   T/var/www/html/scripts/venv/lib/python3.10/site-packages/scipy/ndimage/_ni_support.py_extend_mode_to_code%   s   r   c                 C   sJ   t | t}|st | trt| }t||krd}t||S | g| }|S )zIf 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   )inputrankis_str
normalizederrr   r   r   _normalize_sequence:   s   

r   Fc                 C   s  |d u r|j }| d u r)|stj||jjd} | S t|jtj}tj||d} | S t| ttjfrP|rGt| j	dkrGt
d t| tj} tj|| d} | S t| trqtj|  } |rht| j	dkrhtdtj|| d} | S | j |krztd|r| jj	dkrtd| S )N)dtypecz+promoting specified output dtype to complexzoutput must have complex dtypezoutput shape not correct)shapenumpyzerosr   namepromote_types	complex64r   typekindwarningswarnr   
sctypeDictr   )outputr   r   complex_outputcomplex_typer   r   r   _get_outputJ   s4   




r-   c                    s   | d u r
t t S t| rt| f} n8t| trH| D ]}t dd | D } |  k s3| 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   s    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   r0   ndimr   r   r3   o   s   " z6axes must be an integer, iterable of integers, or Nonezaxes must be unique)tupleranger    isscalarr.   r/   r   r   
ValueErrorr   set)axesr5   r2   messager   r4   r   _check_axese   s    

r=   )NF)	collections.abcr   r.   r'   r    r   r   r-   r=   r   r   r   r   <module>   s   
