ó
    Eñi¯  ã                   óÄ   • S SK Jr  SSKr\R                  " \R                  5      R
                  S   rSq " S S5      qS r	 " S S\
5      rSS	 jrS
 rS rSS jrS rg)é   )Ú_ccallback_cé    Nc                   ó   • \ rS rSrSrg)ÚCDataé	   © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚR/home/mande/repo/quber/.venv/lib/python3.13/site-packages/scipy/_lib/_ccallback.pyr   r   	   s   † Úr   r   c                  ó‚   • [         b  g  SS Kn U R                  5       q [         R                  qg ! [         a    Sq  g f = f)Nr   F)ÚffiÚcffiÚFFIr   ÚImportError)r   s    r   Ú_import_cffir      s<   € ô �ØðÛØ�h‰h‹jˆÜ—	‘	‰øÜó ØŠðús   Š$/ ¯>½>c                   óŠ   • \ rS rSrSrSrSS jrS r\S 5       r	\S 5       r
\S	 5       rS
 r\SS j5       r\SS j5       rSrg)ÚLowLevelCallableé   aÐ  
Low-level callback function.

Some functions in SciPy take as arguments callback functions, which
can either be python callables or low-level compiled functions. Using
compiled callback functions can improve performance somewhat by
avoiding wrapping data in Python objects.

Such low-level functions in SciPy are wrapped in `LowLevelCallable`
objects, which can be constructed from function pointers obtained from
ctypes, cffi, Cython, or contained in Python `PyCapsule` objects.

.. seealso::

   Functions accepting low-level callables:

   `scipy.integrate.quad`, `scipy.ndimage.generic_filter`,
   `scipy.ndimage.generic_filter1d`, `scipy.ndimage.geometric_transform`

   Usage examples:

   :ref:`ndimage-ccallbacks`, :ref:`quad-callbacks`

Parameters
----------
function : {PyCapsule, ctypes function pointer, cffi function pointer}
    Low-level callback function.
user_data : {PyCapsule, ctypes void pointer, cffi void pointer}
    User data to pass on to the callback function.
signature : str, optional
    Signature of the function. If omitted, determined from *function*,
    if possible.

Attributes
----------
function
    Callback function given.
user_data
    User data given.
signature
    Signature of the function.

Methods
-------
from_cython
    Class method for constructing callables from Cython C-exported
    functions.

Notes
-----
The argument ``function`` can be one of:

- PyCapsule, whose name contains the C function signature
- ctypes function pointer
- cffi function pointer

The signature of the low-level callback must match one of those expected
by the routine it is passed to.

If constructing low-level functions from a PyCapsule, the name of the
capsule must be the corresponding signature, in the format::

    return_type (arg1_type, arg2_type, ...)

For example::

    "void (double)"
    "double (double, int *, void *)"

The context of a PyCapsule passed in as ``function`` is used as ``user_data``,
if an explicit value for ``user_data`` was not given.

r   Nc                 óT   • U R                  XU5      n[        R                  XX45      $ ©N)Ú_parse_callbackÚtupleÚ__new__)ÚclsÚfunctionÚ	user_dataÚ	signatureÚitems        r   r   ÚLowLevelCallable.__new__h   s*   € ð ×"Ñ" 8¸	ÓBˆÜ�}‰}˜S¨Ð"=Ó>Ð>r   c                 ó@   • SU R                   < SU R                  < S3$ )NzLowLevelCallable(ú, Ú))r   r    ©Úselfs    r   Ú__repr__ÚLowLevelCallable.__repr__n   s!   € Ø" 4§=¡=Ñ"3°2°d·n±nÑ5GÀqÐIÐIr   c                 ó.   • [         R                  U S5      $ )Nr   ©r   Ú__getitem__r'   s    r   r   ÚLowLevelCallable.functionq   ó   € ä× Ñ   qÓ)Ð)r   c                 ó.   • [         R                  U S5      $ )Né   r,   r'   s    r   r    ÚLowLevelCallable.user_datau   r/   r   c                 óV   • [         R                  " [        R                  U S5      5      $ )Nr   )r   Úget_capsule_signaturer   r-   r'   s    r   r!   ÚLowLevelCallable.signaturey   s    € ä×1Ò1´%×2CÑ2CÀDÈ!Ó2LÓMÐMr   c                 ó   • [        5       er   )Ú
ValueError)r(   Úidxs     r   r-   ÚLowLevelCallable.__getitem__}   s
   € Ü‹lÐr   c                 ó´   •  UR                   U   nU " XSU5      $ ! [         a  nSn[        U5      UeSnAf[         a  nSU< S3n[        U5      UeSnAff = f)a±  
Create a low-level callback function from an exported Cython function.

Parameters
----------
module : module
    Cython module where the exported function resides
name : str
    Name of the exported function
user_data : {PyCapsule, ctypes void pointer, cffi void pointer}, optional
    User data to pass on to the callback function.
signature : str, optional
    Signature of the function. If omitted, determined from *function*.

z?Given module is not a Cython module with __pyx_capi__ attributeNzNo function z$ found in __pyx_capi__ of the module)Ú__pyx_capi__ÚAttributeErrorr7   ÚKeyError)r   ÚmoduleÚnamer    r!   r   ÚeÚmessages           r   Úfrom_cythonÚLowLevelCallable.from_cython€   so   € ð"	-Ø×*Ñ*¨4Ñ0ˆHñ �8¨	Ó2Ð2øô ó 	-ØWˆGÜ˜WÓ%¨1Ð,ûÜó 	-Ø$ T¡HÐ,PÐQˆGÜ˜WÓ%¨1Ð,ûð	-ús   ‚ š
A¤2²A¿AÁAc                 óp  • [        5         [        U[        5      (       a  [        R	                  US5      nOo[        U[
        5      (       a  [        X5      u  pCOL[        U[        5      (       a  [        X5      u  pCO)[        R                  " U5      (       a  UnO[        S5      e[        U[        R                  5      (       a  [        U5      nOP[        U[        5      (       a  [        U5      nO/Uc  SnO)[        R                  " U5      (       a  UnO[        S5      e[        R                   " XCU5      $ )Nr   zMGiven input is not a callable or a low-level callable (pycapsule/ctypes/cffi)zNGiven user data is not a valid low-level void* pointer (pycapsule/ctypes/cffi))r   Ú
isinstancer   r   r-   Ú
PyCFuncPtrÚ_get_ctypes_funcr   Ú_get_cffi_funcr   Úcheck_capsuler7   ÚctypesÚc_void_pÚ_get_ctypes_dataÚ_get_cffi_dataÚget_raw_capsule)r   Úobjr    r!   ÚfuncÚcontexts         r   r   Ú LowLevelCallable._parse_callback›   s  € äŒä�cÔ+×,Ñ,Ü×$Ñ$ S¨!Ó,‰DÜ˜œZ×(Ñ(Ü.¨sÓ>‰OˆD�)Ü˜œU×#Ñ#Ü,¨SÓ<‰OˆD�)Ü×'Ò'¨×,Ñ,Ø‰Däð Jó Kð Kô �i¤§¡×1Ñ1Ü& yÓ1‰GÜ˜	¤5×)Ñ)Ü$ YÓ/‰GØÑØ‰GÜ×'Ò'¨	×2Ñ2Ø‰Gäð Oó Pð Pô ×+Ò+¨D¸WÓEÐEr   )NN)r	   r
   r   r   Ú__doc__Ú	__slots__r   r)   Úpropertyr   r    r!   r-   ÚclassmethodrB   r   r   r   r   r   r   r      sˆ   † ñHðV €Iô?òJð ñ*ó ð*ð ñ*ó ð*ð ñNó ðNòð ó3ó ð3ð4 óFó óFr   r   c                 ó0  • [         R                  " U [         R                  5      R                  nUcb  [	        U R
                  5      S-   n[        U R                  5       H,  u  p4US:X  a  U[	        U5      -  nM  US[	        U5      -   -  nM.     US-  nX!4$ )Nz (r   r%   r&   )rJ   ÚcastrK   ÚvalueÚ_typename_from_ctypesÚrestypeÚ	enumerateÚargtypes)rP   r!   Úfunc_ptrÚjÚargs        r   rG   rG   ¾   s�   € ä�{Š{˜4¤§¡Ó1×7Ñ7€Hð ÑÜ)¨$¯,©,Ó7¸$Ñ>ˆ	Ü §¡Ö.‰FˆAØ�A‹vØÔ2°3Ó7Ñ7’	à˜TÔ$9¸#Ó$>Ñ>Ñ>’	ñ	 /ð
 	�SÑˆ	àÐÐr   c                 ó  • U c  gU [         R                  L a  gU R                  nSnUR                  S5      (       a"  US-  nUSS  nUR                  S5      (       a  M"  UR                  S5      (       a  USS  nUS:”  a  US	S
U-  -   -  nU$ )NÚvoidzvoid *r   ÚLP_r   é   Úc_r1   Ú Ú*)rJ   rK   r	   Ú
startswith)r"   r?   Úpointer_levels      r   rZ   rZ   Ï   s™   € Ø�|ØØ	”—‘Ò	 Øà�=‰=€Dà€MØ
�/‰/˜%×
 Ñ
 Ø˜ÑˆØ�A�Bˆxˆð �/‰/˜%×
 Ó
 ð ‡��t×ÑØ�A�Bˆxˆà�qÓØ��c˜-Ñ'Ñ'Ñ'ˆà€Kr   c                 ó`   • [         R                  " U [         R                  5      R                  $ r   )rJ   rX   rK   rY   ©Údatas    r   rL   rL   å   s   € ä�;Š;�tœVŸ_™_Ó-×3Ñ3Ð3r   c                 óª   • [         R                  SU 5      nUc8  [         R                  [         R                  U 5      5      R	                  SS5      nX!4$ )NÚ	uintptr_tz(*)rf   )r   rX   ÚgetctypeÚtypeofÚreplace)rP   r!   r^   s      r   rH   rH   î   sG   € ä�x‰x˜ TÓ*€Hð ÑÜ—L‘L¤§¡¨DÓ!1Ó2×:Ñ:¸5À#ÓFˆ	àÐÐr   c                 ó.   • [         R                  SU 5      $ )Nrn   )r   rX   rk   s    r   rM   rM   ù   s   € ä�8‰8�K Ó&Ð&r   r   )Ú r   rJ   Ú	CFUNCTYPErK   Ú	__bases__rF   r   r   r   r   r   rG   rZ   rL   rH   rM   r   r   r   Ú<module>rv      sh   ðÝ ã à×Ò˜fŸo™oÓ.×8Ñ8¸Ñ;€
à
€÷	ñ 	òô]F�uô ]FôHò"ò,4ôó'r   