L i 2UddlZddlmZddlZddlZddlZddlZddlmZddl Z ddl Z ddl m Z ddl mZmZmZddlZddlmZmZmZmZmZmZmZmZddlmZmZddlm Z dd l!m"Z"e#e$d <e#e$d <ejJjMejNd k\rH ejP5ejRd de*ejVZ,ejZZ.dddnej`Z,ejbZ.e2ejfzZ4e5ejlzejfzZ7e8dze$d<ejJjMejNdk\rdZ9nQejJjMejNdkrdZ9n& ejtdgjwddZ9ejzj|ejzj~zZ@ee$d<e4e@zdzZAee$d<ede@ZB ddlCm>Z>dRdZEe5ddfdZFdZGd e2d!e5fd"ZHd#ZIddd$d%d&ZJd'ZK dSd(ZLdTd)ZMed*gd+ZNd,ZOGd-d.ZPGd/d0ZQGd1d2ZRd3ZS dUd4ZTedVd5ZUd6ZVdWd7ZWd8ZXdXd9ZY dYddd:d;ede8d?e dzd!ee8zf d@ZZdTdAZ[dBZ\dCddDdEZ]dFZ^dGZ_GdHdIe`ZadRdJZbdKZcdZdLZddMZedNZfdOdPdQZgy#1swYxYw#e/$rej`Z,ejbZ.YwxYw#e<$rdZ9YXwxYw#eD$rGddZ>YwxYw)[N)contextmanager) namedtuple) ModuleType)Literal TypeAliasTypeVar)Arrayarray_namespace is_lazy_arrayis_numpy is_marrayxp_result_devicexp_sizexp_result_type) FunctionDoc Parameter)issparse AxisErrornp_longnp_ulongz 2.0.0.dev0ignorez/.*In the future `np\.long` will be defined as.*copy_if_neededz2.0.0z1.28.0F)copy_RNGSeedType GeneratorType)bound) Generatorc eZdZy)r N)__name__ __module__ __qualname__V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/_lib/_util.pyr r Gs r&r c tj|}tj|Dcgc]}|jjc}}tj tj |d||}t||D]g\} tj durtj |d\ }t fd|D} tj| || i|Scc}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 fill_valuedtypeFc3JK|]}tj|ywN)npextract).0arrconds r' z_lazyselect..ns=sRZZc*=s #) r.broadcast_arrays mintypecoder+charfullshapezipalltupleplace) condlist choicelistarraysdefaultatcodeoutfunc_tempr2s @r' _lazyselectrGKs8 & )F NN&9QAGGLL9 :E ''"((6!9%' GC*h/) d 66$%- %%dF1I6a=f== dD$K( ) J:sC1Cctj|}| |j}t|ds|f}t j t j||jz}tj||zdztj}|jdd|z}|dk7r||z }||||zdzdd}tj||||}|jd|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__rdatar)order)r.r+ alignmenthasattr functoolsreduceoperatormulitemsizeemptyuint8__array_interface__ndarrayfill)r8r+rMalignsizebufoffsetrKs r'_aligned_zerosr^ss HHUOE } 5) $   HLL% 05>> AD ((4%`_ 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 Hdddddd fd}|S)ayExample 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.ctj fd}tj}|j g|j j tjtjjd|_ rt|}|dDcgc]}|j}}d|vrd}tj d}|d|jdj}d|vr||jdd zdng} |g| z} td|| } | |d|jd<t|j!d d d }t||_|Scc}w) Nc |v} |v}duxrt|dzk\} du}t|t|zt|zdkDr# jd d dd}t|tj j jjjdu}|rF|j| <|rdd dd d z}tj|td n|r|}tj jtj jtj j f} ||r t#|| rn|r}d dd d z}tj|t$d nQ|r&tj j'| | <n)|r'|r%d d z}tj|t$d  |i|S)Nr2() got multiple values for argument now known as `z`. Specify one of `z` or ``.Use of keyword argument `!` is deprecated and replaced by ``. Support for `` will be removed in SciPy z. r` stacklevelzPositional 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.)lenintr" TypeErrorr.randommtrand_rand_bit_generator _seed_seqpopwarningswarnDeprecationWarningr SeedSequence BitGenerator isinstance FutureWarning default_rng)argskwargs as_old_kwarg as_new_kwarg as_pos_arg emit_warningmessageglobal_seed_setarg ok_classesNEW_NAMEcmn_msgrnfunold_namerms r'wrapperz6_transition_to_rng..decorator..wrappers6$v-L#v-L%T1Sc$i77?jA((0z2$$/=4  G MM'+=!L<( II''II**II** KJsJ.decorators  I (I ( I (X$--c2 1 9 9F  ) ) 0 0 2F   h(9(9(F(FPT UF 9!  g&C7:<7HIeuzzIOI'I!)),Al+O,A,A%,HINNBD-ww}}R'81'<'=>UW  'L0%.ueW%E"BTL!/"7"7">?#hnnT1-a0"%c(Js/E8r%)rrmrnrorrrs```` @@r'_transition_to_rngrsXTH K -9(Dj! :G G aaF r&c||tjur$tjjjSt |t j tjzrtjj|St |tjjtjjzr|Std|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) r.rrrrnumbersIntegralinteger RandomStater ValueError)seeds r'check_random_stater|s& |tryy(yy%%%$((2::56yy$$T**$ -- 0C0CCD q!! ""r&c|st|r d}t||s*tjj |r td|rtj ntj }||}|s,|jtjdur td|rFtj|jtjs||tj}|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. zSparse arrays/matrices are not supported by this function. Perhaps one of the `scipy.sparse.linalg` functions would work instead.zmasked arrays are not supportedOzobject arrays are not supported)r+) rrr.ma isMaskedArrayasarray_chkfiniteasarrayr+ issubdtypeinexactfloat64)rA check_finite sparse_ok objects_okmask_ok as_inexactmsgtoarrays r'_asarray_validatedrsF  A;)CS/ !  55  q !>? ?&2b"" G A  77bhhsm #>? ?}}QWWbjj1,A Hr&c tj|}|||krt|d|d|S#t$rt|ddwxYw)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 )rRrr~r)krminimums r' _validate_intrst$A NN1 q7{D6"!!( +,15 6 H A4& 456D@As 1A  FullArgSpec)rvarargsvarkwdefaults kwonlyargskwonlydefaults annotationsc tj|}|jjDcgc]N}|jtj j tj jfvr |jP}}|jjDcgc]5}|jtj jk(r |j7}}|r|dnd}|jjDcgc]5}|jtj jk(r |j7}}|r|dnd}td|jjDxsd}|jjDcgc]5}|jtj jk(r |j7}}|jjDcic]X}|jtj jk(r/|j|jur|j|jZ}}|jjDcic]1}|j|jur|j|j3} }t!||||||xsd| Scc}wcc}wcc}wcc}wcc}wcc}w)asinspect.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. rNc3K|]O}|jtjjk(r&|j|j ur|jQywr-)kindrrPOSITIONAL_OR_KEYWORDr@rU)r0ps r'r3z)getfullargspec_no_self..$sD FFg''== = IIQWW $ sAA)rrrrrrrPOSITIONAL_ONLYrVAR_POSITIONAL VAR_KEYWORDr;rr@rU annotationr) rDsigrrrrrr kwdefaultsrs r'getfullargspec_no_selfrs|*   D !C--/  66g''==''779 9  D  --/ 66W&&55 5 G$gajG--/  66W&&22 2  E E!H4E>>002   --/ 66W&&33 3 J.1^^-B-B-D,VVw00===))177*&&!))#,J,251F1F1H3All!''1661<<'3K3 tWeXz!)T; 88;    ,3s%AJ3#:J8:J=:K+AK&6K ceZdZdZdZdZy)_FunctionWrapperz? Object to wrap user's function, allowing picklability c4||_|g|_y||_yr-frselfrrs r'__init__z_FunctionWrapper.__init__:s,B D r&c<|j|g|jSr-r)rxs r'__call__z_FunctionWrapper.__call__>stvva$$))$$r&Nr"r#r$rrrr%r&r'rr6s1%r&rceZdZdZddZdZy)_ScalarFunctionWrapperzD Object to wrap scalar user function, allowing picklability Nc6||_|gn||_d|_yNr)rrnfevrs r'rz_ScalarFunctionWrapper.__init__Fs,BD  r&cL|jtj|g|j}|xjdz c_tj |s& tj |j}|S|S#ttf$r}td|d}~wwxYw)Nrz@The user-provided objective function must return a scalar value.) rr.rrrisscalarritemr~r)rrfxes r'rz_ScalarFunctionWrapper.__call__KsTVVBGGAJ + + Q {{2 ZZ^((*  r z*  2 s#BB# BB#r-rr%r&r'rrBs r&rc<eZdZdZd dZdZdZdZdZdZ dZ 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. cd|_t|_d|_t |r||_|j|_yddlm}t|dk(r/||_|jj|_d|_yt|dk(ryt|dkDr:|t||_|jj|_d|_ytd) NFr)PoolrLTr) processeszUNumber of workers specified must be -1, an int >= 1, or an object with a 'map' method) poolmap_mapfunc _own_poolcallablemultiprocessingrr} RuntimeError)rrrs r'rzMapWrapper.__init__ls   D>DI IIDM ,4yB F $  !%TaTQ 3t95 $  !%"$,--r&c|Sr-r%rs r' __enter__zMapWrapper.__enter__s r&cR|jr|jjyyr-)r r terminaters r'rzMapWrapper.terminates >> II   ! r&cR|jr|jjyyr-)r rjoinrs r'rzMapWrapper.joins >> IINN  r&cR|jr|jjyyr-)r rclosers r'rzMapWrapper.closes >> IIOO  r&c|jr5|jj|jjyyr-)r rrr)rexc_type exc_value tracebacks r'__exit__zMapWrapper.__exit__s, >> IIOO  II   ! r&cb |j||S#t$r}td|d}~wwxYw)Nz;The map-like callable must be of the form f(func, iterable))rr~)rrDiterablers r'rzMapWrapper.__call__s= >==x0 0 >67<= > >s . ).Nr) r"r#r$rrrrrrrrr%r&r'rr\s*-8"" >r&rcBtjfd}|S)z Wrapper to deal with setup-cleanup of workers outside a user function via a ContextManager. It saves having to do the setup/tear down with within that function, which can be messy. c|j}d|vrt}nd|vr |dt}n|d}t|5}||d<|i|cdddS#1swYyxYw)Nworkers)rrr)rkwdsr_workersmfrDs r'innerz_workers_wrapper..innersr F "H & VI%6%>Hi(H  ! )R "F9 (( ) ) )s AArPr)rDr$s` r'_workers_wrapperr&s' __T ) ) Lr&c.t|tr|j|||||S|$tjj j }|r3||j|dz||S||j||dz||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+)rr integersr.rrrrandint)genlowr(r[r+r)s r' rng_integersr.sX#y!||CdU%-/ / ;))""((C |{{37U{CC{{3TAXD{NN{{3TE{BBr&c#Ktjj|ffd tj_ dtj_y#tj_wxYww)z0Context with a fixed np.random.default_rng seed.c|Sr-r%rorig_funs r'z$_fixed_default_rng..s htnr&N)r.rrr1s @r'_fixed_default_rngr4sGyy$$H(,._wrappedsKD#F#  FF75t <    s0)r7compileI)rDr=r<s` @r'_rng_html_rewriter@s&jjFMG Or&cjtj||}|r|tj||}|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)r.argmin expand_dims)rAkeepdimsrCr9s r'_argminrGs1 ))AD !CD$nnSt, Jr&ctttj||d}tj|||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]]) TrCrFrB)rGr.isnantake_along_axis)rArCrs r' _first_nonnanrL-s/8  $6A  a ..r&cF|#|jdk(ry|j}d}nD|j}||dk(r0|d|d|zz||dzdz}tj|dt St ||}||k(tj|zj||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]]) NrTrrr)rBrI) r[ravelr8r.r7boolrLrJr:)rArCrFshpa0s r' _nan_allsamerRMsD | 66Q; GGIgg t9>et*tH},s4!89~=C7734t< < qt $B 1W # ( (dX ( FFr&) xp_omit_okayxprA nan_policy) propagateraiseomitrSrTchd}||vrd|d}t|t|dk(ry| t|}|j|jdr"|j |j |}n |j|jdr`|j |j |j||j |j |j|z}nt|rtj|jtr_d}|jD]I}tjt|tjs1tj |sGd}nny|d k(r)t!|r d }t#||r d }t||S|d k(r4|s2t|s't!|r d }t#||r d}t||S)N>rXrWrVznan_policy must be one of .rFz real floatingzcomplex floatingTrWz4nan_policy='raise' is not supported for lazy arrays.zThe input contains nan valuesrXz3nan_policy='omit' is not supported for lazy arrays.z8nan_policy='omit' is incompatible with non-NumPy arrays.)rrr isdtyper+rJmaxrealimagr r.robjectrNtypenumberr r~)rArUrSrTpoliciesr contains_nanels r' _contains_nanre}s.H!*8*A6oqzQ z Q  zz!''?+xxq * AGG/ 0xxrwwqz 23bhhrvvbggaj?Q6RR ""--8 '') B}}T"Xryy1bhhrl#    W  HCC. 1CS/ !  v l8B<  GCC. LCS/ ! r&cfd}|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. cJtjfd}|S)Nc ^|vrrjjd}tt|ddz|d<dj|}dddd|d }t j |t d|vrjd d }t||j|<|i|S) NrZrr`rvrwrxryrzrt`) rrr}rrrrr"r~r)rrrnr dep_versionrnew_namers r'rz5_rename_parameter..decorator..wrappers6!"-"3"3C"8K%([^)>FZH//7j9++6-q :GMM'+=!Lv%"%,,099A ! EG#G,,#)::h#7x '' 'r&r%)rrrjrkrs` r'rz$_rename_parameter..decorators%   (  ("r&r%)rrkrjrs``` r'_rename_parameterrls@( r&c |j}|j}|j|Dcgc]0}tjj t ||2}}|Scc}wr-)rrspawnr.rr r`)rq n_childrenbgsschild_ss child_rngss r' _rng_spawnrtsa  B B"$((:"68))%%hd2hx&898J8 8s5A%r%)r8rTc|t|n|}t|d|d}t|}|j||j||}|s|d}t |r |j S|S)NT)force_floatingrT)r+devicer%)r rrr7nanr rK)r8rTrKr+rwr9s r'_get_nanryse#%:$ 2B D" =E t $F ''%uV' conslackr crossover_nitc j|djS#t$rtjcYSwxYwr)rrrr.rk)r order_keyss r'keyz!_RichResult.__repr__..keyBs; !''Q 88 vv  s!%AAc34K|D]}|dvr |ywrr%)itemsr omit_keyss r'omit_redundantz,_RichResult.__repr__..omit_redundantHs* 7i'  scFt|jS)N)r)sortedr)drrs r' item_sorterz)_RichResult.__repr__..item_sorterNs.3= =r&)sorterz())getattrkeys_dict_formatter __class__r")rrrrrrs @@@@r'__repr__z_RichResult.__repr__8s^ T=*= E      > 99;"4 < <>>**T1 1r&c4t|jSr-)listrrs r'__dir__z_RichResult.__dir__VsDIIK  r&N) r"r#r$rrdict __setitem__ __setattr__ __delitem__ __delattr__rrr%r&r'rr-s,?. ""K""K2<!r&rcV|jd}d|z}d|zj|S)zQ Ensures that lines after the first are indented by the specified amount r )rr)srdrindents r' _indenterrZs/ GGDME UF 6M   &&r&ctj|rytj|rytj|rytj|dddS)zP Returns a string representation of a float with exactly ten characters z infz -infz nanr`F) precisionpad_leftunique)r.isposinfisneginfrJformat_float_scientific)rs r'_float_formatter_10rcsE {{1~ Q ! % %a1q OOr&ct|trtttt |j |z}dj||Dcgc];\}}|j|dztt|||zdzd||dzz=c}}}|Stjd|z dddti5t|}d d d |Scc}}w#1swYSxYw) 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 rz: r`rL float_kind) linewidth edgeitems threshold formatterN)rrr\rr|rrrrjustrrr. printoptionsrr)rrdmplusrmrvrs r'rrps!T Caffh( )E 1 II#)!9.1awwqzD( AaCE1f!EqsKL. / H__r!tqB(46I'JL AA  H.  HsAC  C""C,a7 The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see :ref:`linalg_batch` for details. cXtt|\tfd}|S)a Factory for decorator that applies a function over batched arguments. Array arguments may have any number of core dimensions (typically 0, 1, or 2) and any broadcastable batch shapes. There may be any number of array outputs of any number of dimensions. Assumptions right now - which are satisfied by all functions of interest in `linalg` - are that all array inputs are consecutive keyword or positional arguments, and that the wrapped function returns either a single array or a tuple of arrays. It's only as general as it needs to be right now - it can be extended. Parameters ---------- *argdefs : tuple of (str, int) Definitions of array arguments: the keyword name of the argument, and the number of core dimensions. Example: -------- `linalg.eig` accepts two matrices as the first two arguments `a` and `b`, where `b` is optional, and returns one array or a tuple of arrays, depending on the values of other positional or keyword arguments. To generate a wrapper that applies the function over batches of `a` and optionally `b` : >>> _apply_over_batch(('a', 2), ('b', 2)) ctjfd}t|}|djtj t |jddd|_|S)Nct|}|d|d}}tD]V\}}||vs |dzt|krtjd|d|j |j |Xg}g}tt|D]\}\}} |dntj|}|dn |j} | dk(r|jdk\rdnd} |||<|j | dkDr| d| n| |j | dkDr| | dndt|s g||i|Stj|} tt||D]'\}\}} | tj|| | z||<)g} tj| D]>gfd|D|i|}t!|t"s|fn|}| j |@tt| } t| D]E\}}tj$|}|jdd} tj&|| | z| |<Gt| dk(r| dS| S) Nrz%() got multiple values for argument `rur%z1|2r`rc30K|] }||ndywr-r%)r0rbrs r'r3zH_apply_over_batch..decorator..wrapper..s'2!&/4.?eElTI2s)r enumerater|rr"appendrr9r.rr8r{anybroadcast_shapes broadcast_tondindexrr;stackreshape)rrr? other_argsir batch_shapes core_shapesrbr{r8 batch_shape core_shaperesultsresultrrn_arraysnamesndimss @r'rz5_apply_over_batch..decorator..wrappers:D"&ix$xy/JF$U+ 846>1uD )(AJJ<8::>r*CDD fjj&67  8LK$-c&%.@$A F =E4 % 2::e3D#m5= % a1QD!q ##TAXE&D5M5I""D1H5$="E F|$8&8:888--|JBHJ +5VU*C&v& '3=)G'w/ J 6&)#\\!"- ZZ j0HI  J"%W!271: ? ?r&zExtended Summaryrr) rPrrr _batch_noterstriprrr)rrrrrrs` r'rz$_apply_over_batch..decoratorsj  = @ = @~'" &&{'9'9';<c(..q1!4r&)rr9r|)argdefsrrrrs @@@r'_apply_over_batchrs/6W &LE55zHEL r&rLrBctjdkDrtj|||Stj||z|S)Nz2.0rB)r. __version__vecdotsum)x1x2rCs r' np_vecdotrs: ~~yyRd++vvb2gD))r&)r)TFFFFr-)NNint64F)l !E^1cuBn)FN)F)rV)rrN)hr7 contextlibrrPrRrr collectionsrrritypesrtypingrrrnumpyr.scipy._lib._array_apir r r r r rrrscipy._lib._docscraperrscipy._lib._sparsernumpy.exceptionsrr`__annotations__lib NumpyVersionrcatch_warningsfilterwarningsrlongrulongrrint_uintr}r IntNumberrhfloating DecimalNumberrOrrb __array__r~rr rrrr numpy.random ImportErrorrGr^rcrlrrrrrrrrrrr&r.r4r@rGrLrRrerlrtryr|rrrrrrrrrr%r&r'r s %" ..<<<9'&  66r~~&,6  $X $ $ & #H # #B  ggGxxH ggGwwH "**   #bjj0 t 66r~~&'1NVV(83N! T* ))%% (=(==i=$&-)-t4  3 %P!&S4;s;u;  :264#'|@"<(,BG"'4 n RIJ 48n % %4G>G>T.8?=C@)). /@-Gd9D< < <45< < T <  T\ <~4n .4*!$*!Z' P 8 dN"$ *&   ggGwwH*     sNK*-KK%K51LK KK21K25L?LLL