o
    i                     @   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.
    Znearestr   wrap   )Zreflectzgrid-mirror   Zmirror   Zconstant   z	grid-wrap   zgrid-constant   zboundary mode not supported)RuntimeError)modeZ	is_filter r   S/home/kim/smarthome/.venv/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
   )inputZrankZ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   Zzerosr   nameZpromote_typesZ	complex64r   typekindwarningswarnr   r
   
issubclassnumberZasarray)outputr   r   Zcomplex_outputZcomplex_typer   r   r   _get_outputN   s:   

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

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>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   r)   ndimr   r   r,   x   s   " 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_axesn   s    

r4   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   Zgenericr   argr   r   r   _skip_if_dtype   s
   
r7   c                 C   s   | d u s	t | trd S | S r&   )r   intr5   r   r   r   _skip_if_int   s   r9   )F)NF)collections.abcr   r'   r    numpyr   r   r   r%   r4   r7   r9   r   r   r   r   <module>   s   

 