
    <>iV                        S SK r S SKJr  S SKrS SKrS SKrS SKJr  \R                  R                  r\R                  " S5      rS rS rS r\\R                  R#                  S\R$                  " 5       S	4\R&                  " 5       S
4\R(                  " 5       S4\R*                  " 5       S4\R,                  " 5       S4\R.                  " 5       S4\R0                  " 5       S4\R2                  " 5       S4\R4                  " 5       S4\R6                  " 5       S4\R8                  " 5       S4/5      S 5       5       r\\R                  R#                  S\R$                  \R&                  \R(                  \R*                  \R,                  \R.                  \R0                  \R2                  \R4                  \R6                  \R8                  /5      S 5       5       rS rS r g)    Nwraps)Versionnumpyc                 p    [         R                  R                  [         R                  " U 5      U5      S:H  $ )N   )ctypes	pythonapiPyCapsule_IsValid	py_object)capsulenames     X/var/www/html/land-tabula/venv/lib/python3.13/site-packages/pyarrow/tests/test_dlpack.pyr   r       s,    --f.>.>w.GNRSSS    c                     U R                  5       n[        US5      SL d   e[        R                  U 5      n[        R                  R                  X1SS9  U R                  5       S:X  d   eg )Ns   dltensorT)strict)r   r   )
__dlpack__r   npfrom_dlpacktestingassert_array_equal__dlpack_device__)arrexpected_arrDLTensorresults       r   check_dlpack_exportr   $   s_    ~~HX{3t;;;^^C FJJ!!&t!D  "f,,,r   c                 0   ^  [        T 5      U 4S j5       nU$ )Nc                     > [         R                  " 5         [        R                  " 5       n T" U 0 UD6[        R                  " 5       U:X  d   e$ ! [        R                  " 5       U:X  d   ef = f)N)gccollectpatotal_allocated_bytes)argskwargsallocated_bytesfs      r   wrapper&check_bytes_allocated.<locals>.wrapper/   s\    


224	Ad%f%++-@@@2++-@@@s   A A-r   )r'   r(   s   ` r   check_bytes_allocatedr*   .   s"    
1XA A Nr   )
value_typenp_type_struint8uint16uint32uint64int8int16int32int64float16float32float64c                    [        [        R                  5      [        S5      :  a  [        R                  " S5        [        R                  / SQ[        R                  U5      S9n[        R
                  " X S9n[        X25        [        R                  R                  U5      n[        XB5        UR                  SS5      n[        R                  S/[        R                  U5      S9n[        XR5        UR                  SS5      n[        R                  S/[        R                  U5      S9n[        XR5        UR                  S5      n[        R                  SS	/[        R                  U5      S9n[        XR5        [        R
                  " / U S9n[        R                  / [        R                  U5      S9n[        Xb5        [        R                  R                  U5      n[        XB5        g )
N1.24.0yNo dlpack support in numpy versions older than 1.22.0, strict keyword in assert_array_equal added in numpy version 1.24.0r         dtypetyper   r<   r   r=   )r   r   __version__pytestskiparrayr?   r"   r   Tensor
from_numpyslice)r+   r,   expectedr   t
arr_slicedarr_zeros          r   test_dlpackrM   :   se   $ r~~!22  	 xx	+)>x?H
((8
-C&
		X&A$1aJxx288K#8x9H
-1aJxx288K#8x9H
-1JxxAbhh{&;x<H
-xx,Hxx"((;"7x8H+
		X&A$r   np_typec                    [        [        R                  5      [        S5      :  a  [        R                  " S5        [        R                  / SQ5      n[        R                  XS9R                  SSS9n[        R                  R                  U5      n[        X25        [        R                  XS9R                  SSS9n[        R                  R                  U5      n[        X25        g )	Nr9   r:   )r   r<   r=            r   r   r>   )r<   r<   r<   C)orderF)r   r   rB   rC   rD   rE   reshaper"   rF   rG   r   )rN   r   rI   rJ   s       r   test_tensor_dlpackrW   l   s     r~~!22  	 ((+
,Cxxx+33IS3IH
		X&A$xxx+33IS3IH
		X&A$r   c                     [        [        R                  5      [        S5      :  a  [        R                  " S5        [
        R                  " / SQ5      n [        R                  " [        SS9   [        R                  U 5        S S S 5        [
        R                  " SS/SS	//[
        R                  " [
        R                  " 5       5      S
9n [        R                  " [        SS9   [        R                  U 5        S S S 5        [
        R                  " / 5      n [        R                  " [        SS9   [        R                  U 5        S S S 5        [
        R                  " / SQ5      n [        R                  " [        SS9   [        R                  U 5        S S S 5        g ! , (       d  f       GN%= f! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g = f)Nz1.22.0z6No dlpack support in numpy versions older than 1.22.0.)r   Nr=   z,Can only use DLPack on arrays with no nulls.matchr   r   r=   rP   r@   z+DataType is not compatible with DLPack spec)TFTz5Bit-packed boolean data type not supported by DLPack.)r   r   rB   rC   rD   r"   rE   raises	TypeErrorr   list_r3   )r   s    r   test_dlpack_not_supportedr^      s@   r~~!22LM
((<
 C	y )2 
3
s
3 ((
Q!QXXbhhj!C 
y(U	V
s 
W ((2,C	y(U	V
s 
W ((&
'C	y )2 
3
s
3 
3#
3 
3 
W	V 
W	V

3 
3s0   .F"'F44GG"
F14
G
G
G$c                     [         R                  " S5      n [        R                  " [        R                  " S[        R
                  " 5       5      /5      n[        R                  " / SQ[        R
                  " 5       S9n[        R                  " U/US9nU R                  X0R                  S5      5      nU R                  XCR                  5      nUS   n[         R                  " [        SS9   [        R                  U5        S S S 5        [         R                  " [        SS9   UR                  5         S S S 5        g ! , (       d  f       NA= f! , (       d  f       g = f)	Nzpyarrow.cudaf0r;   r@   )schemar   z=DLPack support is implemented only for buffers on CPU device.rY   )rC   importorskipr"   ra   fieldr2   rE   record_batchserialize_record_batchContextread_record_batchr[   NotImplementedErrorr   r   r   )cudara   a0batchcbufcbatchcarrs          r   test_dlpack_cuda_not_supportedro      s    ~.DYYrxxz234F	)"((*	-BOORD0E&&ull1o>D##D,,7F$<D 
* 39 
:
t
: 
* 39 
: 
: 
:	
: 
:
: 
:s   /E &E 
E
E)!r	   	functoolsr   r    rC   pyarrowr"   pyarrow.vendored.versionr   markr   
pytestmarkrb   r   r   r   r*   parametrizer-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   rM   rW   r^   ro    r   r   <module>rw      s  $   	   , [[
!T-	 !	W	h	h	h	F	W	W	W	y!	y!	y! %! "%B ((BIIryy"))''288RXXrxx**bjj"**?@%	@ 
% 6!r   