o
    tBh,                  
   @   s  d Z ddlZddlZddlZddlZddlZddlZddl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ZzddlZW n eyM   dZY nw ddlZddlmZmZmZmZ ddlmZmZ ddlmZmZmZmZ ddlm Z m!Z! ddl"m#Z# dd	l$m%Z% dd
l$m&Z& ddl$m'Z' ddl$m(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z. g Z/dZ0e/1e0 e2Z3e/1e3 e4dZ5e/1e5 e6dZ7e/1e7 e8dZ9e/1e9 e:dZ;e/1e; e<dZ=e/1e= dZ>e/1e> g Z?e/1e? i Z@e/1e@ eAZBe/1eB dd ZCG dd dZDG dd deEZFe/1eC e/1eD e/1eF eD ZGe/1eG eF ZHe/1eH edddgede/dd ZIdd ZJedddeK gdd  ZLeedg d!d"d# ZMed$d% ZNed&d' ZOed(d) ZPed*d+ ZQed,d- ZReed.g d/d0d1 ZSeeedd2d3gd4d5 ZTed6d7 ZUd8d9 ZVed:d; ZWed<d= ZXed>d?d@gdAdB ZYedCdDdEdFZdGfdHdIZdGfgdJdK Z[edLdMdNgdOdP Z\eedg dQedRe*dSdT Z]dUdV Z^dWdX Z_edYdZe_fd[e^fgd\d] Z`ed^g d_d`da Zaedbdc Zbeddde Zcedfdg Zdedhdi Zeedjdk ZfedldmdndoZegddpdp hdq gdrdsgdtedug dvdwdx Ziedydddzd{di gd|d} Zjed~g ddd Zkedddi gdd ZledurG dd dejmZndd ZoG dd dZpedd Zqdd Zredd Zsedd Ztedd Zuedd Zvdd Zwedddi gdd Zxdd ZyG dd de,ZzG dd de,Z{dd Z|edd Z}edd Z~dS )z@Test the numpy pickler as a replacement of the standard pickler.    N)closing)np
with_numpywith_lz4without_lz4)with_memory_profilermemory_used)parametrizeraisesSkipTestwarns)numpy_pickleregister_compressor)data)_IO_BUFFER_SIZE)_detect_compressor)#_is_numpy_array_byte_order_mismatch)_ensure_native_byte_order)_COMPRESSORS_LZ4_PREFIXCompressorWrapperLZ4_NOT_INSTALLED_ERRORBinaryZlibFile    c                 c   s    | V  d S Nr   )xr   r   t/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/joblib/test/test_numpy_pickle.py	_functionH   s   
r   c                   @      e Zd Zdd ZdS )_classc                 C      d S r   r   selfr   r   r   _methodM      z_class._methodN__name__
__module____qualname__r$   r   r   r   r   r    L       r    c                   @   r   )	_newclassc                 C   r!   r   r   r"   r   r   r   r$   R   r%   z_newclass._methodNr&   r   r   r   r   r+   Q   r*   r+   compressmemberc                 C   sH   |  dj}tj|||d t|}|t|kr ||ks"J d S d S )Ntest.pklr,   )joinstrpathr   dumploadcopydeepcopy)tmpdirr,   r-   filename_memberr   r   r   test_standard_typesb   s   
r9   c                   C   s<   t t tdt  W d    d S 1 sw   Y  d S )Nfoo)r
   
ValueErrorr   r2   dictr   r   r   r   test_value_erroro   s   
"r=   wrong_compress
   c                 C   sP   d | }tt}tjdd| d W d    n1 sw   Y  || d S )Nz%Non valid compress level given: "{0}"dummyr:   r/   )formatr
   r;   r   r2   match)r>   exception_msgexcinfor   r   r   test_compress_level_erroru   s   
rF   )FTr      zlibc                 C   s  |  dj}tjd}|d}t|f|jf||f|||gfD ]E\}}tj	|||d}t
|dks5J |d |ks=J tj|d sGJ t|}|D ]
}	t|	tjsXJ qNtjt|t| q!ttdtj|d dd	tjd
fD ]3}tj	|||d}t
|dksJ t|}t|tjurt|drt|t|sJ tj|| q{t }tj	|||d}t
|dksJ t|}
t|
t|sJ tj|
j|j tj|
j|j tj|
j|j d S )Nr.   r   r@      r/   r   r@   mmapw+   )modeshapedtype__array_prepare__)r0   r1   r   randomRandomStaterandom_sample	enumerateTr   r2   lenospathexistsr3   
isinstancendarraytestingassert_array_equalarraymatrixzerosmemmapfloattypehasattrComplexTestObjectarray_float	array_int	array_obj)r6   r,   r7   rndaindexobj	filenamesobj_item
obj_loadedr   r   r   test_numpy_persistence   sB   
(



rr   c                 C   sL   t jtd t jd}| dj}tj||dd t|}t j	
|| d S )Nd   rP   r.   Tr/   )r   onesr   uint8r0   r1   r   r2   r3   r]   r^   )r6   	big_arrayr7   arr_reloadedr   r   r   2test_numpy_persistence_bufferred_array_compression   s
   
ry   c                 C   s  t jd}|d}| dj}t|| tj|dd}t	|t j
s&J | dj}t }t|| tj|dd}t	|t|sEJ t	|jt j
sNJ |jjjrUJ t	|jt j
s^J |jjjreJ t	|jt j
rnJ t j|j|j t j|j|j t j|j|j tj|dd}|jjjsJ d|jdd< |jjjsJ d|jdd< tj|dd}t j|j|j t j|j|j tj|d	d |jjjsJ |jjdksJ |jjjsJ |jjdksJ d S )
Nr   r@   z	test1.pklr	mmap_modez	test2.pklr+g      $@rL   )r   rR   rS   rT   r0   r1   r   r2   r3   r[   rb   rf   rd   rg   flags	writeablerh   ri   r]   r^   rN   )r6   rj   rk   r7   brm   rq   obj_reloadedr   r   r   test_memmap_persistence   sT   





r   c                 C   s~   t jd}|d}t jddgtd}||f}| dj}t	|| tj
|dd\}}t|t js5J t|t jr=J d S )	Nr   r@   r   r   rt   r.   rz   r{   )r   rR   rS   rT   r_   objectr0   r1   r   r2   r3   r[   rb   )r6   rj   rk   r   	constructr7   a_cloneb_cloner   r   r   $test_memmap_persistence_mixed_dtypes   s   
r   c                 C   s`   t jd}|d}t j|d}| dj}t	|| tj
|dd}t|t jjs.J d S )Nr   r@   g      ?r.   rz   r{   )r   rR   rS   rT   mamasked_greaterr0   r1   r   r2   r3   r[   masked_array)r6   rj   rk   r7   r   r   r   r   test_masked_array_persistence  s   
r   c                 C   s   t jd}|d}| dj}tj||dd tt	}tj
|dd W d    n1 s/w   Y  t|dks<J t|d jd|dd	 ksLJ d S )
Nr   r@   r.   r   r/   r}   r{   ztmmap_mode "%(mmap_mode)s" is not compatible with compressed file %(filename)s. "%(mmap_mode)s" flag will be ignored.)r7   r|   )r   rR   rS   rT   r0   r1   r   r2   r   UserWarningr3   rW   strmessage)r6   rj   rk   this_filenamewarninfor   r   r   test_compress_mmap_mode_warning  s   

r   
cache_size)Nr   r@   c                 C   s   |  dj}tjd}|d}td td }t	j
|||d W d    n1 s-w   Y  |d ur8dnd}t||ksBJ |D ]}|jtksMJ t|jd|ksYJ qDd S )Nr.   r   rI   always)r   r   zzPlease do not set 'cache_size' in joblib.dump, this parameter has no effect and will be removed. You used 'cache_size={0}')r0   r1   r   rR   rS   rT   warningssimplefilterr   r   r2   rW   categoryDeprecationWarningr   r   rB   )r6   r   r7   rj   rk   r   expected_nb_warningswr   r   r   test_cache_size_warning!  s    



r   TFc                 C   s   |  dj}td}tjdtd tjd}t|}t|}||||fD ]7}|jd }|ttj	
dd }	ttj||	|d}
td	 }|
|ksLJ ttj|	}
d
t }|
|| k s^J q'd S )Nr.   r@   r@   rs   g    .ArO   rP   r     r/   g0@    )r0   r1   r   ru   intrv   r`   nbytesr   rR   randintr   r   r2   r   r3   )r6   r,   r7   small_arrayrw   small_matrix
big_matrixrm   sizeobj_filenamemem_usedwrite_buf_sizeread_buf_sizer   r   r   test_memory_usage6  s"   



r   c                 C   s2  t jdt ddt jdt ddt jdt ddt jdt ddt jdddd	d
gddt jdt jd t jg dt ddt jg dt dddg	}| dj}t	j
||dd}t|dkshJ t	|}t||D ]$\}}t|t jrt|}|j|jksJ t j|| qr||ksJ qrd S )N   <i8rt   >i8<f8>f8r   abcrJ   rk   r   O   r   r   rJ      C'est l'été !ztemp.pkl.gzr/   )r   arangerP   r_   rv   tobytesr`   r0   r1   r   r2   rW   r3   zipr[   r\   r   r]   assert_equal)r6   expected_listfnamedumped_filenamesresult_listresultexpectedr   r   r   $test_compressed_pickle_dump_and_loadS  s*   
r   c              
   C   s@  t d| }t|d}ddd}|dd}||d}||krztd}td tjd	d
dd t	
| }W d   n1 sDw   Y  tj| }	d|	v sWd|	v rYdnd}
t||
kscJ |D ]}|jtksnJ t|jd| kszJ qet||D ]$\}}t|tjrt|}|j|jksJ tj|| q||ksJ qW dS  ty } z?|dkrt|tsJ d}|t|v sJ n| drtj d rt|tsJ t!t|v sJ n W Y d}~dS W Y d}~dS d}~ww z	t	
|  t"d ty } zd|}|t|j v sJ W Y d}~dS d}~ww )zHelper function to test joblib pickle content.

    Note: currently only pickles containing an iterable are supported
    by this function.
    z.+py(\d)(\d).+r   rJ   rG   )rJ   rG   rM   Nr   ignorenumpyz"The compiler package is deprecated)moduler   z_0.9z_0.8.4r   zkThe file '{0}' has been generated with a joblib version less than 0.10. Please regenerate this pickle file.zPYou may be trying to read with python 3 a joblib pickle generated with python 2..lz4z>Numpy pickle loading should have raised a ValueError exceptionz unsupported pickle protocol: {0})#rerC   r   groupgetr   r   r   filterwarningsr   r3   rX   rY   basenamerW   r   r   r   r   rB   r   r[   r   r\   r   rP   r]   r   	Exceptionr;   endswithr   argsr   AssertionError)r7   r   version_matchpy_version_used_for_writing%py_version_to_default_pickle_protocolpickle_reading_protocolpickle_writing_protocolr   r   filename_baser   r   r   r   excr   er   r   r   _check_picklep  sx   




"r   c               	      s   t jdt ddt jdt ddt jdddddgd	dt jd
t jd t jg dt dddg} tj	tj
tjd td urJ d7   fddtD }|D ]}t||  qYd S )Nr   r   rt   r   r   r   rJ   r   r   r   r   r   ).pkl.gzz.gzip.bz2lz4).xz.lzmac                    s0   g | ] t  fd dD rtj qS )c                 3   s    | ]}  |V  qd S r   )r   ).0extfnr   r   	<genexpr>  s    zGtest_joblib_pickle_across_python_versions.<locals>.<listcomp>.<genexpr>)anyrX   rY   r0   )r   pickle_extensionstest_data_dirr   r   
<listcomp>  s    z=test_joblib_pickle_across_python_versions.<locals>.<listcomp>)r   r   rP   r_   rv   r   r`   rX   rY   dirnameabspathr   __file__lzmalistdirr   )r   pickle_filenamesr   r   r   r   )test_joblib_pickle_across_python_versions  s"   r   c                  C   s\  t jddgddgdt jdt ddt jdt ddg} | D ]5}tjd	kr.t|r-J nt|s4J t|}|jjrM|jj	 D ]	}|d
 jdk qBq |jjdksUJ q t jddgddgdt jdt ddt jdt ddg}|D ]5}tjdkrt|rJ nt|sJ t|}|jjr|jj	 D ]	}|d
 jdk qqv|jjdksJ qvd S )N)r   g       @)rG   g      @) r   )r   r   rt   rG   r   r   bigr   =)r   r   )r   r   r   r   little)
r   r_   r   rP   sys	byteorderr   r   fieldsvalues)	be_arraysr_   	convertedf	le_arraysr   r   r   .test_numpy_array_byte_order_mismatch_detection  sB   



r   compress_tuple)rH   rG   gziprG   c                 C   s`   |  dj}tjd||d t|d}t||d ksJ W d    d S 1 s)w   Y  d S )Nr.   rA   r/   rbr   r0   r1   r   r2   openr   )r6   r   r7   r   r   r   r   test_compress_tuple_argument  s   "r  zcompress_tuple,message))rH   rG   extraz9Compress argument tuple should contain exactly 2 elements)wrongrG   z(Non valid compression method given: "{}"r  )rH   r  z$Non valid compress level given: "{}"c                 C   sR   |  dj}tt}tjd||d W d    n1 sw   Y  || d S )Nr.   rA   r/   )r0   r1   r
   r;   r   r2   rC   )r6   r   r   r7   rE   r   r   r   &test_compress_tuple_argument_exception  s
   
r  compress_stringrH   r   c                 C   s\   |  dj}tjd||d t|d}t||ksJ W d    d S 1 s'w   Y  d S )Nr.   rA   r/   r   r   )r6   r  r7   r   r   r   r   test_compress_string_argument  s   "r  )r   rG      cmethodc           	   	   C   s  |  dj}tjdddtddddg d	i d
df}|dv r(td u r(td n|dkr6tj	d
 r6td |d | }|D ]K}t
j||||fd t|d}t||ksXJ W d    n1 sbw   Y  t
|}t|t|suJ t|tjrtj|| q>||ksJ q>d S )Nr.   )rs   rs   f8r   r@   r   r   )rk   rJ   r   r   g      ?r   xzzlzma is support not availabler   zlz4 is not installed..r/   r   )r0   r1   r   ru   ranger   pytestskipr   r   r   r2   r   r   r3   r[   rd   r\   r]   r^   )	r6   r,   r  r7   objectsdump_filenamerm   r   r   r   r   r   test_joblib_compression_formats  s*   

r  c                 C   sr   t t| d}| }W d   n1 sw   Y  t|d}|| W d   dS 1 s2w   Y  dS )zDecompress a gzip file.r   Nwb)r   r   GzipFilereadr   writesource_filenametarget_filenamefobufr   r   r   _gzip_file_decompress?  s   
"r  c                 C   sr   t | d}t| }W d   n1 sw   Y  t |d}|| W d   dS 1 s2w   Y  dS )zDecompress a zlib file.r   Nr  )r   rH   
decompressr  r  r  r   r   r   _zlib_file_decompressH  s   "r  zextension,decompress.zr   c                 C   sH   d}|  dj}|| }t|| ||| t|}||ks"J d S )Nza string to persistr.   )r0   r1   r   r2   r3   )r6   	extensionr  rm   filename_rawfilename_compressedr   r   r   r   'test_load_externally_decompressed_filesQ  s   

r#  zextension,cmethod))r  rH   )r   r   )r   bz2)r   r   )r   r  )r   not-compressed)r   r%  c                 C   s   |dv rt d u rtd | dj}d}|| }t|| t|d}t||ks-J W d    n1 s7w   Y  t	|}t
|t|sJJ ||ksPJ d S )Nr
  zlzma is missingr.   zobject to dumpr   )r   r  r  r0   r1   r   r2   r   r   r3   r[   rd   )r6   r   r  r7   rm   
dump_fnamer   r   r   r   r   %test_compression_using_file_extensionf  s   

r'  c           	   
   C   s@  t jddt g dg}tjtjg}td ur|tjg7 }| 	dj
}|D ]w}|D ]r}||d}t|| W d    n1 sBw   Y  ||d}t|}W d    n1 s\w   Y  t|d}t|}W d    n1 svw   Y  t|t jrt j|| t j|| q*||ksJ ||ksJ q*q&d S )Nr   	some datar   r.   r  r   )r   rR   r`   r$  BZ2Filer   r  r   LZMAFiler0   r1   r   r2   r3   r   r[   r\   r]   r^   )	r6   objsfobjsr7   rm   fobjr   r   obj_reloaded_2r   r   r   test_file_handle_persistence  s4   
r/  c                  C   sp   t jddt g dg} | D ]%}t }t|| t|}t|t j	r/t j
|| q||ks5J qd S )Nr   r(  r   )r   rR   r`   ioBytesIOr   r2   r3   r[   r\   r]   r^   )r+  rm   r   r   r   r   r   test_in_memory_persistence  s   

r2  c                 C   s   t jd}| dj}t|d}t|| W d    n1 s"w   Y  t|d}tj|dd}W d    n1 s>w   Y  t j	|| d S )Nr   r.   r  r   r}   r{   )
r   rR   r0   r1   r   r   r2   r3   r]   r^   )r6   rm   r7   r   r   r   r   r   !test_file_handle_persistence_mmap  s   r3  c              	   C   s   t jd}| dj}t|d}tj||dd W d    n1 s$w   Y  tt	|d<}t
t}tj|dd W d    n1 sHw   Y  t|d	ksUJ t|d
 jd|dd kseJ W d    d S 1 spw   Y  d S )Nr   r.   r  r   r/   r   r}   r{   r   r   zP"%(fileobj)r" is not a raw file, mmap_mode "%(mmap_mode)s" flag will be ignored.)fileobjr|   )r   rR   r0   r1   r   r   r2   r   r   r  r   r   r3   rW   r   r   )r6   rm   r7   r   r   r   r   r   ,test_file_handle_persistence_compressed_mmap  s    

"r5  c                  C   s   t jd} t }t| | tt}tj|dd W d    n1 s&w   Y  t	|dks3J t
|d jdddi ksBJ d S )Nr   r}   r{   r   r   zuIn memory persistence is not compatible with mmap_mode "%(mmap_mode)s" flag passed. mmap_mode option will be ignored.r|   )r   rR   r0  r1  r   r2   r   r   r3   rW   r   r   )rm   r  r   r   r   r   +test_file_handle_persistence_in_memory_mmap  s   
r6  r   s   a little data as bytes.i'  z{}r   zlatin-1za little data as bytes.za large data as bytes.)idscompress_level)r   rG   	   c              
   C   s  |  dj}t|d}t|d|dO}| sJ || | | ks)J ttj	 |
  W d    n1 s=w   Y  ttj	 |  W d    n1 sVw   Y  W d    n1 sew   Y  |jsoJ tt |  W d    n1 sw   Y  W d    n1 sw   Y  t|dk}t|R}| sJ | sJ | | ksJ | |ksJ ttj	 |  W d    n1 sw   Y  | sJ |d | dksJ W d    n1 sw   Y  |jsJ W d    n	1 s
w   Y  t|d|d}| sJ || W d    n	1 s.w   Y  t|d}| |ksBJ | sIJ W d    n	1 sTw   Y  t|d|d}| sgJ || |  t|d}| |ks~J |  d S )Nr.   r  compresslevelr   r   )r0   r1   r   r   writabler  filenor
   r0  UnsupportedOperation_check_can_read_check_can_seekclosedr;   _check_not_closedreadableseekabler  _check_can_writeseektellclose)r6   r   r8  r7   r   fzr   r   r   test_binary_zlibfile  sp   












rJ  	bad_value   rk   c                 C   s`   |  dj}tt}t|d|d W d    n1 sw   Y  td|}|| d S )Nr.   r  r:  zS'compresslevel' must be an integer between 1 and 9. You provided 'compresslevel={}')	r0   r1   r
   r;   r   r   escaperB   rC   )r6   rK  r7   rE   patternr   r   r   +test_binary_zlibfile_bad_compression_levels  s   
rO  bad_mode)rk   r   rz   r   r   rJ   c                 C   sL   |  dj}tt}t|| W d    n1 sw   Y  |d d S )Nr.   zInvalid mode)r0   r1   r
   r;   r   rC   )r6   rP  r7   rE   r   r   r   "test_binary_zlibfile_invalid_modes%  s
   
rQ  bad_filec                 C   s@   t t}t| d W d    n1 sw   Y  |d d S )Nr   z1filename must be a str or bytes object, or a file)r
   	TypeErrorr   rC   )rR  rE   r   r   r   *test_binary_zlibfile_invalid_filename_type-  s   
rT  c                   @   r   )SubArrayc                 C   s   t t| ffS r   )_load_sub_arrayr   asarrayr"   r   r   r   
__reduce__:  s   zSubArray.__reduce__N)r'   r(   r)   rX  r   r   r   r   rU  8      rU  c                 C   s   t | j}| |d d < |S r   )rU  rO   )arrdr   r   r   rV  =  s   
rV  c                   @   s   e Zd ZdZdd ZdS )rf   z7A complex object containing numpy arrays as attributes.c                 C   s8   t jddd| _t jddd| _t jg ddd| _d S )Nrs   float64rt   int32)rk   r@   g      4@r   )r   r   rg   ru   rh   r_   ri   r"   r   r   r   __init__E  s   zComplexTestObject.__init__N)r'   r(   r)   __doc__r^  r   r   r   r   rf   B  s    rf   c                 C   sJ   |  dj}td}t|| t|}t|tsJ tj	|| d S )Nr.   )r@   )
r0   r1   rU  r   r2   r3   r[   r   r]   r^   )r6   r7   rk   cr   r   r   test_numpy_subclassK  s   
ra  c                 C   s~   zddl m} W n
 ty   Y d S w | dj}d}t||| t||ks,J t|| t|||ks=J d S )Nr   )Pathr.   {   )pathlibrb  ImportErrorr0   r1   r   r2   r3   )r6   rb  r7   valuer   r   r   test_pathlibU  s   rg  c                 C   s   |  dj}tddgddggdd  tjdddd d d dd d f fD ] }|jjr/J |jjr5J t	|| t
|}tj|| q'd S )	Nr.   r   rJ   rG   rM   )r@   2      F)order)r0   r1   r   asfortranarrayru   r~   c_contiguousf_contiguousr   r2   r3   r]   r^   )r6   r7   r_   array_reloadedr   r   r   "test_non_contiguous_array_picklingc  s   "
rp  c                 C   sD   |  dj}td}tj||tjd t|}tj	
|| d S )Nr.   r@   )protocol)r0   r1   r   ra   r   r2   pickleHIGHEST_PROTOCOLr3   r]   r^   )r6   r7   
test_arrayro  r   r   r   test_pickle_highest_protocolt  s
   

ru  c            	      C   s   t d} d}ttjtj}|| |d t|}| \}}|	d}t
| | W d    n1 s:w   Y  |	d}t
|}W d    n1 sTw   Y  t j||  d S )Nr@   )	localhosti90  r   r  r   )r   r   socketAF_INETSOCK_STREAMbindlistencreate_connectionacceptmakefiler   r2   r3   r]   r^   )	rt  _ADDRlistenerclientserverclient_addrsfcfro  r   r   r   test_pickle_in_socket  s   



r  c                 C   s   |  dj}tj}tj|ddtj|ddg}t|| tj	|dd}t
|d tjs.J |d j|ks7J tj|| d S )Nz	test.mmaprv   rt   rz   r{   r   )r0   r1   rK   ALLOCATIONGRANULARITYr   ra   ru   r   r2   r3   r[   rb   offsetr]   r^   )r6   r   r   rm   memmapsr   r   r    test_load_memmap_with_big_offset  s   r  c                    sn   d}dG dd dt j G  fdddt}t||  t| j ks'J t| jks0J t| d S )N	test-nameztest-prefixc                   @      e Zd ZdS )z:test_register_compressor.<locals>.BinaryCompressorTestFileNr'   r(   r)   r   r   r   r   BinaryCompressorTestFile      r  c                       s   e Zd Z fddZdS )z=test_register_compressor.<locals>.BinaryCompressorTestWrapperc                    s   t j|  d d S )Nrm   prefixr   r^  r"   r  compressor_prefixr   r   r^       
zFtest_register_compressor.<locals>.BinaryCompressorTestWrapper.__init__Nr'   r(   r)   r^  r   r  r   r   BinaryCompressorTestWrapper  s    r  )r0  BufferedIOBaser   r   r   fileobj_factoryr  pop)r6   compressor_namer  r   r  r   test_register_compressor  s   r  invalid_namec                 C   s@   t t}t| d  W d    n1 sw   Y  |d d S )Nz"Compressor name should be a string)r
   r;   r   rC   )r  rE   r   r   r   %test_register_compressor_invalid_name  s   
r  c                     sd   G dd d G  fdddt } tt}td|   W d    n1 s&w   Y  |d d S )Nc                   @   r  )zCtest_register_compressor_invalid_fileobj.<locals>.InvalidFileObjectNr  r   r   r   r   InvalidFileObject  r  r  c                       s   e Zd Z fddZdS )zJtest_register_compressor_invalid_fileobj.<locals>.InvalidFileObjectWrapperc                    s   t j|  dd d S Ns   prefixr  r  r"   r  r   r   r^    r  zStest_register_compressor_invalid_fileobj.<locals>.InvalidFileObjectWrapper.__init__Nr  r   r  r   r   InvalidFileObjectWrapper  s    r  invalidzQCompressor 'fileobj_factory' attribute should implement the file object interface)r   r
   r;   r   rC   )r  rE   r   r  r   (test_register_compressor_invalid_fileobj  s   
r  c                   @   r   )AnotherZlibCompressorWrapperc                 C   s   t j| tdd d S r  )r   r^  r   r"   r   r   r   r^    s   z%AnotherZlibCompressorWrapper.__init__Nr  r   r   r   r   r    rY  r  c                   @   r   ) StandardLibGzipCompressorWrapperc                 C   s   t j| tjdd d S r  )r   r^  r   r  r"   r   r   r   r^    s   z)StandardLibGzipCompressorWrapper.__init__Nr  r   r   r   r   r    rY  r  c                  C   s   d} t | t  tt}t | t  W d    n1 sw   Y  |d|  t | t dd | tv s8J t|  jt	j
ksBJ t|  d S )Nr  z#Compressor '{}' already registered.T)force)r   r  r
   r;   r  rC   rB   r   r  r   r  r  )r  rE   r   r   r   +test_register_compressor_already_registered  s    
r  c                 C   s  dd l }d}|tv sJ t| j|jjksJ | dj}d}tj|||d t	|d}|
tttks8J W d    n1 sBw   Y  t||ksPJ t||d  t	|d}|
tttksiJ W d    n1 ssw   Y  t||ksJ d S )Nr   r   r.   	test datar/   r   r   )	lz4.framer   r  frameLZ4FrameFiler0   r1   r   r2   r   r  rW   r   r3   )r6   r   
compressorr   r   r   r   r   r   test_lz4_compression  s    r  c                 C   s   |  dj}d}t}tt}tj||dd W d    n1 s!w   Y  || tt}t||d  W d    n1 sBw   Y  || d S )Nz
test.nolz4r  r   r/   r   )r0   r1   r   r
   r;   r   r2   rC   )r6   r   r   msgrE   r   r   r    test_lz4_compression_without_lz4  s   


r  )r_  r4   rX   rR   r   r0  r   r   r   rH   r$  rr  rw  
contextlibr   rK   r   re  r  joblib.test.commonr   r   r   r   r   r   joblib.testingr	   r
   r   r   joblibr   r   joblib.testr   joblib.numpy_pickle_utilsr   r   r   r   joblib.compressorr   r   r   r   r   typelist_noneappendrd   _typebool_boolr   _intrc   _floatcomplex_complexr   _string_tuple_list_dictrW   _builtinr   r    r   r+   	_instance_objectr9   r=   r<   rF   rr   ry   r   r   r   r   r   r   r   r   r   r   r  rB   r  r  r  r  r  r#  r'  r/  r2  r3  r5  r6  r   encoderJ  rO  rQ  rT  r\   rU  rV  rf   ra  rg  rp  ru  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   sj   	
















	4
	
1



@
 
(




		



 



4
	


	
	





