
    4[g~                     ~   U d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlmZ d dl	Z	d dl
Z
d dlmZmZmZmZ d dlZd dlmZmZmZ ee   ed<   ee   ed<   ee   ed<   ej6                  j9                  ej:                        d	k\  rd d
lmZm Z m!Z!m"Z" nd dlmZm Z m!Z! e#Z"eed<   eed<   ej6                  j9                  ej:                        dk\  rH	  ejH                         5   ejJ                  dde&       ejN                  Z(ejR                  Z*ddd       nejX                  Z(ejZ                  Z*ee.ej^                  f   Z0ee1ejd                  ej^                  f   Z3ee4   ed<   ej6                  j9                  ej:                        dk\  rdZ5nQej6                  j9                  ej:                        dk  rdZ5n&	  ejl                  dg      jo                  d       dZ5erjeee0ejp                  jr                  ejp                  jt                  f      Z; edeejp                  jr                  ejp                  jt                  f         Z<	 d dl=m9Z9 d@dZ?dAdZ@e1ddfdZAd  ZBd!e.d"e1fd#ZCd$ ZD	 	 	 dBd%ZEdCd&ZF ed'g d(      ZGd) ZH G d* d+      ZI G d, d-      ZJ	 	 dDd.ZKedEd/       ZLd0 ZMdFd1ZNd2 ZOdGd3ZPdHdd4d5ZQdCd6ZRd7 ZSdd4d8ZTd9 ZUd: ZV G d; d<eW      ZXdAd=ZYd> ZZdId?Z[y# 1 sw Y   xY w# e+$ r ejX                  Z(ejZ                  Z*Y w xY w# e#$ r dZ5Y Fw xY w# e>$ r  G d d      Z9Y w xY w)J    N)contextmanager)
namedtuple)OptionalUnionTYPE_CHECKINGTypeVar)array_namespaceis_numpysize	AxisErrorComplexWarningVisibleDeprecationWarningz1.25.0)r   r   r   DTypePromotionError)r   r   r   np_longnp_ulongz
2.0.0.dev0ignorez/.*In the future `np\.long` will be defined as.*copy_if_neededz2.0.0z1.28.0F   copyGeneratorType)bound)	Generatorc                       e Zd Zy)r   N)__name__
__module____qualname__     K/var/www/html/bid-api/venv/lib/python3.12/site-packages/scipy/_lib/_util.pyr   r   T   s    r   r   c                     t         g| }||cxu rn ||t        d       |j                   g| }|j                  dg      j                  }|j                  |d   |d      |dd c }|j                   | fd|D               }|V|j                  |      }|j                  |j                  |j                        }	|j                   j                  ||		      }
nT  |j                   |fd
|D               }|j                  ||      }	|j                   j                  |	      }
||
<   ||
 <   |
S )a  Return elements chosen from two possibilities depending on a condition

    Equivalent to ``f(*arrays) if cond else fillvalue`` performed elementwise.

    Parameters
    ----------
    cond : array
        The condition (expressed as a boolean array).
    arrays : tuple of array
        Arguments to `f` (and `f2`). Must be broadcastable with `cond`.
    f : callable
        Where `cond` is True, output will be ``f(arr1[cond], arr2[cond], ...)``
    fillvalue : object
        If provided, value with which to fill output array where `cond` is
        not True.
    f2 : callable
        If provided, output will be ``f2(arr1[cond], arr2[cond], ...)`` where
        `cond` is not True.

    Returns
    -------
    out : array
        An array with elements from the output of `f` where `cond` is True
        and `fillvalue` (or elements from the output of `f2`) elsewhere. The
        returned array has data type determined by Type Promotion Rules
        with the output of `f` and `fillvalue` (or the output of `f2`).

    Notes
    -----
    ``xp.where(cond, x, fillvalue)`` requires explicitly forming `x` even where
    `cond` is False. This function evaluates ``f(arr1[cond], arr2[cond], ...)``
    onle where `cond` ``is True.

    Examples
    --------
    >>> import numpy as np
    >>> a, b = np.array([1, 2, 3, 4]), np.array([5, 6, 7, 8])
    >>> def f(a, b):
    ...     return a*b
    >>> _lazywhere(a > 2, (a, b), f, np.nan)
    array([ nan,  nan,  21.,  32.])

    Nz1Exactly one of `fillvalue` or `f2` must be given.Tr   Fr   r   c              3   (   K   | ]	  }|     y wNr   .0arrconds     r    	<genexpr>z_lazywhere.<locals>.<genexpr>   s     73t9   
fill_valuedtypec              3   (   K   | ]	  }|     y wr#   r   )r%   r&   nconds     r    r(   z_lazywhere.<locals>.<genexpr>   s     =fsE
fr)   r,   )
r	   
ValueErrorbroadcast_arraysasarrayr,   astyperesult_typefullshapeempty)r'   arraysf	fillvaluef2xpargs
bool_dtypetemp1r,   outtemp2r.   s   `           @r    
_lazywhererB   X   s<   X 
	'	'B
iR^	8MLMM2t-f-DTF#))J99T!Wju9=tABxLD&JJq7789E	zJJy)	u{{IOO<ggdjjYegD

2=f=>?ue,hhtzzh/E
CIJr   c                   
 t        j                  | }t        j                  |D cg c]  }|j                  j                   c}      }t        j
                  t        j                  |d         ||      }t        ||       D ]g  \  }
t        j                  
du       rt        j                  
|d         \  
}t        
fd|D              }	t        j                  |
 ||	        i |S c c}w )aZ  
    Mimic `np.select(condlist, choicelist)`.

    Notice, it assumes that all `arrays` are of the same shape or can be
    broadcasted together.

    All functions in `choicelist` must accept array arguments in the order
    given in `arrays` and must return an array of the same shape as broadcasted
    `arrays`.

    Examples
    --------
    >>> import numpy as np
    >>> x = np.arange(6)
    >>> np.select([x <3, x > 3], [x**2, x**3], default=0)
    array([  0,   1,   4,   0,  64, 125])

    >>> _lazyselect([x < 3, x > 3], [lambda x: x**2, lambda x: x**3], (x,))
    array([   0.,    1.,    4.,   0.,   64.,  125.])

    >>> a = -np.ones_like(x)
    >>> _lazyselect([x < 3, x > 3],
    ...             [lambda x, a: x**2, lambda x, a: a * x**3],
    ...             (x, a), default=np.nan)
    array([   0.,    1.,    4.,   nan,  -64., -125.])

    r   r*   Fc              3   J   K   | ]  }t        j                  |        y wr#   )npextractr$   s     r    r(   z_lazyselect.<locals>.<genexpr>   s     =fsRZZc*fs    #)rE   r1   mintypecoder,   charr5   r6   zipalltupleplace)condlist
choicelistr8   defaultatcoder@   func_tempr'   s             @r    _lazyselectrU      s    8   &)FNN&9&QAGGLL&9:E
''"((6!9%'
GC*h/
d66$%- %%dF1I6a=f==
dD$K( 0 J :s   C1Cc                    t        j                  |      }||j                  }t        | d      s| f} t	        j
                  t        j                  |       |j                  z  }t        j                  ||z   dz   t         j                        }|j                  d   d   |z  }|dk7  r||z
  }||||z   dz    dd }t        j                  | |||      }|j                  d       |S )zAllocate a new ndarray with aligned memory.

    Primary use case for this currently is working around a f2py issue
    in NumPy 1.9.1, where dtype.alignment is such that np.zeros() does
    not necessarily create arrays aligned up to it.

    N__len__r   datar   )order)rE   r,   	alignmenthasattr	functoolsreduceoperatormulitemsizer7   uint8__array_interface__ndarrayfill)r6   r,   r[   alignr   bufoffsetrY   s           r    _aligned_zerosrj      s     HHUOE}5)$HLL%05>>AD
((4%<!#RXX
.C$$V,Q/%7F{ fVD[]
#CR
(C::eUCu5DIIaLKr   c                     | j                   6| j                  | j                   j                  dz  k  r| j                         S | S )zReturn an array equivalent to the input array. If the input
    array is a view of a much larger array, copy its contents to a
    newly allocated array. Otherwise, return the input unchanged.
       )baser   r   )arrays    r    _prune_arrayro      s7    
 zz%**uzz!/C"Czz|Lr   nreturnc                 h    | dk  rt        t        j                  |             S t        j                  S )zlCompute the factorial and return as a float

    Returns infinity when result is too large for a double
       )floatmath	factorialrE   inf)rp   s    r    float_factorialrx      s'    
 ()3w5"#:BFF:r   c                    | | t         j                  u r$t         j                  j                  j                  S t	        | t
        j                  t         j                  f      rt         j                  j                  |       S t	        | t         j                  j                  t         j                  j                  f      r| S t        d|  d      )a`  Turn `seed` into a `np.random.RandomState` instance.

    Parameters
    ----------
    seed : {None, int, `numpy.random.Generator`, `numpy.random.RandomState`}, optional
        If `seed` is None (or `np.random`), the `numpy.random.RandomState`
        singleton is used.
        If `seed` is an int, a new ``RandomState`` instance is used,
        seeded with `seed`.
        If `seed` is already a ``Generator`` or ``RandomState`` instance then
        that instance is used.

    Returns
    -------
    seed : {`numpy.random.Generator`, `numpy.random.RandomState`}
        Random number generator.

    'z<' cannot be used to seed a numpy.random.RandomState instance)rE   randommtrand_rand
isinstancenumbersIntegralintegerRandomStater   r0   )seeds    r    check_random_stater      s    & |tryy(yy%%%$))2::67yy$$T**$..		0C0CDE
q ! ! " "r   c                    |s,ddl }|j                  j                  |       rd}t        |      |s*t        j
                  j                  |       rt        d      |rt        j                  nt        j                  } ||       } |s,| j                  t	        j                  d      u rt        d      |rFt	        j                  | j                  t        j                        s || t        j                        } | S )aA  
    Helper function for SciPy argument validation.

    Many SciPy linear algebra functions do support arbitrary array-like
    input arguments. Examples of commonly unsupported inputs include
    matrices containing inf/nan, sparse matrix representations, and
    matrices with complicated elements.

    Parameters
    ----------
    a : array_like
        The array-like input.
    check_finite : bool, optional
        Whether to check that the input matrices contain only finite numbers.
        Disabling may give a performance gain, but may result in problems
        (crashes, non-termination) if the inputs do contain infinities or NaNs.
        Default: True
    sparse_ok : bool, optional
        True if scipy sparse matrices are allowed.
    objects_ok : bool, optional
        True if arrays with dype('O') are allowed.
    mask_ok : bool, optional
        True if masked arrays are allowed.
    as_inexact : bool, optional
        True to convert the input array to a np.inexact dtype.

    Returns
    -------
    ret : ndarray
        The converted validated array.

    r   NzxSparse matrices are not supported by this function. Perhaps one of the scipy.sparse.linalg functions would work instead.zmasked arrays are not supportedOzobject arrays are not supportedr/   )scipy.sparsesparseissparser0   rE   maisMaskedArrayasarray_chkfiniter2   r,   
issubdtypeinexactfloat64)	rP   check_finite	sparse_ok
objects_okmask_ok
as_inexactscipymsgtoarrays	            r    _asarray_validatedr     s    F <<  #)C S/!55q!>??&2b""

G
A77bhhsm#>??}}QWWbjj1,AHr   c                     	 t        j                  |       } || |k  rt        | d|       d| S # t        $ r t        | d      dw xY w)a  
    Validate a scalar integer.

    This function can be used to validate an argument to a function
    that expects the value to be an integer.  It uses `operator.index`
    to validate the value (so, for example, k=2.0 results in a
    TypeError).

    Parameters
    ----------
    k : int
        The value to be validated.
    name : str
        The name of the parameter.
    minimum : int, optional
        An optional lower bound.
    z must be an integer.Nz" must be an integer not less than )r`   index	TypeErrorr0   )knameminimums      r    _validate_intr   K  st    $ANN1 q7{D6 "!!(	+ ,15	6H  A4& 456D@As	   1 A
FullArgSpec)r=   varargsvarkwdefaults
kwonlyargskwonlydefaultsannotationsc           	         t        j                  |       }|j                  j                         D cg c]N  }|j                  t         j
                  j                  t         j
                  j                  fv r|j                  P }}|j                  j                         D cg c]5  }|j                  t         j
                  j                  k(  r|j                  7 }}|r|d   nd}|j                  j                         D cg c]5  }|j                  t         j
                  j                  k(  r|j                  7 }}|r|d   nd}t        d |j                  j                         D              xs d}|j                  j                         D cg c]5  }|j                  t         j
                  j                  k(  r|j                  7 }}|j                  j                         D ci c]X  }|j                  t         j
                  j                  k(  r/|j                  |j                  ur|j                  |j                  Z }}|j                  j                         D ci c]1  }|j                  |j                  ur|j                  |j                  3 }	}t!        ||||||xs d|	      S c c}w c c}w c c}w c c}w c c}w c c}w )as  inspect.getfullargspec replacement using inspect.signature.

    If func is a bound method, do not list the 'self' parameter.

    Parameters
    ----------
    func : callable
        A callable to inspect

    Returns
    -------
    fullargspec : FullArgSpec(args, varargs, varkw, defaults, kwonlyargs,
                              kwonlydefaults, annotations)

        NOTE: if the first argument of `func` is self, it is *not*, I repeat
        *not*, included in fullargspec.args.
        This is done for consistency between inspect.getargspec() under
        Python 2.x, and inspect.signature() under Python 3.x.

    r   Nc              3      K   | ]O  }|j                   t        j                  j                  k(  r&|j                  |j
                  ur|j                   Q y wr#   )kindinspect	ParameterPOSITIONAL_OR_KEYWORDrO   r7   )r%   ps     r    r(   z)getfullargspec_no_self.<locals>.<genexpr>  sD      2aFFg''===IIQWW$ 	
		2s   AA)r   	signature
parametersvaluesr   r   r   POSITIONAL_ONLYr   VAR_POSITIONALVAR_KEYWORDrK   KEYWORD_ONLYrO   r7   
annotationr   )
rR   sigr   r=   r   r   r   r   
kwdefaultsr   s
             r    getfullargspec_no_selfr   y  s   * 

D
!C--//166g''==''779 9 	
/ 	  --//166W&&555 	
/   $gajG--//166W&&222 	
/ 
  E!H4E >>002   
	  --//166W&&333 	
/   .1^^-B-B-D ,-DVVw00===))177* &&!))#-DJ , 251F1F1H 31HAll!''1 661<<'1HK 3tWeXz!)T;8 8;

,3s%   AJ3#:J8:J=:K+AK&6Kc                       e Zd ZdZd Zd Zy)_FunctionWrapperz?
    Object to wrap user's function, allowing picklability
    c                 4    || _         |g | _        y || _        y r#   r9   r=   )selfr9   r=   s      r    __init__z_FunctionWrapper.__init__  s    ,B	D	r   c                 <     | j                   |g| j                   S r#   r   )r   xs     r    __call__z_FunctionWrapper.__call__  s    tvva$$))$$r   N)r   r   r   __doc__r   r   r   r   r    r   r     s    1%r   r   c                   <    e Zd ZdZd
dZd Zd Zd Zd Zd Z	d Z
y	)
MapWrapperav  
    Parallelisation wrapper for working with map-like callables, such as
    `multiprocessing.Pool.map`.

    Parameters
    ----------
    pool : int or map-like callable
        If `pool` is an integer, then it specifies the number of threads to
        use for parallelization. If ``int(pool) == 1``, then no parallel
        processing is used and the map builtin is used.
        If ``pool == -1``, then the pool will utilize all available CPUs.
        If `pool` is a map-like callable that follows the same
        calling sequence as the built-in map function, then this callable is
        used for parallelization.
    c                    d | _         t        | _        d| _        t	        |      r|| _         | j                   | _        y ddlm} t        |      dk(  r/ |       | _         | j                   j                  | _        d| _        y t        |      dk(  ry t        |      dkD  r: |t        |            | _         | j                   j                  | _        d| _        y t        d      )	NFr   )PoolrZ   Tr   )	processeszUNumber of workers specified must be -1, an int >= 1, or an object with a 'map' method)	poolmap_mapfunc	_own_poolcallablemultiprocessingr   intRuntimeError)r   r   r   s      r    r   zMapWrapper.__init__  s    	D>DI IIDM,4yB F	 $		!%TaTQ 3t95	 $		!%" $, - -r   c                     | S r#   r   r   s    r    	__enter__zMapWrapper.__enter__  s    r   c                 R    | j                   r| j                  j                          y y r#   )r   r   	terminater   s    r    r   zMapWrapper.terminate  s    >>II! r   c                 R    | j                   r| j                  j                          y y r#   )r   r   joinr   s    r    r   zMapWrapper.join  s    >>IINN r   c                 R    | j                   r| j                  j                          y y r#   )r   r   closer   s    r    r   zMapWrapper.close  s    >>IIOO r   c                     | j                   r5| j                  j                          | j                  j                          y y r#   )r   r   r   r   )r   exc_type	exc_value	tracebacks       r    __exit__zMapWrapper.__exit__  s,    >>IIOOII! r   c                 b    	 | j                  ||      S # t        $ r}t        d      |d }~ww xY w)Nz;The map-like callable must be of the form f(func, iterable))r   r   )r   rR   iterablees       r    r   zMapWrapper.__call__  s=    	>==x00 	> 6 7<=>	>s    	.).Nr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r     s*    -8""
>r   r   c                 .   t        | t              r| j                  |||||      S | $t        j                  j
                  j                  } |r3|| j                  |dz   ||      S || j                  ||dz   ||      S | j                  ||||      S )al  
    Return random integers from low (inclusive) to high (exclusive), or if
    endpoint=True, low (inclusive) to high (inclusive). Replaces
    `RandomState.randint` (with endpoint=False) and
    `RandomState.random_integers` (with endpoint=True).

    Return random integers from the "discrete uniform" distribution of the
    specified dtype. If high is None (the default), then results are from
    0 to low.

    Parameters
    ----------
    gen : {None, np.random.RandomState, np.random.Generator}
        Random number generator. If None, then the np.random.RandomState
        singleton is used.
    low : int or array-like of ints
        Lowest (signed) integers to be drawn from the distribution (unless
        high=None, in which case this parameter is 0 and this value is used
        for high).
    high : int or array-like of ints
        If provided, one above the largest (signed) integer to be drawn from
        the distribution (see above for behavior if high=None). If array-like,
        must contain integer values.
    size : array-like of ints, optional
        Output shape. If the given shape is, e.g., (m, n, k), then m * n * k
        samples are drawn. Default is None, in which case a single value is
        returned.
    dtype : {str, dtype}, optional
        Desired dtype of the result. All dtypes are determined by their name,
        i.e., 'int64', 'int', etc, so byteorder is not available and a specific
        precision may have different C types depending on the platform.
        The default value is 'int64'.
    endpoint : bool, optional
        If True, sample from the interval [low, high] instead of the default
        [low, high) Defaults to False.

    Returns
    -------
    out: int or ndarray of ints
        size-shaped array of random integers from the appropriate distribution,
        or a single such random int if size not provided.
    )highr   r,   endpointr   )r   r,   )r   r   r,   )r~   r   integersrE   r{   r|   r}   randint)genlowr   r   r,   r   s         r    rng_integersr     s    X #y!||CdU%-  / 	/ ;))""((C |{{37U{CC{{3TAXD{NN {{3TE{BBr   c              #      K   t         j                  j                  | ffd	t         j                  _        	 d t         j                  _        y# t         j                  _        w xY ww)z0Context with a fixed np.random.default_rng seed.c                      |       S r#   r   r   orig_funs    r    <lambda>z$_fixed_default_rng.<locals>.<lambda>J  s	    htnr   N)rE   r{   default_rngr   s    @r    _fixed_default_rngr   F  sG      yy$$H(,<BII) (				s   5A-A A-A**A-c                 ^     t        j                  dt         j                         fd}|S )a&  Rewrite the HTML rendering of ``np.random.default_rng``.

    This is intended to decorate
    ``numpydoc.docscrape_sphinx.SphinxDocString._str_examples``.

    Examples are only run by Sphinx when there are plot involved. Even so,
    it does not change the result values getting printed.
    z*np.random.default_rng\((0x[0-9A-F]+|\d+)\)c                  j     | i |}|D cg c]  }t        j                  d|       }}|S c c}w )Nznp.random.default_rng())resub)r=   kwargsreslinelinesrR   patterns        r    _wrappedz#_rng_html_rewrite.<locals>._wrapped]  sN    D#F# 
 FF75t< 	 
 	
s   0)r   compileI)rR   r   r   s   ` @r    _rng_html_rewriter   Q  s&     jjFMG Or   c                 j    t        j                  | |      }|r|t        j                  ||      }|S )z
    argmin with a `keepdims` parameter.

    See https://github.com/numpy/numpy/issues/8710

    If axis is not None, a.shape[axis] must be greater than 0.
    axis)rE   argminexpand_dims)rP   keepdimsr   r   s       r    _argminr  h  s1     ))AD
!CD$nnSt,Jr   c                 t    t        t        j                  |       |d      }t        j                  | ||      S )a  
    Return the first non-nan value along the given axis.

    If a slice is all nan, nan is returned for that slice.

    The shape of the return value corresponds to ``keepdims=True``.

    Examples
    --------
    >>> import numpy as np
    >>> nan = np.nan
    >>> a = np.array([[ 3.,  3., nan,  3.],
                      [ 1., nan,  2.,  4.],
                      [nan, nan,  9., -1.],
                      [nan,  5.,  4.,  3.],
                      [ 2.,  2.,  2.,  2.],
                      [nan, nan, nan, nan]])
    >>> _first_nonnan(a, axis=0)
    array([[3., 3., 2., 3.]])
    >>> _first_nonnan(a, axis=1)
    array([[ 3.],
           [ 1.],
           [ 9.],
           [ 5.],
           [ 2.],
           [nan]])
    Tr   r  r   )r  rE   isnantake_along_axis)rP   r   r   s      r    _first_nonnanr	  v  s/    8 	$6Aa..r   c                 F   |#| j                   dk(  ry| j                         } d}nD| j                  }||   dk(  r0|d| d|z  z   ||dz   d z   }t        j                  |dt
              S t        | |      }|| k(  t        j                  |       z  j                  ||      S )	a  
    Determine if the values along an axis are all the same.

    nan values are ignored.

    `a` must be a numpy array.

    `axis` is assumed to be normalized; that is, 0 <= axis < a.ndim.

    For an axis of length 0, the result is True.  That is, we adopt the
    convention that ``allsame([])`` is True. (There are no values in the
    input that are different.)

    `True` is returned for slices that are all nan--not because all the
    values are the same, but because this is equivalent to ``allsame([])``.

    Examples
    --------
    >>> from numpy import nan, array
    >>> a = array([[ 3.,  3., nan,  3.],
    ...            [ 1., nan,  2.,  4.],
    ...            [nan, nan,  9., -1.],
    ...            [nan,  5.,  4.,  3.],
    ...            [ 2.,  2.,  2.,  2.],
    ...            [nan, nan, nan, nan]])
    >>> _nan_allsame(a, axis=1, keepdims=True)
    array([[ True],
           [False],
           [False],
           [False],
           [ True],
           [ True]])
    Nr   Tr   r   r*   r   r  )	r   ravelr6   rE   r5   boolr	  r  rJ   )rP   r   r  shpa0s        r    _nan_allsamer    s    D |66Q;GGIggt9>et*tH},s4!89~=C7734t<<	qt	$B1W#((dX(FFr   )r<   c                   |t        |       }t        |       }|h d}||vrt        dt        |       d      |j	                  | j
                  d      xs |j	                  | j
                  d      }t        |       dk(  rd}n|r!|j                  |j                  |             }nt        |      rt        j                  | j
                  t              r_d}| j                         D ]I  }t        j                  t        |      t        j                        s1t        j                  |      sGd} n nd}|r|d	k(  rt        d
      |r|r|dk(  rd}t        |      ||fS )N>   omitraise	propagateznan_policy must be one of .zreal floatingzcomplex floatingr   FTr  zThe input contains nan valuesr  z9`nan_policy='omit' is incompatible with non-NumPy arrays.)r	   r
   r0   setisdtyper,   xp_sizer  maxrE   r   objectr  typenumber)	rP   
nan_policypoliciesr<   	not_numpyr   contains_nanelmessages	            r    _contains_nanr"    s:   	zQRL I1!5c(m_AFGGzz!''?3 :**QWW&89 qzQ	xxq	*	""--8'')B}}T"Xryy1bhhrl#	  
g-899\j&&8M!!##r   c                       fd}|S )a  
    Generate decorator for backward-compatible keyword renaming.

    Apply the decorator generated by `_rename_parameter` to functions with a
    recently renamed parameter to maintain backward-compatibility.

    After decoration, the function behaves as follows:
    If only the new parameter is passed into the function, behave as usual.
    If only the old parameter is passed into the function (as a keyword), raise
    a DeprecationWarning if `dep_version` is provided, and behave as usual
    otherwise.
    If both old and new parameters are passed into the function, raise a
    DeprecationWarning if `dep_version` is provided, and raise the appropriate
    TypeError (function got multiple values for argument).

    Parameters
    ----------
    old_name : str
        Old name of parameter
    new_name : str
        New name of parameter
    dep_version : str, optional
        Version of SciPy in which old parameter was deprecated in the format
        'X.Y.Z'. If supplied, the deprecation message will indicate that
        support for the old parameter will be removed in version 'X.Y+2.Z'

    Notes
    -----
    Untested with functions that accept *args. Probably won't work as written.

    c                 J     t        j                          fd       }|S )Nc            	      ^   |v rrjj                  d      }t        t        |d         dz         |d<   dj                  |      }d d d d| d	}t	        j
                  |t        d       |v rj                   d	 d
}t        |      |j                        |<    | i |S )Nr  r   rl   zUse of keyword argument `z!` is deprecated and replaced by `z`.  Support for `z` will be removed in SciPy )
stacklevelz2() got multiple values for argument now known as ``)
splitstrr   r   warningswarnDeprecationWarningr   r   pop)r=   r   end_versionr!  dep_versionfunnew_nameold_names       r    wrapperz5_rename_parameter.<locals>.decorator.<locals>.wrapper  s    6!"-"3"3C"8K%([^)<q)@%AKN"%((;"7K!:8* E>>FZ H//7j 9++6-q :G MM'+=!Lv%"%,, 099A
! EG#G,,#)::h#7x '''r   )r^   wraps)r0  r3  r/  r1  r2  s   ` r    	decoratorz$_rename_parameter.<locals>.decorator  s%    			( 
	(" r   r   )r2  r1  r/  r5  s   ``` r    _rename_parameterr6    s    @( r   c           	          | j                   }|j                  }|j                  |      D cg c]0  }t        j                  j                   t        |      |            2 }}|S c c}w r#   )_bit_generator	_seed_seqspawnrE   r{   r   r  )rng
n_childrenbgsschild_ss
child_rngss         r    
_rng_spawnrA  #  sd    			B	B"$((:"68"6h ))%%hd2hx&89"6  88s   5A%c                 .   | t        | n| } |D cg c]  }| j                  |       }}	 t        | d| j                        } | j                  g || }| j                  | j                  |      d   S c c}w # t
        $ r | j                  }Y <w xY w)Nfloat16r/   r   )r	   r2   getattrfloat32r4   r   r   nan)r<   rY   item	min_floatr,   s        r    _get_nanrI  ,  s    #%:$	2B)-.BJJtD.B	2::6	00i0 ::bffE:*2.. /  

s   A7+A< <BBc                 V    | | k  s| |k\  rd|  d| }t        |      | dk  r| |z   } | S )Nzaxis z) is out of bounds for array of dimension r   )r   )r   ndimr   s      r    normalize_axis_indexrL  9  sC    te|tt|dVDTFKnaxd{Kr   c                 H    | y	  | |       y# t         $ r
 d| _        Y yw xY w)aY  Call wrapped callback; return True if algorithm should stop.

    Parameters
    ----------
    callback : callable or None
        A user-provided callback wrapped with `_wrap_callback`
    res : OptimizeResult
        Information about the current iterate

    Returns
    -------
    halt : bool
        True if minimization should stop

    FT)StopIterationstop_iteration)callbackr   s     r    _call_callback_maybe_haltrQ  D  s6       "&s    !!c                   R    e Zd ZdZd Zej                  Zej                  Z	d Z
d Zy)_RichResultz5 Container for multiple outputs with pretty-printing c                 H    	 | |   S # t         $ r}t        |      |d }~ww xY wr#   )KeyErrorAttributeError)r   r   r   s      r    __getattr__z_RichResult.__getattr__`  s.    	.: 	. &A-	.s    	!!c                     g dt        | d      h dfdfdfd}| j                         rt        | |      S | j                  j                  dz   S )	N)r!  successstatusr0  funlr   xlcol_indnitloweruppereqlinineqlin	convergedflagfunction_calls
iterationsroot_order_keys>   conslackrh  crossover_nitc                     	 j                  | d   j                               S # t        $ r t        j                  cY S w xY wNr   )r   r_  r0   rE   rw   )rG  
order_keyss    r    keyz!_RichResult.__repr__.<locals>.keys  s;    !''Q88 vvs   !% A Ac              3   4   K   | D ]  }|d   v r|  y wrm  r   )itemsrG  	omit_keyss     r    omit_redundantz,_RichResult.__repr__.<locals>.omit_redundanty  s%     7i'
 s   c                 F    t         | j                                     S )N)ro  )sortedrq  )dro  rs  s    r    item_sorterz)_RichResult.__repr__.<locals>.item_sorter  s    .3==r   )sorterz())rD  keys_dict_formatter	__class__r   )r   rw  ro  rr  rs  rn  s     @@@@r    __repr__z_RichResult.__repr__i  s^    
 T=*=
 E				> 99;"4<<>>**T11r   c                 4    t        | j                               S r#   )listry  r   s    r    __dir__z_RichResult.__dir__  s    DIIK  r   N)r   r   r   r   rW  dict__setitem____setattr____delitem____delattr__r|  r  r   r   r    rS  rS  ^  s,    ?. ""K""K2<!r   rS  c                 V    | j                  d      }d|z  }d|z   j                  |      S )zQ
    Ensures that lines after the first are indented by the specified amount
    
 )r(  r   )srp   r(  indents       r    	_indenterr    s/     GGDMEUF6M&&r   c                     t        j                  |       ryt        j                  |       ryt        j                  |       ryt        j                  | ddd      S )zP
    Returns a string representation of a float with exactly ten characters
    z
       infz
      -infz
       nan   rl   F)	precisionpad_leftunique)rE   isposinfisneginfr  format_float_scientific)r   s    r    _float_formatter_10r    sE     
{{1~	Q	!%%a1qOOr   c                    t        | t              rt        t        t        t        | j                                           |z   }dj                   ||       D cg c];  \  }}|j                  |      dz   t        t        |||z   dz   d|      |dz         z   = c}}      }|S t        j                  d|z
  dddt        i      5  t        |       }d	d	d	       |S c c}}w # 1 sw Y   S xY w)
z
    Pretty printer for dictionaries

    `n` keeps track of the starting indentation;
    lines are indented by this much after a line break.
    `mplus` is additional left padding applied to keys
    r  z: rl   r   L      
float_kind)	linewidth	edgeitems	threshold	formatterN)r~   r  r  r   lenr~  ry  r   rjustr  rz  rE   printoptionsr  r)  )rv  rp   mplusrx  mr   vr  s           r    rz  rz    s     !TCaffh()E1II#)!9.#,41a wwqzD( AaCE1f!EqsKL#,. / H __r!tqB(46I'JLAAL H.L Hs   A C
C""C,)NN)r   )TFFFFr#   )NNint64F)l	   !E^1cuBn )FN)F)r  N)r   r   N)\r   
contextlibr   r^   r`   r*  r   collectionsr   r   ru   typingr   r   r   r   numpyrE   scipy._lib._array_apir	   r
   r   r  r  	Exception__annotations__WarninglibNumpyVersion__version__numpy.exceptionsr   r   r   r   r   catch_warningsfilterwarningsFutureWarninglongr   ulongr   rV  int_uintr   r   	IntNumberrt   floatingDecimalNumberr  r   rn   	__array__r{   r   r   SeedTyper   numpy.randomImportErrorrB   rU   rj   ro   rx   r   r   r   r   r   r   r   r   r   r   r  r	  r  r"  r6  rA  rI  rL  rQ  r  rS  r  r  rz  r   r   r    <module>r     sx   	 %     "     L L 	? W = (66r~~&(2 
  $	
66r~~&,6$X$$&#H##B
 ggGxxH ' ggGwwH#rzz/"	eR[["**45 66r~~&'1NVV(83N!T* i)<)< ii334 5 6HO59L9L9;9N9N:O 4P QM3DN%P !&S 4;s ;u ;"< (,BG"'5pR IJ
48n	% 	%G> G>T 8?=C@ ) )./@-G`#$$ #$L4n  
/4*!$ *!Z'
Pq '&  ggGwwH*     sN   K8 !-K+K8 ;%L L* +K50K8 8LLL'&L'*L<;L<