o
    h                     @   s\   d dl mZ d dlZd dlZd dlZdddZdd Zddd	Zd
d Z	dd Z
dd ZdS )    )IterableNFc                 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&|r&dS | dkr,dS | dkr4|r4d
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	is_filter r   M/var/www/vscode/kcb/lib/python3.10/site-packages/scipy/ndimage/_ni_support.py_extend_mode_to_code%   s&   r   c                 C   sJ   t | t}|s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strnpiterablelistlenr   )inputrankis_str
normalizederrr   r   r   _normalize_sequence>   s   

r   c                 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rR|rIt| j	dkrIt
jddd t| tj} tj|| d} | S t| tr{t| } |rg| j	dkrgtdt| jtjsrtdtj|| d} | S t| } | j |krtd|r| jj	dkrtd| S )	N)dtypecz+promoting specified output dtype to complexr	   )
stacklevelzoutput must have complex dtypezoutput must have numeric dtypezoutput shape not correct)shaper   zerosr    namepromote_types	complex64r   typekindwarningswarnr   r   
issubclassnumberasarray)outputr   r#   complex_outputcomplex_typer   r   r   _get_outputN   s:   



r2   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>u   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   r6   ndimr   r   r9   x   s   " z6axes must be an integer, iterable of integers, or Nonezaxes must be unique)tupleranger   isscalarr4   r5   r   r   
ValueErrorr   set)axesr;   r8   messager   r:   r   _check_axesn   s    

rC   c                 C   sB   t | trdS t| tu rt| tjrdS | S t | tjrdS | S )z'array or dtype' polymorphism.

    Return None for np.int8, dtype('float32') or 'f' etc
           arg for np.empty(3) etc
    N)r   r   r(   r,   r   genericr    argr   r   r   _skip_if_dtype   s
   
rG   c                 C   s   | d u s	t | trd S | S r3   )r   intrE   r   r   r   _skip_if_int   s   rI   )F)NF)collections.abcr   r4   r*   numpyr   r   r   r2   rC   rG   rI   r   r   r   r   <module>   s   

 