o
    Ö­j¼  ã                   @   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   úV/var/www/html/CropPilot/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 )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Ú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r‰tdƒ‚|r•| jj	dkr•t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   

 