U
    k/eP                  _   @   s  d dl Z d dlZd dlZd dlZd dlZdd Zejddd Z	dd Z
d	d
 Zdd Zdd Zdd Zejdejejejejejejejejejejejejejejejejej ej!ej"ej#ej$ej%ej&ej'ej(ej)ej*ej+ej,ej-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;ej<ej=ej>ej?ej@ejAejBejCejDejEejFejGejHejIejJejKejLejMejNejOejPejQejRejSejTejUejVejWejXejYejZej[ej\ej]ej^ej_ej`ejaejbejcejdejeejfejgjhejgjiejjejkejlg\dd ZmdS )    Nc                  C   s(   t  } tjtj| dds$td S )NZarrowzapi.h)paZget_includeospathexistsjoinAssertionError)Zinclude_dir r   ;/tmp/pip-unpacked-wheel-seu8352k/pyarrow/tests/test_misc.pytest_get_include   s    r
   zsys.platform != "win32"c                   C   s   t dd t D std S )Nc                 s   s$   | ]}t jt j|d V  qdS )z	arrow.libN)r   r   r   r   ).0	directoryr   r   r	   	<genexpr>"   s   z.test_get_library_dirs_win32.<locals>.<genexpr>)anyr   Zget_library_dirsr   r   r   r   r	   test_get_library_dirs_win32    s    r   c               	   C   sL   t  } | dkstz&t | d  t  | d ks8tW 5 t |  X d S Nr      )r   	cpu_countr   Zset_cpu_countnr   r   r	   test_cpu_count&   s    r   c               	   C   sL   t  } | dkstz&t | d  t  | d ks8tW 5 t |  X d S r   )r   Zio_thread_countr   Zset_io_thread_countr   r   r   r	   test_io_thread_count0   s    r   c                     sr   d  fdd} | d\}}|  dks,t|dks8tdD ]0}| |\}}|  dks\td|  ks<tq<d S )	NzOif 1:
        import pyarrow as pa
        print(pa.io_thread_count())
        c                    sF   t j }| |d< tjtjd g|dd}|  |j	 |j
	 fS )NZARROW_IO_THREADS-cT)envcapture_output)r   environcopy
subprocessrunsys
executablecheck_returncodestdoutdecodestderr)env_varr   rescoder   r	   run_with_env_varB   s    
z6test_env_var_io_thread_count.<locals>.run_with_env_varZ17 )z-1z8z;ARROW_IO_THREADS does not contain a valid number of threads)stripr   )r(   outerrvr   r&   r	   test_env_var_io_thread_count:   s    r0   c                   C   sj   t tjtjstt tjtjs$tt tjts4tt tj	tsDttjj
tjksVttjjdksftd S )N)debugreleaseZ
minsizerelZrelwithdebinfo)
isinstancer   Zcpp_build_infoZ	BuildInfor   Zcpp_version_infoVersionInfoZcpp_versionstr__version__version_infoZ
build_typer   r   r   r	   test_build_infoU   s    r8   c                  C   s|   t  } t| t jstd}| j|ks*t| j|ks8t| jdkrxtj	 }d|d< d| jd}t
jtjd|g|d d S )N)noneZsse4_2ZavxZavx2Zavx512r9   ZARROW_USER_SIMD_LEVELzif 1:
            import pyarrow as pa

            info = pa.runtime_info()
            assert info.simd_level == 'none', info.simd_level
            assert info.detected_simd_level == z6,                info.detected_simd_level
            r   )r   )r   Zruntime_infor3   ZRuntimeInfor   Z
simd_levelZdetected_simd_levelr   r   r   r   
check_callr   r   )infoZpossible_simd_levelsr   r'   r   r   r	   test_runtime_infob   s    

r<   klassc              	   C   s2   d}t jt|j| jdd |   W 5 Q R X d S )Nz9Do not call {cls}'s constructor directly, use .* instead.)cls)match)pytestZraises	TypeErrorformat__name__)r=   msgr   r   r	   &test_extension_type_constructor_errorsw   s    `rE   )nr   r   r   r@   Zpyarrowr   r
   markZskipifr   r   r   r0   r8   r<   ZparametrizeZFieldZSchemaZChunkedArrayZRecordBatchZTableZBufferArrayZTensorZDataTypeZListTypeZLargeListTypeZFixedSizeListTypeZ	UnionTypeZSparseUnionTypeZDenseUnionTypeZ
StructTypeZ
Time32TypeZ
Time64TypeZTimestampTypeZDecimal128TypeZDecimal256TypeZDictionaryTypeZFixedSizeBinaryTypeZ	NullArrayZNumericArrayZIntegerArrayZFloatingPointArrayZBooleanArrayZ	Int8ArrayZ
Int16ArrayZ
Int32ArrayZ
Int64ArrayZ
UInt8ArrayZUInt16ArrayZUInt32ArrayZUInt64ArrayZ	ListArrayZLargeListArrayZMapArrayZFixedSizeListArrayZ
UnionArrayZBinaryArrayZStringArrayZFixedSizeBinaryArrayZDictionaryArrayZDate32ArrayZDate64ArrayZTimestampArrayZTime32ArrayZTime64ArrayZDurationArrayZDecimal128ArrayZDecimal256ArrayZStructArrayZRunEndEncodedArrayZScalarZBooleanScalarZ
Int8ScalarZInt16ScalarZInt32ScalarZInt64ScalarZUInt8ScalarZUInt16ScalarZUInt32ScalarZUInt64ScalarZHalfFloatScalarZFloatScalarZDoubleScalarZDecimal128ScalarZDecimal256ScalarZDate32ScalarZDate64ScalarZTime32ScalarZTime64ScalarZTimestampScalarZDurationScalarZStringScalarZBinaryScalarZFixedSizeBinaryScalarZ
ListScalarZLargeListScalarZ	MapScalarZFixedSizeListScalarZUnionScalarZStructScalarZDictionaryScalarZRunEndEncodedScalarZipcMessageZMessageReaderZ
MemoryPoolZLoggingMemoryPoolZProxyMemoryPoolrE   r   r   r   r	   <module>   s   



^