L i ddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z gdZ ejZej ZddZdZd Zd Zd Zd Zdddd dZdZdZej6dZdZy))NumberN)copy_if_needed) good_sizeprev_good_size)rr set_workers get_workersct|tr|f} |Dcgc]}tj|}}|Scc}w#t$r}|xsd}t |d|d}~wwxYw)aConvert ``x`` to an iterable sequence of int Parameters ---------- x : value, or sequence of values, convertible to int name : str, optional Name of the argument being converted, only used in the error message Returns ------- y : ``List[int]`` valuez) must be a scalar or iterable of integersN) isinstanceroperatorindex TypeError ValueError)xnameaes a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/fft/_pocketfft/helper.py_iterable_of_intrst!V DT() *1X^^A  * * H + TwD6!JKLRSSTs!>9>> A!AA!c|du}|du}|syt|d}|Dcgc]}|dkr|jzn|}}tfd|Dr tdt t |t |k7r td|st|d}|r"t |t |k7r td|rOt |jkDr td t jt |z j}t||Dcgc]\}}|d k(rj|n|}}}nI|r+tj}t j}n|Dcgc]}j|}}td |Drtd |d t|t|fScc}wcc}}wcc}w)a Handle shape and axes arguments for N-D transforms. Returns the shape and axes in a standard form, taking into account negative values and checking for various potential errors. Parameters ---------- x : ndarray The input array. shape : int or array_like of ints or None The shape of the result. If both `shape` and `axes` (see below) are None, `shape` is ``x.shape``; if `shape` is None but `axes` is not None, then `shape` is ``numpy.take(x.shape, axes, axis=0)``. If `shape` is -1, the size of the corresponding dimension of `x` is used. axes : int or array_like of ints or None Axes along which the calculation is computed. The default is over all axes. Negative indices are automatically converted to their positive counterparts. Returns ------- shape : tuple The shape of the result as a tuple of integers. axes : list Axes along which the calculation is computed, as a list of integers. Naxesrc3JK|]}|jk\xs|dkyw)rN)ndim).0rrs r z*_init_nd_shape_and_axes..Ss%2qAFF{#a!e#2s #z$axes exceeds dimensionality of inputzall axes must be uniqueshapezBwhen given, axes and shape arguments have to be of the same lengthz)shape requires more axes than are presentc3&K|] }|dk yw)rN)rss rrz*_init_nd_shape_and_axes..js Q1q5 sinvalid number of data points ( ) specified) rranyrlensetrangeziprlisttuple)rrrnoshapenoaxesrr!s` r_init_nd_shape_and_axesr-.s<tmG T\F f-489qa!eAFF *99 2T2 2CD D s4y>SY &67 7  0 CIU+>? ? 5zAFF" !LMM#e*,aff5D:=eT:JK$!QqBwA-KK QWW QVV}%)*** %  -eWK @B B <d ##;:$L +sF; G,Gct|dstj|}|jtjk(r$tj|tj S|jj dvr$tj|tjS|jjd}|jdsdnt}tj|||S)zl Convert to array with floating or complex dtype. float16 values are also promoted to float32. dtypefc=ALIGNEDT)r/copy) hasattrnpasarrayr/float16float32kindfloat64 newbyteorderflagsrarray)rr/r3s r _asfarrayr>qs 1g  JJqMww"**zz!RZZ(( T !zz!RZZ(( GG  %Ewwy)4~D 88AU ..cv||uryt|tjs t|dry|jduS)z| Strict check for `arr` not sharing any data with `original`, under the assumption that arr = asarray(original) F __array__N)r r5ndarrayr4base)arroriginals r _datacopiedrFs7  h h ++0N 88t r?cd}tdg|jz}t||D]E\}}|j||k\rtd|||<(td|j|||<d}Gt |}|s||dfSt |j}t||D] \}}|||< t j||j} ||| |<| dfS)z5Internal auxiliary function for _raw_fft, _raw_fftnd.FNrT) slicerr(rr*r)r5zerosr/) rrr must_copyrnaxr!axiszs r _fix_shaperOsI4[M!&& EUD!2 772;! a E"Ia-E"II  %LE x QWW Aud#4$ AGGAxAeH d7Nr?cH|dkrtd|dt||f|fS)Nrr"r#)rrO)rrKrMs r _fix_shape_1drQs71u-aS <> > a!w ''r?)Nbackwardorthoforwardcb t|}|r|Sd|z S#t$rtd|ddwxYw)zAReturns the pypocketfft normalization mode from the norm argumentrRzInvalid norm value z,, should be "backward", "ortho" or "forward"N) _NORM_MAPKeyErrorr)normrUinorms r_normalizationr[sQ=$u0a%i0 =!$*2 238< ==s .c|ttddS|dkr.|t k\r|dtzz }|Std|dt |dk(r td|S)Ndefault_workersrrz workers value out of range; got z, must not be less than zworkers must not be zero)getattr_config _cpu_countr)workerss r_workersrbs}w 1155{ zk ! q:~ %G N ?yI+,6;-9: : A344 Nr?c#Kt}ttj|t_ d|t_y#|t_wxYww)aContext manager for the default number of workers used in `scipy.fft` Parameters ---------- workers : int The default number of workers to use Examples -------- >>> import numpy as np >>> from scipy import fft, signal >>> rng = np.random.default_rng() >>> x = rng.standard_normal((128, 64)) >>> with fft.set_workers(4): ... y = signal.fftconvolve(x, x) N)r rbr rr_r])ra old_workerss rrrs=&-K&x~~g'>?G. "-+s2AA A AAc$ttddS)zReturns the default number of workers within the current context Examples -------- >>> from scipy import fft >>> fft.get_workers() 1 >>> with fft.set_workers(4): ... fft.get_workers() 4 r]r)r^r_r r?rr r s 7-q 11r?)N)numbersrr os threading contextlibnumpyr5scipy._lib._utilr pypocketfftrr__all__localr_ cpu_countr`rr-r>rFrOrQrWr[rbcontextmanagerrr r r?rrqs +3 H )//  R\\^  2@$F/( 6(!aA > =   ..4 2r?