
    (ph=                        % S SK r S SKJr  S SKrS SKrS SKrS SKrS SKJr  S SK	r	S SK
r
S SKJrJr  S SKrS SKJrJrJr  S SKJrJr  \\   \S'   \\   \S'   \\   \S	'   \R6                  R9                  \R:                  5      S
:  a  S SKJrJ r J!r!J"r"  OS SKJrJ r J!r!  \#r"\\S'   \\S'   \R6                  R9                  \R:                  5      S:  aH   \RH                  " 5          \RJ                  " SS\&5        \RN                  r(\RR                  r*SSS5        O\RX                  r(\RZ                  r*\.\R^                  -  r0\1\Rd                  -  \R^                  -  r3\4S-  \S'   \R6                  R9                  \R:                  5      S:  a  Sr5OO\R6                  R9                  \R:                  5      S:  a  Sr5O# \Rl                  " S/5      Ro                  SS9  Sr5\Rp                  Rr                  \Rp                  Rt                  -  r;\\S'   \0\;-  S-  r<\\S'   \" S\;S9r= S SK>J9r9  SHS jr@SIS  jrA\1S!S4S" jrBS# rCS$\.S%\14S& jrDS'rESSS(S).S* jrFS+ rG   SJS, jrHSKS- jrI\" S./ S/Q5      rJS0 rK " S1 S25      rL " S3 S45      rM  SLS5 jrN\SMS6 j5       rOS7 rPSNS8 jrQS9 rRSOS: jrSSPSSS;.S< jjrTSKS= jrUS> rVSS?.S@ jrWSA rXSB rY " SC SD\Z5      r[SISE jr\SF r]SQSG jr^g! , (       d  f       GN= f! \+ a    \RX                  r(\RZ                  r* GNf = f! \# a    Sr5 GNCf = f! \? a     " S S5      r9 GNf = f)R    N)contextmanager)
namedtuple)	TypeAliasTypeVar)array_namespaceis_numpyxp_size)FunctionDoc	Parameter	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_RNGSeedTypeGeneratorType)bound)	Generatorc                       \ rS rSrSrg)r   P    N)__name__
__module____qualname____firstlineno____static_attributes__r       C/var/www/html/venv/lib/python3.13/site-packages/scipy/_lib/_util.pyr   r   P   s    r$   r   c           	        ^ ^ [        T /UQ76 nXCs=L a  b  O  Ub  Ub  [        S5      eUR                  " T /UQ76 nUR                  S/5      R                  nUR                  US   USS9USS sm nUR                  U" U 4S jU 5       6 5      nUc  [        U5      [        [        [        [        1;   a,  [        R                  " S	S
9   X-  R                  n	SSS5        OUR                  UR                  U5      n	UR                  T R                  W	UR                  X9S9S9n
OPT ) mUR                  U" U4S jU 5       6 5      nUR                  X5      n	UR!                  T R                  U	S9n
XT'   XT '   U
$ ! , (       d  f       N= f)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   ,   >#    U  H	  oT   v   M     g 7fNr   .0arrconds     r%   	<genexpr>_lazywhere.<locals>.<genexpr>   s     7t9   r   )invaliddtype)r2   
fill_valuec              3   ,   >#    U  H	  oT   v   M     g 7fr(   r   )r*   r+   nconds     r%   r-   r.      s     =fsE
fr/   )r   
ValueErrorbroadcast_arraysasarrayr2   astypetypeboolintfloatcomplexnperrstateresult_typefullshapeempty)r,   arraysf	fillvaluef2xpargs
bool_dtypetemp1r2   outtemp2r5   s   `           @r%   
_lazywhererO   T   s{   X 
	'	'B
R^	8MLMMt-f-DTF#))J99T!Wju9=tABxLD&JJq7789E	z
 	?tS%99X.*11 /. >>%++y95ggdjj!#I!C  E 

2=f=>?u,hhtzzh/E
IJ /.s   E>>
Fc                   ^
 [         R                  " U6 n[         R                  " U Vs/ s H  oDR                  R                  PM     sn5      n[         R
                  " [         R                  " US   5      X5S9n[        X5       Hr  u  nm
[         R                  " T
SL 5      (       a  M%  [         R                  " T
US   5      u  m
n[        U
4S jU 5       5      n	[         R                  " UT
U" U	6 5        Mt     U$ s  snf )a
  
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   r3   r2   Fc              3   R   >#    U  H  n[         R                  " TU5      v   M     g 7fr(   )r?   extractr)   s     r%   r-   _lazyselect.<locals>.<genexpr>   s     =fsRZZc**fs   $')r?   r7   mintypecoder2   charrB   rC   zipalltupleplace)condlist
choicelistrE   defaultatcoderM   func_tempr,   s             @r%   _lazyselectrc      s    8   &)FNN&9&QGGLL&9:E
''"((6!9%'
GC*/
d66$%-  %%dF1I6a=f==
dD$K( 0 J :s   C>Cc                    [         R                  " U5      nUc  UR                  n[        U S5      (       d  U 4n [        R
                  " [        R                  U 5      UR                  -  n[         R                  " XC-   S-   [         R                  5      nUR                  S   S   U-  nUS:w  a  X6-
  nXVXd-   S-    SS n[         R                  " XXRS9nUR                  S5        U$ )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)r?   r2   	alignmenthasattr	functoolsreduceoperatormulitemsizerD   uint8__array_interface__ndarrayfill)rC   r2   ri   alignsizebufoffsetrg   s           r%   _aligned_zerosry      s     HHUOE}5)$$HLL%05>>AD
((4<!#RXX
.C$$V,Q/%7F{ V[]
#CR
(C::eC5DIIaLKr$   c                     U R                   b7  U R                  U R                   R                  S-  :  a  U R                  5       $ U $ )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.
   )baserv   r   )arrays    r%   _prune_arrayr~      s7    
 zz%**uzz!/C"Czz|Lr$   nreturnc                 l    U S:  a  [        [        R                  " U 5      5      $ [        R                  $ )zdCompute the factorial and return as a float

Returns infinity when result is too large for a double
   )r=   math	factorialr?   inf)r   s    r%   float_factorialr      s'    
 ()3w5"#:BFF:r$   a^  If `rng` is passed by keyword, types other than `numpy.random.Generator` are
    passed to `numpy.random.default_rng` to instantiate a ``Generator``.
    If `rng` is already a ``Generator`` instance, then the provided instance is
    used. Specify `rng` for repeatable function behavior.

    If this argument is passed by position or `{old_name}` is passed by keyword,
    legacy behavior for the argument `{old_name}` applies:

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

    .. versionchanged:: 1.15.0
        As part of the `SPEC-007 <https://scientific-python.org/specs/spec-0007/>`_
        transition from use of `numpy.random.RandomState` to
        `numpy.random.Generator`, this keyword was changed from `{old_name}` to `rng`.
        For an interim period, both keywords will continue to work, although only one
        may be specified at a time. After the interim period, function calls using the
        `{old_name}` keyword will emit warnings. The behavior of both `{old_name}` and
        `rng` are outlined above, but only the `rng` keyword should be used in new code.
        T)position_numend_versionreplace_docc          	      J   ^ ^^^^^ SmST ST ST ST  S3	mUUUU UU4S jnU$ )a  Example decorator to transition from old PRNG usage to new `rng` behavior

Suppose the decorator is applied to a function that used to accept parameter
`old_name='random_state'` either by keyword or as a positional argument at
`position_num=1`. At the time of application, the name of the argument in the
function signature is manually changed to the new name, `rng`. If positional
use was allowed before, this is not changed.*

- If the function is called with both `random_state` and `rng`, the decorator
  raises an error.
- If `random_state` is provided as a keyword argument, the decorator passes
  `random_state` to the function's `rng` argument as a keyword. If `end_version`
  is specified, the decorator will emit a `DeprecationWarning` about the
  deprecation of keyword `random_state`.
- If `random_state` is provided as a positional argument, the decorator passes
  `random_state` to the function's `rng` argument by position. If `end_version`
  is specified, the decorator will emit a `FutureWarning` about the changing
  interpretation of the argument.
- If `rng` is provided as a keyword argument, the decorator validates `rng` using
  `numpy.random.default_rng` before passing it to the function.
- If `end_version` is specified and neither `random_state` nor `rng` is provided
  by the user, the decorator checks whether `np.random.seed` has been used to set
  the global seed. If so, it emits a `FutureWarning`, noting that usage of
  `numpy.random.seed` will eventually have no effect. Either way, the decorator
  calls the function without explicitly passing the `rng` argument.

If `end_version` is specified, a user must pass `rng` as a keyword to avoid
warnings.

After the deprecation period, the decorator can be removed, and the function
can simply validate the `rng` argument by calling `np.random.default_rng(rng)`.

* A `FutureWarning` is emitted when the PRNG argument is used by
  position. It indicates that the "Hinsen principle" (same
  code yielding different results in two versions of the software)
  will be violated, unless positional use is deprecated. Specifically:

  - If `None` is passed by position and `np.random.seed` has been used,
    the function will change from being seeded to being unseeded.
  - If an integer is passed by position, the random stream will change.
  - If `np.random` or an instance of `RandomState` is passed by position,
    an error will be raised.

  We suggest that projects consider deprecating positional use of
  `random_state`/`rng` (i.e., change their function signatures to
  ``def my_func(..., *, rng=None)``); that might not make sense
  for all projects, so this SPEC does not make that
  recommendation, neither does this decorator enforce it.

Parameters
----------
old_name : str
    The old name of the PRNG argument (e.g. `seed` or `random_state`).
position_num : int, optional
    The (0-indexed) position of the old PRNG argument (if accepted by position).
    Maintainers are welcome to eliminate this argument and use, for example,
    `inspect`, if preferred.
end_version : str, optional
    The full version number of the library when the behavior described in
    `DeprecationWarning`s and `FutureWarning`s will take effect. If left
    unspecified, no warnings will be emitted by the decorator.
replace_doc : bool, default: True
    Whether the decorator should replace the documentation for parameter `rng` with
    `_rng_desc` (defined above), which documents both new `rng` keyword behavior
    and typical legacy `random_state`/`seed` behavior. If True, manually replace
    the first paragraph of the function's old `random_state`/`seed` documentation
    with the desired *final* `rng` documentation; this way, no changes to
    documentation are needed when the decorator is removed. Documentation of `rng`
    after the first blank line is preserved. Use False if the function's old
    `random_state`/`seed` behavior does not match that described by `_rng_desc`.

rngz@To silence this warning and ensure consistent behavior in SciPy z", control the RNG using argument `z `. Arguments passed to keyword `z` will be validated by `np.random.default_rng`, so the behavior corresponding with a given value may change compared to use of `a+  `. For example, 1) `None` will result in unpredictable random numbers, 2) an integer will result in a different stream of random numbers, (with the same distribution), and 3) `np.random` or `RandomState` instances will result in an error. See the documentation of `default_rng` for more information.c                 "  >^  [         R                  " T 5      UUUU UU4S j5       nT(       a  [        U5      nUS    Vs/ s H  o3R                  PM     nnSU;   a  Sn[        R                  ST5      nUS   UR                  S5         R                  nSU;   a  XwR                  S5      S-   S  O/ nU/U-   n	[        SXY5      n
XS   UR                  S5      '   [        U5      R                  SS5      S   n[        U5      Ul        U$ s  snf )	Nc            	        > TU;   nT
U;   nTS L=(       a    [        U 5      TS-   :  nTS Ln[        U5      [        U5      -   [        U5      -   S:  a#  TR                   ST
 ST
 ST S3n[        U5      e[        R
                  R                  R                  R                  R                  S L nU(       aI  UR                  T5      UT
'   U(       a,  ST ST
 ST S	T S
3	T-   n[        R                  " U[        SS9  GOU(       a  U T   n[        R
                  R                  [        R
                  R                  [        R
                  R                   4n	Uc  U(       a  [#        X5      (       a  OU(       a)  ST
 ST ST S3T-   n[        R                  " U[$        SS9  O^U(       a&  [        R
                  R'                  UT
   5      UT
'   O1U(       a*  U(       a#  ST S3T-   n[        R                  " U[$        SS9  T" U 0 UD6$ )Nr   2() got multiple values for argument now known as `z`. Specify one of `z` or `z`.Use of keyword argument `!` is deprecated and replaced by ``.  Support for `` will be removed in SciPy z. r{   
stacklevelzPositional use of `z` (formerly known as `z`) is still allowed, but the behavior is changing: the argument will be normalized using `np.random.default_rng` beginning in SciPy zH, and the resulting `Generator` will be used to generate random numbers.zJThe NumPy global RNG was seeded by calling `np.random.seed`. Beginning in z2, this function will no longer use the global RNG.)lenr<   r   	TypeErrorr?   randommtrand_rand_bit_generator	_seed_seqpopwarningswarnDeprecationWarningr   SeedSequenceBitGenerator
isinstanceFutureWarningdefault_rng)rJ   kwargsas_old_kwargas_new_kwarg
as_pos_argemit_warningmessageglobal_seed_setarg
ok_classesNEW_NAMEcmn_msgr   funold_namer   s             r%   wrapper6_transition_to_rng.<locals>.decorator.<locals>.wrappern  s9    $v-L#v-L%T1Sc$i<RSCS6SJ&d2L < 3|#44s:FJ||n %..6Z 8 zz5 
  (( !ii..44CCMMQUUO#)::h#7x 3H: >77?j A((0z 2$$/=4   G MM'+=!L <(
 II''II**II**

 KJs<W<W!-hZ 8$: &FFQ] S**   G MM'=QG $&99#8#89I#Jx  \66A] CBB 	
 g}C'''r$   
Parametersr   z/{None, int, `numpy.random.Generator`}, optionalz
{old_name} r   
)rl   wrapsr
   name	_rng_descreplaceindexdescr   strsplit__doc__)r   r   docparamparameter_names_type_descold_docold_doc_keepnew_doc_rng_parameter_docr   r   r   r   r   r   s   `          r%   	decorator%_transition_to_rng.<locals>.decoratorm  s   		I	( I	( 
I	(V g&C7:<7HI7Hezz7HOI'I!)),Al+O,A,A%,HINNBD-w}}R'81'<'=>UW 'L0%.ue%E"BTL!/"7"7">?#hnnT1-a0"%c( Js    Dr   )r   r   r   r   r   r   r   s   ```` @@r%   _transition_to_rngr     sX    T H 	K-9( Dj !: G			G Z Zx r$   c                    U b  U [         R                  L a$  [         R                  R                  R                  $ [	        U [
        R                  [         R                  -  5      (       a  [         R                  R                  U 5      $ [	        U [         R                  R                  [         R                  R                  -  5      (       a  U $ [        SU  S35      e)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)r?   r   r   r   r   numbersIntegralintegerRandomStater   r6   )seeds    r%   check_random_stater     s    & |tryy(yy%%%$((2::566yy$$T**$		--		0C0CCDD
q ! ! " "r$   c                 J   U(       d1  SSK nUR                  R                  U 5      (       a  Sn[        U5      eU(       d/  [        R
                  R                  U 5      (       a  [        S5      eU(       a  [        R                  O[        R                  nU" U 5      n U(       d.  U R                  [        R                  " S5      L a  [        S5      eU(       aI  [        R                  " U R                  [        R                  5      (       d  U" U [        R                  S9n U $ )a  
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   NzSparse arrays/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 supportedr1   )scipy.sparsesparseissparser6   r?   maisMaskedArrayasarray_chkfiniter8   r2   
issubdtypeinexactfloat64)	r^   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1,AHr$   c                      [         R                  " U 5      n Ub  X:  a  [        U SU 35      SeU $ ! [         a    [        U S35      Sef = f)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 )rn   r   r   r6   )kr   minimums      r%   _validate_intr   #  sr    $ANN1 q{D6 "!!(	+ ,15	6H  A4& 456D@As	   3 AFullArgSpec)rJ   varargsvarkwdefaults
kwonlyargskwonlydefaultsannotationsc           	         [         R                  " U 5      nUR                  R                  5        Vs/ s HS  nUR                  [         R
                  R                  [         R
                  R                  4;   d  MG  UR                  PMU     nnUR                  R                  5        Vs/ s H9  nUR                  [         R
                  R                  :X  d  M-  UR                  PM;     nnU(       a  US   OSnUR                  R                  5        Vs/ s H9  nUR                  [         R
                  R                  :X  d  M-  UR                  PM;     nnU(       a  US   OSn[        S UR                  R                  5        5       5      =(       d    SnUR                  R                  5        Vs/ s H9  nUR                  [         R
                  R                  :X  d  M-  UR                  PM;     nnUR                  R                  5        Vs0 s H_  nUR                  [         R
                  R                  :X  d  M-  UR                  UR                  Ld  MH  UR                  UR                  _Ma     nnUR                  R                  5        Vs0 s H5  nUR                  UR                  Ld  M  UR                  UR                  _M7     n	n[!        X4XVUU=(       d    SU	5      $ s  snf s  snf s  snf s  snf s  snf s  snf )a;  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      #    U  HV  nUR                   [        R                  R                  :X  d  M-  UR                  UR
                  Ld  MH  UR                  v   MX     g 7fr(   )kindinspectr   POSITIONAL_OR_KEYWORDr]   rD   )r*   ps     r%   r-   )getfullargspec_no_self.<locals>.<genexpr>v  sJ      2aFFg''=== 	IIQWW$ 			2s   ,A A A )r   	signature
parametersvaluesr   r   r   POSITIONAL_ONLYr   VAR_POSITIONALVAR_KEYWORDrY   KEYWORD_ONLYr]   rD   
annotationr   )
r`   sigr   rJ   r   r   r   r   
kwdefaultsr   s
             r%   getfullargspec_no_selfr  Q  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 (1661<<'1HK 3tez!)T;8 8;

,3sN   AK.=K.+,K3K3,K8K86,K=&K=,LLLL9Lc                   $    \ rS rSrSrS rS rSrg)_FunctionWrapperi  z7
Object to wrap user's function, allowing picklability
c                 4    Xl         Uc  / U l        g UU l        g r(   rF   rJ   )selfrF   rJ   s      r%   __init___FunctionWrapper.__init__  s    ,B	D	r$   c                 <    U R                   " U/U R                  Q76 $ r(   r  )r	  xs     r%   __call___FunctionWrapper.__call__  s    vva$$))$$r$   )rJ   rF   N)r   r    r!   r"   r   r
  r  r#   r   r$   r%   r  r    s    1%r$   r  c                   F    \ rS rSrSrSS jrS rS rS rS r	S r
S	 rS
rg)
MapWrapperi  aB  
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                    S U l         [        U l        SU l        [	        U5      (       a  Xl         U R                   U l        g SSKJn  [        U5      S:X  a/  U" 5       U l         U R                   R                  U l        SU l        g [        U5      S:X  a  g [        U5      S:  a7  U" [        U5      S9U l         U R                   R                  U l        SU l        g [        S5      e)	NFr   )Poolrh   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  r<   RuntimeError)r	  r  r  s      r%   r
  MapWrapper.__init__  s    	D>>I IIDM,4yB F	 $		!%TaTQ 3t95	 $		!%" $, - -r$   c                     U $ r(   r   r	  s    r%   	__enter__MapWrapper.__enter__  s    r$   c                 \    U R                   (       a  U R                  R                  5         g g r(   )r  r  	terminater  s    r%   r"  MapWrapper.terminate  s    >>II! r$   c                 \    U R                   (       a  U R                  R                  5         g g r(   )r  r  joinr  s    r%   r%  MapWrapper.join  s    >>IINN r$   c                 \    U R                   (       a  U R                  R                  5         g g r(   )r  r  closer  s    r%   r(  MapWrapper.close  s    >>IIOO r$   c                     U R                   (       a5  U R                  R                  5         U R                  R                  5         g g r(   )r  r  r(  r"  )r	  exc_type	exc_value	tracebacks       r%   __exit__MapWrapper.__exit__  s,    >>IIOOII! r$   c                 b     U R                  X5      $ ! [         a  n[        S5      UeS nAff = f)Nz;The map-like callable must be of the form f(func, iterable))r  r   )r	  r`   iterablees       r%   r  MapWrapper.__call__  s;    	>==00 	> 6 7<=>	>s    
.).)r  r  r  Nr   )r   r    r!   r"   r   r
  r  r"  r%  r(  r.  r  r#   r   r$   r%   r  r    s*    -8""
>r$   r  c                 "   [        U [        5      (       a  U R                  XX4US9$ U c$  [        R                  R
                  R                  n U(       a,  Uc  U R                  US-   X4S9$ Ub  U R                  XS-   X4S9$ U R                  XX4S9$ )a  
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.
)highrv   r2   endpointr   )rv   r2   )r6  rv   r2   )r   r   integersr?   r   r   r   randint)genlowr6  rv   r2   r7  s         r%   rng_integersr<    s    X #y!!||C%-  / 	/ ;))""((C |{{37{CC{{3AXD{NN {{3{BBr$   c              #      ^#    [         R                  R                  mU 4U4S jj[         R                  l         Sv   T[         R                  l        g! T[         R                  l        f = f7f)z0Context with a fixed np.random.default_rng seed.c                    > T" U 5      $ r(   r   r   orig_funs    r%   <lambda>$_fixed_default_rng.<locals>.<lambda>"  s	    htnr$   N)r?   r   r   r?  s    @r%   _fixed_default_rngrC    sF      yy$$H(,<BII) (				s   7A/A A/A,,A/c                 b   ^ ^ [         R                  " S[         R                  5      mU U4S jnU$ )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                  r   > T" U 0 UD6nU Vs/ s H  n[         R                  " TSU5      PM     nnU$ s  snf )Nznp.random.default_rng())resub)rJ   r   reslinelinesr`   patterns        r%   _wrapped#_rng_html_rewrite.<locals>._wrapped5  sN    D#F# 
 FF75t< 	 
 	
s   "4)rF  compileI)r`   rL  rK  s   ` @r%   _rng_html_rewriterP  )  s&     jjFMG Or$   c                 j    [         R                  " XS9nU(       a  Ub  [         R                  " X2S9nU$ )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)r?   argminexpand_dims)r^   keepdimsrS  rH  s       r%   _argminrW  @  s-     ))A
!CD$nnS,Jr$   c                 j    [        [        R                  " U 5      USS9n[        R                  " XUS9$ )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rS  rV  rR  )rW  r?   isnantake_along_axis)r^   rS  r   s      r%   _first_nonnanr\  N  s-    8 	$6Aa..r$   c                 4   Uc$  U R                   S:X  a  gU R                  5       n SnOAU R                  nX1   S:X  a-  USU SU-  -   X1S-   S -   n[        R                  " US[
        S9$ [        XS9nX@:H  [        R                  " U 5      -  R                  XS9$ )	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   Tr4  r   rQ   rR  rY  )	rv   ravelrC   r?   rB   r;   r\  rZ  rX   )r^   rS  rV  shpa0s        r%   _nan_allsamera  n  s    D |66Q;GGIgg9>et*tH},s!89~=C7734t<<	q	$BW#((d(FFr$   )xp_omit_okayrI   c                   Uc  [        U 5      n[        U5      (       + nUc  1 SknX;  a  [        S[        U5       S35      e[	        U 5      S:X  a  SnGOnUR                  U R                  S5      (       a"  UR                  UR                  U 5      5      nGO+UR                  U R                  S5      (       a`  UR                  UR                  UR                  U 5      5      5      UR                  UR                  UR                  U 5      5      5      -  nO[        U5      (       a  [        R                  " U R                  [        5      (       an  SnU R                  5        HW  n[        R                  " [        U5      [        R                   5      (       d  M8  [        R                  " U5      (       d  MU  Sn  O   OSnU(       a  US	:X  a  [        S
5      eU(       d!  U(       a  U(       a  US:X  a  Sn[        U5      eXa4$ )N>   omitraise	propagateznan_policy must be one of .r   Fzreal floatingzcomplex floatingTre  zThe input contains nan valuesrd  z9`nan_policy='omit' is incompatible with non-NumPy arrays.)r   r   r6   setr	   isdtyper2   rZ  maxrealimagr?   r   objectr^  r:   number)	r^   
nan_policypoliciesrb  rI   	not_numpycontains_nanelr   s	            r%   _contains_nanrt    s    
zQRL I1!5c(m_AFGGqzQ	AGG_	-	- xxq	*	AGG/	0	0 xxrwwqz 23bhhrvvbggaj?Q6RR	""--88'')B}}T"Xryy11bhhrll#	  
g-899I,:v;MM!!##r$   c                    ^ ^^ UUU 4S jnU$ )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                 N   >^  [         R                  " T 5      UU UU4S j5       nU$ )Nc            	      l  > TU;   a  T(       ah  TR                  S5      n[        [        US   5      S-   5      US'   SR                  U5      nST ST ST SU S3	n[        R
                  " U[        SS9  TU;   a  TR                   S	T S
3n[        U5      eUR                  T5      UT'   T" U 0 UD6$ )Nrg  r   r{   r   r   r   r   r   r   `)
r   r   r<   r%  r   r   r   r   r   r   )rJ   r   r   r   dep_versionr   new_namer   s       r%   r   5_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$   )rl   r   )r   r   ry  rz  r   s   ` r%   r   $_rename_parameter.<locals>.decorator  s%    			( 
	(" r$   r   )r   rz  ry  r   s   ``` r%   _rename_parameterr}    s    @( r$   c                     U R                   nUR                  nUR                  U5       Vs/ s H1  n[        R                  R                  [        U5      " U5      5      PM3     nnU$ s  snf r(   )r   r   spawnr?   r   r   r:   )r   
n_childrenbgsschild_ss
child_rngss         r%   
_rng_spawnr    sb    			B	B"$((:"68"6h ))%%d2hx&89"6  88s   8A()rI   c                 0   U c  [        U6 OU n U Vs/ s H  o R                  U5      PM     nn [        U SU R                  5      nU R                  " / UQUP76 nU R                  U R                  US9S   $ s  snf ! [
         a    U R                  n N:f = f)Nfloat16r1   r   )r   r8   getattrfloat32rA   r   r   nan)rI   rg   item	min_floatr2   s        r%   _get_nanr    s    #%:$	2B)-.JJtD.B	2::6	00i0 ::bffE:*2.. /  

s   A7+A< <BBc                 V    X* :  d  X:  a  SU  SU 3n[        U5      eU S:  a  X-   n U $ )Nzaxis z) is out of bounds for array of dimension r   )r   )rS  ndimr   s      r%   normalize_axis_indexr    s=    e|t|dVDTFKnax{Kr$   c                 L    U c  g U " U5        g! [          a
    SU l         gf = f)a-  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)callbackrH  s     r%   _call_callback_maybe_haltr  %  s6       "&s    ##c                   Z    \ rS rSrSrS r\R                  r\R                  r
S rS rSrg)_RichResulti?  z4Container for multiple outputs with pretty-printing c                 H     X   $ ! [          a  n[        U5      UeS nAff = fr(   )KeyErrorAttributeError)r	  r   r2  s      r%   __getattr___RichResult.__getattr__A  s,    	.: 	. &A-	.s    
!!c                    ^^^^ / SQm[        U ST5      m1 SkmU4S jmU4S jmUU4S jnU R                  5       (       a	  [        XS9$ U R                  R                  S-   $ )	N)r   successstatusr   funlr  xlcol_indnitloweruppereqlinineqlin	convergedflagfunction_calls
iterationsroot_order_keys>   conslackr  crossover_nitc                    >  TR                  U S   R                  5       5      $ ! [         a    [        R                  s $ f = fNr   )r   r  r6   r?   r   )r  
order_keyss    r%   key!_RichResult.__repr__.<locals>.keyT  s;    !''Q88 vvs   !% AAc              3   >   >#    U  H  nUS   T;   a  M  Uv   M     g 7fr  r   )itemsr  	omit_keyss     r%   omit_redundant,_RichResult.__repr__.<locals>.omit_redundantZ  s$     7i'
 s   c                 @   > [        T" U R                  5       5      TS9$ )N)r  )sortedr  )dr  r  s    r%   item_sorter)_RichResult.__repr__.<locals>.item_sorter`  s    .3==r$   )sorterz())r  keys_dict_formatter	__class__r   )r	  r  r  r  r  r  s     @@@@r%   __repr___RichResult.__repr__J  s^    
 T=*=
 E				> 99;;"4<<>>**T11r$   c                 4    [        U R                  5       5      $ r(   )listr  r  s    r%   __dir___RichResult.__dir__h  s    DIIK  r$   r   N)r   r    r!   r"   r   r  dict__setitem____setattr____delitem____delattr__r  r  r#   r   r$   r%   r  r  ?  s,    ?. ""K""K2<!r$   r  c                 V    U R                  S5      nSU-  nSU-   R                  U5      $ )zI
Ensures that lines after the first are indented by the specified amount
r    )r   r%  )sr   r   indents       r%   	_indenterr  l  s/     GGDMEUF6M&&r$   c                     [         R                  " U 5      (       a  g[         R                  " U 5      (       a  g[         R                  " U 5      (       a  g[         R                  " U SSSS9$ )zH
Returns a string representation of a float with exactly ten characters
z
       infz
      -infz
       nan   r{   F)	precisionpad_leftunique)r?   isposinfisneginfrZ  format_float_scientific)r  s    r%   _float_formatter_10r  u  sK     
{{1~~	Q	!%%a1qOOr$   c                    [        U [        5      (       a  [        [        [        [        U R                  5       5      5      5      U-   nSR                  U" U 5       VVs/ s H:  u  pVUR                  U5      S-   [        [        XdU-   S-   SU5      US-   5      -   PM<     snn5      nU$ [        R                  " SU-
  SSS[        0S9   [        U 5      nS	S	S	5        U$ s  snnf ! , (       d  f       W$ = f)
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: r{   r   L      
float_kind)	linewidth	edgeitems	threshold	formatterN)r   r  rj  r  r   r  r  r%  rjustr  r  r?   printoptionsr  r   )r  r   mplusr  mr   vr  s           r%   r  r    s     !TCaffh()E1II#)!9.#,41 wwqzD( aCE1f!EqsKL#,. / H __r!tqB(46I'JLAAL H.L L Hs   AC 

C&&
C5)NN)r   )TFFFFr(   )NNint64F)l	   !E^1cuBn )FN)F)rf  N)r   r   N)_rF  
contextlibr   rl   rn   r   r   collectionsr   r   r   typingr   r   numpyr?   scipy._lib._array_apir   r   r	   scipy._lib._docscraper
   r   r:   	Exception__annotations__WarninglibNumpyVersion__version__numpy.exceptionsr   r   r   r   r   catch_warningsfilterwarningsr   longr   ulongr   r  int_uintr<   r   	IntNumberr=   floatingDecimalNumberr;   r   r}   	__array__r   r   r   r   r   r   numpy.randomImportErrorrO   rc   ry   r~   r   r   r   r   r   r   r   r  r  r  r<  rC  rP  rW  r\  ra  rt  r}  r  r  r  r  r  r  r  r  r  r   r$   r%   <module>r     sa   	 %     "   %  D D 8 	? W = (66r~~&(2 
  $	
66r~~&,6$$&##B
 ggGxxH '& ggGwwH"**	#bjj0t 66r~~&'1NVV(83N
!T*
 ))%%		(=(==i =$&-) -t43L^%P !&S 4;s ;u ; 
: 264#'ur"< (,BG"'5pR IJ
48n	% 	%G> G>T 8?=C@ ) )./@-G`,$$,$^4n  
/4*!$ *!Z'
P{" '&  ggGwwH*     sT   K6 '-K$K6 "L *L* $
K3.K6 3K6 6LLL'&L'*L>=L>