U
    Gvfó  ã                   @   s:   d dl mZ d dlZd dlZdd„ Zdd„ Zd
dd	„ZdS )é    )ÚIterableNc                 C   s`   | dkrdS | dkrdS | dk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   ú=/tmp/pip-unpacked-wheel-96ln3f52/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_sequence9   s    


r   Fc                 C   s  |d kr|j }| d k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_outputI   s,    




r"   )NF)Úcollections.abcr   r   r   r   r   r"   r   r   r   r   Ú<module>   s
   