ó
    Ð]j!  ã                   óÐ   • S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJ	r	J
r
Jr  S rS r\" \" S5      5      rS	rS
 rSS jr " S S\5      r " S S\5      r " S S\	5      rS rg)z%Numpy pickle compatibility functions.é    N)ÚBytesIOé   )Ú_ZFILE_PREFIXÚ	UnpicklerÚ_ensure_native_byte_orderÚ_reconstructc                 ó$   • SR                  U 5      $ )z(Convert an int to an hexadecimal string.z{:#x})Úformat)Úan_ints    ÚW/home/mande/repo/quber/.venv/lib/python3.13/site-packages/joblib/numpy_pickle_compat.pyÚhex_strr      s   € à�>‰>˜&Ó!Ð!ó    c                 óR   • [        U [        5      (       a  U $ U R                  S5      $ )NÚlatin1)Ú
isinstanceÚbytesÚencode)Úss    r   Úasbytesr      s#   € Ü�!”U×ÑØˆØ�8‰8�HÓÐr   l            i   c                 ó€  • U R                  S5        [        [        5      [        -   nU R	                  U5      nU[        [        5      S n[        US5      nU R	                  S5      nUS:w  a  U R                  U5        [        R                  " U R	                  5       SU5      n[        U5      U:X  d
   SU -  5       eU$ )zÖRead the z-file and return the content as a string.

Z-files are raw data compressed with zlib used internally by joblib
for persistence. Backward compatibility is not guaranteed. Do not
use for external purposes.
r   Né   r   ó    é   zIIncorrect data length while decompressing %s.The file could be corrupted.)ÚseekÚlenr   Ú_MAX_LENÚreadÚintÚzlibÚ
decompress)Úfile_handleÚheader_lengthÚlengthÚ	next_byteÚdatas        r   Ú
read_zfiler&       sÂ   € ð ×Ñ�QÔÜœÓ&¬Ñ1€MØ×Ñ˜mÓ,€FØ”CœÓ&Ð(Ð)€FÜ�˜‹_€Fð × Ñ  Ó#€IØ�DÓð 	×Ñ˜Ô'ô �?Š?˜;×+Ñ+Ó-¨r°6Ó:€DÜˆt‹9˜Óð ð	'Ø)4ñ	5óÐð €Kr   c                 ó  • U R                  [        5        [        [        U5      5      nU R                  [	        UR                  [        5      5      5        U R                  [        R                  " [	        U5      U5      5        g)zÐWrite the data in the given file as a Z-file.

Z-files are raw data compressed with zlib used internally by joblib
for persistence. Backward compatibility is not guaranteed. Do not
use for external purposes.
N)	Úwriter   r   r   r   Úljustr   r   Úcompress)r!   r%   r*   r#   s       r   Úwrite_zfiler+   B   sY   € ð ×Ñ”mÔ$Ü”S˜“YÓ€Fà×Ñ”g˜fŸl™l¬8Ó4Ó5Ô6Ø×Ñ”d—m’m¤G¨D£M°8Ó<Õ=r   c                   ó(   • \ rS rSrSrSS jrS rSrg)ÚNDArrayWrapperéT   z­An object to be persisted instead of numpy arrays.

The only thing this object does, is to carry the filename in which
the array has been persisted, and the array subclass.
c                 ó(   • Xl         X l        X0l        g©z4Constructor. Store the useful information for later.N)ÚfilenameÚsubclassÚ
allow_mmap)Úselfr1   r2   r3   s       r   Ú__init__ÚNDArrayWrapper.__init__[   s   € à ŒØ ŒØ$�r   c                 óh  • [         R                  R                  UR                  U R                  5      n[        U SS5      n0 nU(       a  UR                  US'   S[        R                  " UR                  R                  5      R                  ;   a  SUS'   UR                  R                  " U40 UD6n[        U5      n[        US5      (       ab  U R                  UR                  R                  UR                  R                   4;  a(  [#        U R                  SS5      nUR%                  U5      $ U$ )zReconstruct the array.r3   TÚ	mmap_modeÚallow_pickleÚ__array_prepare__)r   Úb)ÚosÚpathÚjoinÚ_dirnamer1   Úgetattrr8   ÚinspectÚ	signatureÚnpÚloadÚ
parametersr   Úhasattrr2   ÚndarrayÚmemmapr   r:   )r4   Ú	unpicklerr1   r3   ÚkwargsÚarrayÚ	new_arrays          r   r   ÚNDArrayWrapper.reada   s  € ä—7‘7—<‘< 	× 2Ñ 2°D·M±MÓBˆô ˜T <°Ó6ˆ
ØˆÞØ"+×"5Ñ"5ˆF�;ÑØœW×.Ò.¨y¯|©|×/@Ñ/@ÓA×LÑLÓLð &*ˆF�>Ñ"Ø—‘×!Ò! (Ñ5¨fÑ5ˆô *¨%Ó0ˆô �5Ð-×.Ñ.°4·=±=Ø�L‰L× Ñ Ø�L‰L×ÑðI
ó 4
ô
 % T§]¡]°D¸#Ó>ˆIØ×.Ñ.¨uÓ5Ð5àˆLr   )r3   r1   r2   N)T©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r5   r   Ú__static_attributes__© r   r   r-   r-   T   s   † ñô%õr   r-   c                   ó$   • \ rS rSrSrS rS rSrg)ÚZNDArrayWrapperé�   a(  An object to be persisted instead of numpy arrays.

This object store the Zfile filename in which
the data array has been persisted, and the meta information to
retrieve it.
The reason that we store the raw buffer data of the array and
the meta information, rather than array representation routine
(tobytes) is that it enables us to use completely the strided
model to avoid memory copies (a and a.T store as fast). In
addition saving the heavy information separately can avoid
creating large temporary buffers when unpickling data with
large arrays.
c                 ó(   • Xl         X0l        X l        gr0   )r1   ÚstateÚ	init_args)r4   r1   r[   rZ   s       r   r5   ÚZNDArrayWrapper.__init__�   s   € à ŒØŒ
Ø"�r   c                 ó6  • [         R                  R                  UR                  U R                  5      n[        U R                  6 n[        US5       n[        U5      nSSS5        U R                  W4-   nUR                  U5        U$ ! , (       d  f       N1= f)z?Reconstruct the array from the meta-information and the z-file.ÚrbN)r<   r=   r>   r?   r1   r   r[   Úopenr&   rZ   Ú__setstate__)r4   rI   r1   rK   Úfr%   rZ   s          r   r   ÚZNDArrayWrapper.read–   sv   € ô —7‘7—<‘< 	× 2Ñ 2°D·M±MÓBˆÜ˜dŸn™nÐ-ˆÜ�(˜DÔ! QÜ˜a“=ˆD÷ "à—
‘
˜d˜WÑ$ˆØ×Ñ˜5Ô!Øˆ÷	 "Õ!ús   ÁB
Â

B)r1   r[   rZ   NrN   rU   r   r   rW   rW   �   s   † ñò#õ
r   rW   c                   ó†   • \ rS rSrSr\R                  R                  5       rS	S jrS r	S r
\
\\R                  S   '   Srg)
ÚZipNumpyUnpickleré£   z:A subclass of the Unpickler to unpickle our numpy pickles.Nc                 óF  • [         R                  R                  U5      U l        [         R                  R	                  U5      U l        X0l        U R                  U5      U l        [        R                  " X R                  5         SSKnX@l        g! [         a    Sn Nf = f)zConstructor.r   N)r<   r=   ÚbasenameÚ	_filenameÚdirnamer?   r8   Ú_open_pickler!   r   r5   ÚnumpyÚImportErrorrC   )r4   r1   r!   r8   rC   s        r   r5   ÚZipNumpyUnpickler.__init__¨   s}   € äŸ™×)Ñ)¨(Ó3ˆŒÜŸ™Ÿ™¨Ó1ˆŒØ"ŒØ×,Ñ,¨[Ó9ˆÔÜ×Ò˜4×!1Ñ!1Ô2ð	Ûð �øô ó 	ØŠBð	ús   ÂB ÂB ÂB c                 ó*   • [        [        U5      5      $ ©N)r   r&   )r4   r!   s     r   rj   ÚZipNumpyUnpickler._open_pickleµ   s   € Ü”z +Ó.Ó/Ð/r   c                 ó2  • [         R                  " U 5        [        U R                  S   [        5      (       a_  U R
                  c  [        S5      eU R                  R                  5       nUR                  U 5      nU R                  R                  U5        gg)zÂSet the state of a newly created object.

We capture it to replace our place-holder objects,
NDArrayWrapper, by the array we are interested in. We
replace them directly in the stack of pickler.
éÿÿÿÿNz@Trying to unpickle an ndarray, but numpy didn't import correctly)
r   Ú
load_buildr   Ústackr-   rC   rl   Úpopr   Úappend)r4   Únd_array_wrapperrK   s      r   rs   ÚZipNumpyUnpickler.load_build¸   sz   € ô 	×Ò˜TÔ"Ü�d—j‘j ‘n¤n×5Ñ5Ø�w‰w‰Ü!ØVóð ð  $Ÿz™zŸ~™~Ó/ÐØ$×)Ñ)¨$Ó/ˆEØ�J‰J×Ñ˜eÕ$ð 6r   r   )r?   rh   r!   r8   rC   ro   )rO   rP   rQ   rR   rS   r   ÚdispatchÚcopyr5   rj   rs   ÚpickleÚBUILDrT   rU   r   r   rd   rd   £   s<   † ÙDà×!Ñ!×&Ñ&Ó(€Hôò0ò%ð" !+€HˆV�\‰\˜!‰_Ôr   rd   c                 óŒ  • [        U S5       n[        XS9n UR                  5       n [        US5      (       a  UR                  R                  5         UsSSS5        $ ! [         a  n[	        S5      nXEl        UeSnAff = f! [        US5      (       a  UR                  R                  5         f f = f! , (       d  f       g= f)aÞ  Reconstruct a Python object from a file persisted with joblib.dump.

This function ensures the compatibility with joblib old persistence format
(<= 0.9.3).

Parameters
----------
filename: string
    The name of the file from which to load the object

Returns
-------
result: any Python object
    The object stored in the file.

See Also
--------
joblib.dump : function to save an object

Notes
-----

This function can load numpy array files saved separately during the
dump.
r^   )r!   zyYou may be trying to read with python 3 a joblib pickle generated with python 2. This feature is not supported by joblib.Nr!   )	r_   rd   rD   ÚUnicodeDecodeErrorÚ
ValueErrorÚ	__cause__rF   r!   Úclose)r1   r!   rI   ÚobjÚexcÚnew_excs         r   Úload_compatibilityr…   Ì   s·   € ô4 
ˆh˜Ô	 ô
 & hÑHˆ	ð	.Ø—.‘.Ó"‰Cô �y -×0Ñ0Ø×%Ñ%×+Ñ+Ô-Ø÷) 
Ñ	øô "ó 	ä ð;óˆGð
 !$ÔØˆMûð	ûô �y -×0Ñ0Ø×%Ñ%×+Ñ+Õ-ð 1ú÷% 
Õ	ús9   �
B5˜A©,B5Á
BÁ)A<Á<BÂBÂ.B2Â2B5Â5
C)r   )rS   rA   r<   r{   r   Úior   Únumpy_pickle_utilsr   r   r   r   r   r   r   r   Ú_CHUNK_SIZEr&   r+   Úobjectr-   rW   rd   r…   rU   r   r   Ú<module>rŠ      sw   ðÙ +ã Û 	Û Û Ý ÷ó ò"ò
ñ ‰w�u‹~Ó€Ø€òôD>ô$*�Vô *ôZ�nô ôD&+˜	ô &+óR.r   