
    9is                     V   S SK r S SKrS SKrS SKrS SKrSSKJrJr  / SQr	S r
S rS r " S S	5      r " S
 S\5      r " S S\5      r " S S\S9r " S S5      rS r " S S5      r " S S\5      rS rS(S jrS rS rS rS)S jrS rS rS  rS! rS" r \RB                  " 5       RD                  RF                  \RB                  \RH                  " 5       RD                  RF                  \RH                  \RJ                  " 5       RD                  RF                  \RJ                  \RL                  " 5       RD                  RF                  \RL                  \RN                  " 5       RD                  RF                  \RB                  S#\RH                  S$\RL                  0r(S*S% jr)S& r*S' r+g)+    N   )all_warningswarn)deprecate_funcget_bound_method_classr   safe_as_intcheck_shape_equalitycheck_nDr   
reshape_ndidentityslice_at_axisdeprecate_parameter
DEPRECATEDc                 x    U nSn[        US5      (       a$  UR                  nUS-  n[        US5      (       a  M$  U$ )z+Count the number of wrappers around `func`.r   __wrapped__r   )hasattrr   )func	unwrappedcounts      U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/_shared/utils.py_count_wrappersr      sC    IE
)]
+
+))	
 )]
+
+ L    c                 b   [        U 5      n[        R                  R                  U R                  5      n U R
                  R                  S5       H  n[        X#5      nM     [        W5      nXQ-
  S-   n[        US5      $ ! [         a#  n[        SU R
                   SU< S35      UeSnAff = f)zFind stacklevel for a warning raised from a wrapper around `func`.

Try to determine the number of

Parameters
----------
func : Callable


Returns
-------
stacklevel : int
    The stacklevel. Minimum of 2.
.zCould not access `z` in z.,  may be a closure. Set stacklevel manually. Nr      )r   sysmodulesget
__module____qualname__splitgetattrAttributeErrorRuntimeErrormax)r   wrapped_countmodulenameglobal_funcglobal_wrapped_counte
stacklevels           r   _warning_stacklevelr-   $   s      $D)M [[__T__-F	<%%++C0D!&/K 1  /{;%59Jz1   !2!2 35
 C; <
 	s   -B 
B.B))B.c                 h    U R                   R                  U R                  U 5      n[        U5      nU$ )z"Return function call stack length.)__globals__r   __name__r   )r   _funclengths      r   _get_stack_lengthr3   G   s-      5EU#FMr   c                   "    \ rS rSrSr0 rS rSrg)_DecoratorBaseClassN   a  Used to manage decorators' warnings stacklevel.

The `_stack_length` class variable is used to store the number of
times a function is wrapped by a decorator.

Let `stack_length` be the total number of times a decorated
function is wrapped, and `stack_rank` be the rank of the decorator
in the decorators stack. The stacklevel of a warning is then
`stacklevel = 1 + stack_length - stack_rank`.
c                 d    U R                   R                  UR                  [        U5      5      nU$ N)_stack_lengthr   r0   r3   )selfr   r2   s      r   get_stack_length$_DecoratorBaseClass.get_stack_length\   s)    ##''7H7NOr    N)r0   r   r    __firstlineno____doc__r9   r;   __static_attributes__r=   r   r   r5   r5   N   s    	 Mr   r5   c                   ,    \ rS rSrSrSS.S jrS rSrg)change_default_valuea   ak  Decorator for changing the default value of an argument.

Parameters
----------
arg_name: str
    The name of the argument to be updated.
new_value: any
    The argument new value.
changed_version : str
    The package version in which the change will be introduced.
warning_msg: str
    Optional warning message. If None, a generic warning message
    is used.

N)warning_msgc                4    Xl         X l        X@l        X0l        g r8   )arg_name	new_valuerD   changed_version)r:   rF   rG   rH   rD   s        r   __init__change_default_value.__init__r   s     "&.r   c                 >  ^ ^^^ [         R                  " T5      R                  n[        UR	                  5       5      R                  T R                  5      mUT R                     R                  n[        T5      mT R                  cs  ST R                   ST R                   ST R                   ST R                   SU ST R                   ST R                   ST R                   S	T R                   S
3T l	        [        R                  " T5      UUU U4S j5       nU$ )NzThe new recommended value for z is z. Until version z, the default z
 value is z. From version z, the z default value will be z/. To avoid this warning, please explicitly set z value.c                     > STR                  T5      -   T-
  n[        U 5      TS-   :  aB  TR                  UR                  5       ;  a$  [        R
                  " TR                  [        US9  T" U 0 UD6$ )Nr   )r,   )r;   lenrF   keyswarningsr   rD   FutureWarning)argskwargsr,   arg_idxr   r:   
stack_ranks      r   
fixed_func1change_default_value.__call__.<locals>.fixed_func   sd    T22488:EJ4y7Q;&4==+Md..*U(((r   )inspect	signature
parameterslistrN   indexrF   defaultr   rD   rG   rH   	functoolswraps)r:   r   rY   	old_valuerU   rS   rT   s   ``   @@r   __call__change_default_value.__call__x   s   &&t,77
z()//>t}}-55	$T*
#0t>>""243G3G2H I#}}oZ	{ C  $ 4 45VDMM? K))-(8 977;}}oWN  
		) 
	) r   )rF   rH   rG   rD   r0   r   r    r>   r?   rI   r`   r@   r=   r   r   rB   rB   a   s      MQ /r   rB   c                       \ rS rSrSrS rSrg)PatchClassRepr   z5Control class representations in rendered signatures.c                 "    SU R                    S3$ )N<>)r0   )clss    r   __repr__PatchClassRepr.__repr__   s    3<<.""r   r=   N)r0   r   r    r>   r?   rj   r@   r=   r   r   rd   rd      s
    ?#r   rd   c                       \ rS rSrSrSrg)r      a  Signal value to help with deprecating parameters that use None.

This is a proxy object, used to signal that a parameter has not been set.
This is useful if ``None`` is already used for a different purpose or just
to highlight a deprecated parameter in the signature.
r=   N)r0   r   r    r>   r?   r@   r=   r   r   r   r      s    r   r   )	metaclassc                   >    \ rS rSrSr\rSrSrSSSSS.S jrS	 r	S
r
g)r      aH  Deprecate a parameter of a function.

Parameters
----------
deprecated_name : str
    The name of the deprecated parameter.
start_version : str
    The package version in which the warning was introduced.
stop_version : str
    The package version in which the warning will be replaced by
    an error / the deprecation is completed.
template : str, optional
    If given, this message template is used instead of the default one.
new_name : str, optional
    If given, the default message will recommend the new parameter name and an
    error will be raised if the user uses both old and new names for the
    same parameter.
modify_docstring : bool, optional
    If the wrapped function has a docstring, add the deprecated parameters
    to the "Other Parameters" section.
stacklevel : int, optional
    This decorator attempts to detect the appropriate stacklevel for the
    deprecation warning automatically. If this fails, e.g., due to
    decorating a closure, you can set the stacklevel manually. The
    outermost decorator should have stacklevel 2, the next inner one
    stacklevel 3, etc.

Notes
-----
Assign `DEPRECATED` as the new default value for the deprecated parameter.
This marks the status of the parameter also in the signature and rendered
HTML docs.

This decorator can be stacked to deprecate more than one parameter.

Examples
--------
>>> from skimage._shared.utils import deprecate_parameter, DEPRECATED
>>> @deprecate_parameter(
...     "b", new_name="c", start_version="0.1", stop_version="0.3"
... )
... def foo(a, b=DEPRECATED, *, c=None):
...     return a, c

Calling ``foo(1, b=2)``  will warn with::

    FutureWarning: Parameter `b` is deprecated since version 0.1 and will
    be removed in 0.3 (or later). To avoid this warning, please use the
    parameter `c` instead. For more details, see the documentation of
    `foo`.
a	  Parameter `{deprecated_name}` is deprecated since version {deprecated_version} and will be removed in {changed_version} (or later). To avoid this warning, please do not use the parameter `{deprecated_name}`. For more details, see the documentation of `{func_name}`.a  Parameter `{deprecated_name}` is deprecated since version {deprecated_version} and will be removed in {changed_version} (or later). To avoid this warning, please use the parameter `{new_name}` instead. For more details, see the documentation of `{func_name}`.NT)templatenew_namemodify_docstringr,   c                X    Xl         XPl        X@l        X l        X0l        X`l        Xpl        g r8   )deprecated_namerr   rq   start_versionstop_versionrs   r,   )r:   ru   rv   rw   rq   rr   rs   r,   s           r   rI   deprecate_parameter.__init__   s+      /  *( 0$r   c                   ^ ^^^^ [         R                  " T5      R                  n[        UR	                  5       5      R                  T R                  5      mT R                  (       a3  [        UR	                  5       5      R                  T R                  5      mOSmUT R                     R                  [        La!  [        ST R                   S[        < S35      eT R                  b  T R                  nO&T R                  b  T R                  nOT R                  nUR                  T R                  T R                  T R                   TR"                  T R                  S9m[$        R&                  " T5      UUUU U4S j5       nT R(                  (       a@  TR*                  b3  [-        TT R                  T R                  0T R                  5      nXTl        U$ )NFz
Expected `z` to have the value z2 to indicate its status in the rendered signature.)ru   deprecated_versionrH   	func_namerr   c                    > [         n[         n[        U 5      T:  a(  U T   nTR                  b  U S T [         4-   U TS-   S  -   n TR                  UR	                  5       ;   a/  UTR                     nTR                  b  [         UTR                  '   TSLa  [        U 5      T:  a  U T   nTR                  (       a-  TR                  UR	                  5       ;   a  UTR                     nU[         La  TR
                  b  TR
                  O
[        T5      n[        R                  " T	[        US9  U[         La&  [        STR                   STR                   S35      eTR                  b  X!TR                  '   T" U 0 UD6$ )Nr   Fcategoryr,   zBoth deprecated parameter `z` and new parameter `z<` are used. Use only the latter to avoid conflicting values.)r   rM   rr   ru   rN   r,   r-   rO   r   rP   
ValueError)
rQ   rR   deprecated_valuerG   r,   deprecated_idxr   new_idxr:   warning_messages
        r   rU   0deprecate_parameter.__call__.<locals>.fixed_func  s   )"I 4y>)#'#7 ==,_n-%-(~1345 
 ##v{{}4#)$*>*>#? ==,3=F4//0 e#D	G(; M	}}&++-!?"4==1	z1 2 OO,T2 
 #m
 J.$5d6J6J5K L..2mm_ =GH 
 ]].,<4==)(((r   )rW   rX   rY   rZ   rN   r[   ru   rr   r\   r   r$   rq   replace_parameter_templateremove_parameter_templateformatrv   rw   r    r]   r^   rs   r?   _docstring_add_deprecated)	r:   r   rY   rq   rU   newdocr   r   r   s	   ``    @@@r   r`   deprecate_parameter.__call__   s   &&t,77
joo/066t7K7KL==:??,-33DMMBGGd**+33:ET1122Fzn UD E 
 ==$}}H]]&66H55H"// 00#11 --'']] * 
 
	.	) .	) 
.	)`   T\\%=.t++T]];T=O=OF "(r   )ru   rs   rr   r,   rv   rw   rq   )r0   r   r    r>   r?   r   r   r   rI   r`   r@   r=   r   r   r   r      s=    2h J	 	M  %&Sr   r   c           	         U R                   c  g SSKJnJn  U" U 5      nUR                  5        HY  u  pg/ nUc  UR                  SU S35        OUR                  SU S35        USS	U 3/-  nUS
   R                  U" USUS95        M[     [        U5      n	U	R                  S5      n
U
SS nUS   R                  5       (       d+  UR                  S5        US   R                  5       (       d  M+  UR                  S5      nUS   R                  5       (       a1  USUR                  S5      -   -  nUS   R                  5       (       a  M1  US-  nUSR                  U5      -   nSR                  UR                  S5       Vs/ s H  oR                  5       PM     sn5      nU$ ! [         a    U R                   s $ f = fs  snf )a  Add deprecated kwarg(s) to the "Other Params" section of a docstring.

Parameters
----------
func : function
    The function whose docstring we wish to update.
kwarg_mapping : dict
    A dict containing {old_arg: new_arg} key/value pairs, see
    `deprecate_parameter`.
deprecated_version : str
    A major.minor version string specifying when old_arg was
    deprecated.

Returns
-------
new_doc : str
    The updated docstring. Returns the original docstring if numpydoc is
    not available.
Nr   )FunctionDoc	Parameter`z` is deprecated.zDeprecated in favor of `z`. z.. deprecated:: zOther Parametersr   )r(   typedesc
r   z
    z

)r?   numpydoc.docscraper   r   ImportErroritemsappendstrr!   strippopjoinrstrip)r   kwarg_mappingrz   r   r   Docold_argnew_argr   new_docstringr!   	no_headerdescrfinal_docstringlines                  r   r   r   S  s   ( ||=
 d
C)//1?KK!G9$456KK27)2>?'(:';<==&&7DA	
 2 HM %Eab	Il  ""a l  "" MM!E
A,



IMM!,,, A,



	VOEhmmI66Oii?;P;PQU;V W;V4;V WXOO  ||L !Xs   F$ G $F=<F=c                   .    \ rS rSrSr   SS jrS rSrg)channel_as_last_axisi  a  Decorator for automatically making channels axis last for all arrays.

This decorator reorders axes for compatibility with functions that only
support channels along the last axis. After the function call is complete
the channels axis is restored back to its original position.

Parameters
----------
channel_arg_positions : tuple of int, optional
    Positional arguments at the positions specified in this tuple are
    assumed to be multichannel arrays. The default is to assume only the
    first argument to the function is a multichannel array.
channel_kwarg_names : tuple of str, optional
    A tuple containing the names of any keyword arguments corresponding to
    multichannel arrays.
multichannel_output : bool, optional
    A boolean that should be True if the output of the function is not a
    multichannel array and False otherwise. This decorator does not
    currently support the general case of functions with multiple outputs
    where some or all are multichannel.

c                 P    [        U5      U l        [        U5      U l        X0l        g r8   )setarg_positionskwarg_namesmultichannel_output)r:   channel_arg_positionschannel_kwarg_namesr   s       r   rI   channel_as_last_axis.__init__  s&     !!6723#6 r   c                 J   ^ ^ [         R                  " T5      UU 4S j5       nU$ )Nc                    > UR                  SS 5      nUc  T" U 0 UD6$ [        R                  " U5      (       a  U4n[        U5      S:  a  [	        S5      eUS:X  d  US:X  a  T" U 0 UD6$ T	R
                  (       an  / n[        U 5       HQ  u  pEUT	R
                  ;   a+  UR                  [        R                  " XRS   S5      5        M@  UR                  U5        MS     [        U5      nOU nT	R                   H"  n[        R                  " X   US   S5      X'   M$     SUS'   T" U0 UD6nT	R                  (       a  [        R                  " USUS   5      nU$ )Nchannel_axisr   z1only a single channel axis is currently supported)r   r   )r   npisscalarrM   r   r   	enumerater   moveaxistupler   r   )
rQ   rR   r   new_argsposargr(   outr   r:   s
           r   rU   1channel_as_last_axis.__call__.<locals>.fixed_func  sG   !::nd;L#T,V,,
 {{<(( ,< 1$ !TUUu$(:T,V,,!! )$HCd000 Ca"(MN ,	 !0
 !?((!{{6<a"M )
 &(F>" +F+C''kk#r<?;Jr   )r]   r^   )r:   r   rU   s   `` r   r`   channel_as_last_axis.__call__  s'    		'	 
'	R r   )r   r   r   N))r   r=   Trb   r=   r   r   r   r     s    2 # 	7+r   r   c                   .    \ rS rSrSrSSS.S jrS rSrg)r   i  a  Decorate a deprecated function and warn when it is called.

Adapted from <http://wiki.python.org/moin/PythonDecoratorLibrary>.

Parameters
----------
deprecated_version : str
    The package version when the deprecation was introduced.
removed_version : str
    The package version in which the deprecated function will be removed.
hint : str, optional
    A hint on how to address this deprecation,
    e.g., "Use `skimage.submodule.alternative_func` instead."

Examples
--------
>>> @deprecate_func(
...     deprecated_version="1.0.0",
...     removed_version="1.2.0",
...     hint="Use `bar` instead."
... )
... def foo():
...     pass

Calling ``foo`` will warn with::

    FutureWarning: `foo` is deprecated since version 1.0.0
    and will be removed in version 1.2.0. Use `bar` instead.
N)removed_versionhintc                (    Xl         X l        X0l        g r8   )rz   r   r   )r:   rz   r   r   s       r   rI   deprecate_func.__init__  s    "4.	r   c                   ^ ^^^ STR                    ST R                   3mT R                  (       a  TST R                   S3-  mT R                  (       a"  TST R                  R	                  S5       S3-  m[        T5      m[        R                  " T5      UUU U4S j5       nST 3nUR                  c  X2l        U$ US-   UR                  -   Ul        U$ )	Nr   z` is deprecated since version z  and will be removed in version r    c                  v   > STR                  T5      -   T-
  n[        R                  " T[        US9  T" U 0 UD6$ )Nr   r}   )r;   rO   r   rP   )rQ   rR   r,   r   messager:   rT   s      r   wrapped(deprecate_func.__call__.<locals>.wrapped  s=    T22488:EJMM'MjQ(((r   z**Deprecated:** z

    )	r0   rz   r   r   r   r   r]   r^   r?   )r:   r   r   docr   rT   s   ``  @@r   r`   deprecate_func.__call__	  s    <&&') 	 9$:N:N9OqQQG99499++C0133G$T*
			) 
	) !	*??"!O  "J.@GOr   )rz   r   r   rb   r=   r   r   r   r     s    < ?C 
r   r   c                 n    [         R                  S:  a  U R                  $ U R                  R                  $ )z$Return the class for a bound method.3)r   versionim_class__self__	__class__)ms    r   r   r   &  s&    s*1::D

0D0DDr   c                 j   [         R                  " U 5      S-  nUR                  S:X  a  US:  a  SU-
  nOSX"S:     -
  X"S:  '    [         R                  R	                  USUS9  [         R                  " U 5      R                  [         R                  5      $ ! [
         a    [        SU  S35      ef = f)a/  
Attempt to safely cast values to integer format.

Parameters
----------
val : scalar or iterable of scalars
    Number or container of numbers which are intended to be interpreted as
    integers, e.g., for indexing purposes, but which may not carry integer
    type.
atol : float
    Absolute tolerance away from nearest integer to consider values in
    ``val`` functionally integers.

Returns
-------
val_int : NumPy scalar or ndarray of dtype `np.int64`
    Returns the input value(s) coerced to dtype `np.int64` assuming all
    were within ``atol`` of the nearest integer.

Notes
-----
This operation calculates ``val`` modulo 1, which returns the mantissa of
all values. Then all mantissas greater than 0.5 are subtracted from one.
Finally, the absolute tolerance from zero is calculated. If it is less
than ``atol`` for all value(s) in ``val``, they are rounded and returned
in an integer array. Or, if ``val`` was a scalar, a NumPy scalar type is
returned.

If any value(s) are outside the specified tolerance, an informative error
is raised.

Examples
--------
>>> safe_as_int(7.0)
7

>>> safe_as_int([9, 4, 2.9999999999])
array([9, 4, 3])

>>> safe_as_int(53.1)
Traceback (most recent call last):
    ...
ValueError: Integer argument required but received 53.1, check inputs.

>>> safe_as_int(53.01, atol=0.01)
53

r   r   g      ?)atolz'Integer argument required but received z, check inputs.)
r   asarrayndimtestingassert_allcloseAssertionErrorr   roundastypeint64)valr   mods      r   r   r   +  s    b **S/A
C xx1}9c'CSs^+#I



""3"5 88C=))  
5#oN
 	

s   B B2c                  `   ^ U S   m[        U4S jU SS  5       5      (       d  [        S5      eg)z)Check that all images have the same shaper   c              3   V   >#    U  H  nTR                   UR                   :H  v   M      g 7fr8   )shape).0imageimage0s     r   	<genexpr>'check_shape_equality.<locals>.<genexpr>r  s     C
uv||u{{*
s   &)r   Nz+Input images must have the same dimensions.)allr   )imagesr   s    @r   r	   r	   o  s2    AYFCqr
CCCFGG
r   c                 .    [        S5      4U-  U 4-   S-   $ )a  
Construct tuple of slices to slice an array in the given dimension.

Parameters
----------
sl : slice
    The slice for the given dimension.
axis : int
    The axis to which `sl` is applied. All other dimensions are left
    "unsliced".

Returns
-------
sl : tuple of slices
    A tuple with slices matching `shape` in length.

Examples
--------
>>> slice_at_axis(slice(None, 3, -1), 1)
(slice(None, None, None), slice(None, 3, -1), Ellipsis)
N).)slice)slaxiss     r   r   r   w  s!    , $K>D B5(611r   c                 x    U R                   S:w  a  [        S5      eS/U-  nSX2'   [        R                  " X5      $ )a@  Reshape a 1D array to have n dimensions, all singletons but one.

Parameters
----------
arr : array, shape (N,)
    Input array
ndim : int
    Number of desired dimensions of reshaped array.
dim : int
    Which dimension/axis will not be singleton-sized.

Returns
-------
arr_reshaped : array, shape ([1, ...], N, [1,...])
    View of `arr` reshaped to the desired shape.

Examples
--------
>>> rng = np.random.default_rng()
>>> arr = rng.random(7)
>>> reshape_nd(arr, 2, 0).shape
(7, 1)
>>> reshape_nd(arr, 3, 1).shape
(1, 7, 1)
>>> reshape_nd(arr, 4, -1).shape
(1, 1, 1, 7)
r   zarr must be a 1D arrayr   )r   r   r   reshape)arrr   dim	new_shapes       r   r   r     s<    8 xx1}122d
IIN::c%%r   c                 <   [         R                  " U 5      n SnSn[        U[        5      (       a  U/nU R                  S:X  a  [        XB-  5      eU R                  U;  a8  [        X2SR                  U Vs/ s H  n[        U5      PM     sn5      4-  5      egs  snf )a"  
Verify an array meets the desired ndims and array isn't empty.

Parameters
----------
array : array-like
    Input array to be validated
ndim : int or iterable of ints
    Allowable ndim or ndims for the array.
arg_name : str, optional
    The name of the array in the original function.

z1The parameter `%s` must be a %s-dimensional arrayz+The parameter `%s` cannot be an empty arrayr   z-or-N)	r   
asanyarray
isinstanceintsizer   r   r   r   )arrayr   rF   msg_incorrect_dimmsg_empty_arrayns         r   r
   r
     s     MM% EKCO$vzzQ566zz6;;7M1A7M+N OO
 	
 7Ms   5Bc                    U R                   [        R                  :X  a  U R                  [        R                  5      $ U(       a1  U R                   R
                  S;  a  U R                  [        5      n U $ SSKJn  U" U 5      n U $ )a  Convert input image to float image with the appropriate range.

Parameters
----------
image : ndarray
    Input image.
preserve_range : bool
    Determines if the range of the image should be kept or transformed
    using img_as_float. Also see
    https://scikit-image.org/docs/dev/user_guide/data_types.html

Notes
-----
* Input images with `float32` data type are not upcast.

Returns
-------
image : ndarray
    Transformed version of the input.

dfr   )img_as_float)	dtyper   float16r   float32charfloat
util.dtyper   )r   preserve_ranger   s      r   convert_to_floatr    sg    , {{bjj ||BJJ'' ;;4'LL'E
 L 	.U#Lr   c                     Uc  U [         :X  a  S$ S$ US:  d  US:  a  [        S5      eU [         :X  a  US:w  a  [        S5      eU$ )a  Validate and return spline interpolation's order.

Parameters
----------
image_dtype : dtype
    Image dtype.
order : int, optional
    The order of the spline interpolation. The order has to be in
    the range 0-5. See `skimage.transform.warp` for detail.

Returns
-------
order : int
    if input order is None, returns 0 if image_dtype is bool and 1
    otherwise. Otherwise, image_dtype is checked and input order
    is validated accordingly (order > 0 is not supported for bool
    image dtype)

r   r      z6Spline interpolation order has to be in the range 0-5.zInput image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitly cast input image to another data type.)boolr   )image_dtypeorders     r   _validate_interpolation_orderr
    s[    * }4'q.Q.qyEAITUUduz5
 	
 Lr   c                 .    [        SSSS9nX;   a  X   n U $ )z7Convert padding modes from `ndi.correlate` to `np.pad`.edge	symmetricreflect)nearestr  mirror)dictmodemode_translation_dicts     r   _to_np_moder    s$     YW$$*Kr   c                 ^    [        SSSSSS9nX;  a  [        SU  S35      e[        X   5      $ )	zEConvert from `numpy.pad` mode name to the corresponding ndimage mode.constantr  r  r  wrap)r  r  r  r  r  zUnknown mode: 'z', or cannot translate mode. The mode should be one of 'constant', 'edge', 'symmetric', 'reflect', or 'wrap'. See the documentation of numpy.pad for more info.)r  r   _fix_ndimage_moder  s     r   _to_ndimage_moder    sS      (dV $ 
 	
 2899r   c                 .    SSS.nUR                  X 5      $ )Nzgrid-constantz	grid-wrap)r  r  )r   )r  
grid_modess     r   r  r  2  s     .{CJ>>$%%r   gGc                 ,   [        U [        5      (       a  [        R                  " S U  5       6 $ [        R                  " U 5      n U(       d  U R
                  S:X  a  [        S5      e[        R                  U R                  [        R                  5      $ )a  Return an appropriate floating-point dtype for a given dtype.

float32, float64, complex64, complex128 are preserved.
float16 is promoted to float32.
complex256 is demoted to complex128.
Other types are cast to float64.

Parameters
----------
input_dtype : np.dtype or tuple of np.dtype
    The input dtype. If a tuple of multiple dtypes is provided, each
    dtype is first converted to a supported floating point type and the
    final dtype is then determined by applying `np.result_type` on the
    sequence of supported floating point types.
allow_complex : bool, optional
    If False, raise a ValueError on complex-valued inputs.

Returns
-------
float_type : dtype
    Floating-point dtype for the image.
c              3   8   #    U  H  n[        U5      v   M     g 7fr8   )_supported_float_type)r   ds     r   r   (_supported_float_type.<locals>.<genexpr>^  s     N+Q 5a 8 8+s   cz%complex valued input is not supported)r   r   r   result_typer   kindr   new_float_typer   r   float64)input_dtypeallow_complexs     r   r!  r!  F  sm    . +u%%~~N+NOO((;'K[--4@AAk..

;;r   c                     U $ )z&Returns the first argument unmodified.r=   )r   rQ   rR   s      r   r   r   e  s    Lr   c                    [         R                  " U 5      n U R                  [        :w  a2  [         R                  " U S:g  U S:g  -  5      (       a  [        U S35      e[         R                  " U [        S9$ )zReturn `array` as a numpy.ndarray of dtype bool.

Raises
------
ValueError:
    An error including the given `variable_name` if `array` can not be
    safely cast to a boolean array.
r   r   zo array is not of dtype boolean or contains values other than 0 and 1 so cannot be safely cast to boolean array.)r   )r   r   r   r  anyr   )r   variable_names     r   as_binary_ndarrayr/  j  si     JJuE{{d665A:%1*-.. / "0 1 
 ::e4((r   )gMbP?)r   )F),r]   rW   r   rO   numpyr   	_warningsr   r   __all__r   r-   r3   r5   rB   r   rd   r   r   r   r   r   r   r   r	   r   r   r
   r  r
  r  r  r  r   r   r   r(  	complex64
complex128r   r'  r!  r   r/  r=   r   r   <module>r5     sz     
   )  F &0. 0f#T #> l l^?DM M`>( >BE
A*H22 &F
6!H"J:&& JJLRZZJJLRZZLLNr||MMOJJLRZZ
<>
)r   