Ë
    qwj/  ã                   óF  — d dl mZ d dl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
mZ ddlmZmZ g d¢Z ej                   «       Z ej$                  «       Zdd„Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd d dddœZd„ Zd„ Z ed¬«      ej:                  d„ «       «       Z ed¬«      d„ «       Zy)é    )ÚNumberN)Úcopy_if_needed)Úxp_capabilitiesé   )Ú	good_sizeÚprev_good_size)r   r   Úset_workersÚget_workersc                 óÈ   — t        | t        «      r| f} 	 | D �cg c]  }t        j                  |«      ‘Œ } }| S c c}w # t        $ r}|xs d}t        |› d�«      |‚d}~ww xY w)a  Convert ``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)Ú
isinstancer   ÚoperatorÚindexÚ	TypeErrorÚ
ValueError)ÚxÚnameÚaÚes       ú`/var/www/html/newmanjeet/manjet/venv/lib/python3.12/site-packages/scipy/fft/_pocketfft/helper.pyÚ_iterable_of_intr      su   € ô �!”VÔØˆDˆðTÙ()Ó*© 1ŒX�^‰^˜AÕ¨ˆÐ*ð
 €Hùò +øÜò TØŠ�wˆÜ˜D˜6Ð!JÐKÓLÐRSÐSûðTús!   •> ™9µ> ¹> ¾	A!ÁAÁA!c                 ó–  ‡ — |du }|du }|syt        |d«      }|D �cg c]  }|dk  r|‰ j                  z   n|‘Œ }}t        ˆ fd„|D «       «      rt        d«      ‚t	        t        |«      «      t	        |«      k7  rt        d«      ‚|s´t        |d«      }|r"t	        |«      t	        |«      k7  rt        d«      ‚|rOt	        |«      ‰ j                  kD  rt        d	«      ‚t        ‰ j                  t	        |«      z
  ‰ j                  «      }t        ||«      D ��cg c]  \  }}|d
k(  r‰ j                  |   n|‘Œ }}}nI|r+t        ‰ j                  «      }t        ‰ j                  «      }n|D �cg c]  }‰ j                  |   ‘Œ }}t        d„ |D «       «      rt        d|› d�«      ‚t        |«      t        |«      fS c c}w c c}}w c c}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.
    NÚaxesr   c              3   óJ   •K  — | ]  }|‰j                   k\  xs |d k  –— Œ y­w)r   N)Úndim)Ú.0r   r   s     €r   Ú	<genexpr>z*_init_nd_shape_and_axes.<locals>.<genexpr>T   s&   øè ø€ Ð2©T¨ˆq�A—F‘F‰{Ò#˜a !™eÓ#©Tùs   ƒ #z$axes exceeds dimensionality of inputzall axes must be uniqueÚshapezBwhen given, axes and shape arguments have to be of the same lengthz)shape requires more axes than are presentéÿÿÿÿc              3   ó&   K  — | ]	  }|d k  –— Œ y­w)r   N© )r   Úss     r   r   z*_init_nd_shape_and_axes.<locals>.<genexpr>k   s   è ø€ Ð
 ™%�Qˆ1ˆq�5™%ùs   ‚úinvalid number of data points (ú) specified)r   r   Úanyr   ÚlenÚsetÚrangeÚzipr   ÚlistÚtuple)r   r   r   ÚnoshapeÚnoaxesr   r"   s   `      r   Ú_init_nd_shape_and_axesr.   /   s±  ø€ ð< �tˆm€GØ�Tˆ\€FáÜ  fÓ-ˆÙ48Ó9±D¨q˜a !še��A—F‘F’
¨Ñ*°DˆÐ9äÓ2©TÓ2Ô2ÜÐCÓDÐDÜŒs�4‹y‹>œS ›YÒ&ÜÐ6Ó7Ð7áÜ  ¨Ó0ˆá”C˜“I¤ U£Ò+Üð >ó ?ð ?áÜ�5‹z˜AŸF™FÒ"Ü Ð!LÓMÐMÜ˜Ÿ™¤# e£*Ñ,¨a¯f©fÓ5ˆDä:=¸eÀTÔ:JÔKÑ:J±$°!°Q˜q Bšw�—‘˜’¨AÑ-Ð:JˆÒKÙ	Ü�Q—W‘W“ˆÜ�Q—V‘V‹}‰á%)Ó*¡T �—‘˜“ TˆÐ*ä
Ñ
 ™%Ó
 Ô ÜØ-¨e¨W°KÐ@óBð 	Bô �‹<œ˜d›Ð#Ð#ùò; :ùó$ Lùò
 +s   œF;Ä G Å,Gc                 óÒ  — t        | d«      st        j                  | «      } | j                  t        j                  k(  r$t        j                  | t        j
                  «      S | j                  j                  dvr$t        j                  | t        j                  «      S | j                  j                  d«      }| j                  d   sdnt        }t        j                  | ||¬«      S )zl
    Convert to array with floating or complex dtype.

    float16 values are also promoted to float32.
    ÚdtypeÚfcÚ=ÚALIGNEDT)r0   Úcopy)ÚhasattrÚnpÚasarrayr0   Úfloat16Úfloat32ÚkindÚfloat64ÚnewbyteorderÚflagsr   Úarray)r   r0   r4   s      r   Ú	_asfarrayr?   r   s    € ô �1�gÔÜ�J‰J�q‹Mˆà‡w�w”"—*‘*ÒÜ�z‰z˜!œRŸZ™ZÓ(Ð(Ø	
�‰�‰˜TÑ	!Ü�z‰z˜!œRŸZ™ZÓ(Ð(ð �G‰G× Ñ  Ó%€Eà—w‘w˜yÒ)‰4¬~€DÜ�8‰8�A˜U¨Ô.Ð.ó    c                 óv   — | |u ryt        |t        j                  «      st        |d«      ry| j                  du S )z|
    Strict check for `arr` not sharing any data with `original`,
    under the assumption that arr = asarray(original)
    FÚ	__array__N)r   r6   Úndarrayr5   Úbase)ÚarrÚoriginals     r   Ú_datacopiedrG   †   s7   € ð
 ˆh�ØÜ�h¤§
¡
Ô+´¸À+Ô0NØØ�8‰8�tÐÐr@   c                 ó¼  — d}t        d«      g| j                  z  }t        ||«      D ]E  \  }}| j                  |   |k\  rt        d|«      ||<   Œ(t        d| j                  |   «      ||<   d}ŒG t	        |«      }|s| |   dfS t        | j                  «      }t        ||«      D ]
  \  }}|||<   Œ t        j                  || j                  «      }	| |   |	|<   |	dfS )z5Internal auxiliary function for _raw_fft, _raw_fftnd.FNr   T)	Úslicer   r)   r   r+   r*   r6   Úzerosr0   )
r   r   r   Ú	must_copyr   ÚnÚaxr"   ÚaxisÚzs
             r   Ú
_fix_shaperP   ’   sá   € à€Iô �4‹[ˆM˜!Ÿ&™&Ñ €EÜ�U˜DÖ!‰ˆˆ2Ø�7‰7�2‰;˜!ÒÜ˜a ›ˆE�"ŠIä˜a §¡¨¡Ó-ˆE�"‰IØ‰Ið "ô �%‹L€EáØ�‰x˜ˆÐäˆQ�W‰W‹€AÜ�u˜dÖ#‰ˆˆ4Øˆˆ$Šð $ô 	�‰��A—G‘GÓ€AØ�‰x€A€e�HØˆdˆ7€Nr@   c                 óH   — |dk  rt        d|› d�«      ‚t        | |f|f«      S )Nr   r#   r$   )r   rP   )r   rL   rN   s      r   Ú_fix_shape_1drR   ­   s7   € Øˆ1‚uÜØ-¨a¨S°Ð<ó>ð 	>ô �a˜!˜ ˜wÓ'Ð'r@   é   )NÚbackwardÚorthoÚforwardc                 ób   — 	 t         |    }|r|S d|z
  S # t        $ r t        d| ›d�«      d‚w xY w)zAReturns the pypocketfft normalization mode from the norm argumentrS   zInvalid norm value z,, should be "backward", "ortho" or "forward"N)Ú	_NORM_MAPÚKeyErrorr   )ÚnormrV   Úinorms      r   Ú_normalizationr\   ¸   sQ   € ð=Ü˜$‘ˆÙˆuÐ0 a¨%¡iÐ0øÜò =ÜØ! $ ð *2ð 2ó3à8<ð	=ð=ús   ‚ � ”.c                 ó²   — | €t        t        dd«      S | dk  r.| t         k\  r| dt        z   z  } | S t        d| › dt         › �«      ‚| dk(  rt        d«      ‚| S )NÚdefault_workersr   r   z workers value out of range; got z, must not be less than zworkers must not be zero)ÚgetattrÚ_configÚ
_cpu_countr   )Úworkerss    r   Ú_workersrc   Ã   s}   € Ø€Ü”wÐ 1°1Ó5Ð5à�‚{Ø”z�kÒ!Ø�qœ:‘~Ñ%ˆGð €Nô Ð?À¸yð I+Ü,6¨;¨-ð9ó :ð :à	�AŠÜÐ3Ó4Ð4à€Nr@   T)Úout_of_scopec              #   ó®   K  — t        «       }t        t        j                  | «      «      t        _        	 d–— |t        _        y# |t        _        w xY w­w)a   Context 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
   rc   r   r   r`   r^   )rb   Úold_workerss     r   r	   r	   Ó   s=   è ø€ ô( “-€KÜ&¤x§~¡~°gÓ'>Ó?„GÔð.Ûà"-ŒÕø +ŒÕüs   ‚2AµA ¹AÁAÁAc                  ó$   — t        t        dd«      S )zãReturns 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@   r   r
   r
   ï   s   € ô ”7Ð-¨qÓ1Ð1r@   )N) Únumbersr   r   ÚosÚ	threadingÚ
contextlibÚnumpyr6   Úscipy._lib._utilr   Úscipy._lib._array_apir   Úpypocketfftr   r   Ú__all__Úlocalr`   Ú	cpu_countra   r   r.   r?   rG   rP   rR   rX   r\   rc   Úcontextmanagerr	   r
   r!   r@   r   Ú<module>rt      s¿   ðÝ Û Û 	Û Û ã å +Ý 1÷ 3ò H€à
ˆ)�/‰/Ó
€ØˆR�\‰\‹^€
óò2@$òF/ò(	òò6(ð  !¨a¸AÑ>€	ò=òñ  ˜dÔ#Ø×Ññ.ó ó $ð.ñ4 ˜dÔ#ñ2ó $ñ2r@   