a
    =_&u                    @   s  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d dlmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZmZ d dlmZ G d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d ej eZ!G d!d" d"ej eZ"G d#d$ d$ej eZ#G d%d& d&e#Z$G d'd( d(e#Z%G d)d* d*e#Z&G d+d, d,e#Z'G d-d. d.ej eZ(G d/d0 d0ej eZ)G d1d2 d2e)Z*G d3d4 d4e)Z+G d5d6 d6ej eZ,G d7d8 d8e,Z-G d9d: d:e,Z.G d;d< d<e,Z/G d=d> d>e,Z0G d?d@ d@e,Z1G dAdB dBe,Z2G dCdD dDe,Z3G dEdF dFe,Z4G dGdH dHe,Z5G dIdJ dJe,Z6G dKdL dLe,Z7G dMdN dNe,Z8G dOdP dPej eZ9G dQdR dRe9eZ:G dSdT dTe:Z;G dUdV dVe:Z<G dWdX dXe9Z=G dYdZ dZe=Z>G d[d\ d\e=Z?G d]d^ d^ej eZ@G d_d` d`e@eZAG dadb dbeAZBG dcdd ddeAZCG dedf dfe@ZDG dgdh dheDZEG didj djeDZFG dkdl dlej eZGG dmdn dneGZHG dodp dpeHZIG dqdr dreHZJG dsdt dteGZKG dudv dveKZLG dwdx dxeKZMG dydz dzej eZNG d{d| d|ej eZOG d}d~ d~ej eZPG dd dePZQG dd dePZRG dd dePZSG dd dePZTG dd dePZUG dd dej eZVG dd deVZWG dd deVZXG dd deVZYG dd deVZZG dd deZ[G dd dej eZ\G dd dej eZ]G dd dej eZ^dd Z_e`dkreaejb ec  ejddd dS )    N)testing)AtomClosedNodeErrorNoSuchNodeError)
byteorders)common)allequal)unittesttest_filename)PyTablesTestCasec                   @   s   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#S )$BasicTestCasezmBasic test for all the supported typecodes present in numpy.

    All of them are included on pytables.

    Fc              	   C   s  |}t jr4tdd td|jj dd td| j td}ztj	|dd	P}|j
}| jr|jjd
kr| }|j |_|}||d|d W d    n1 s0    Y  tj	|dd	}|j
}|j }t jrdt||sdtd td|j td|j td|jj td|j td|j td|jj |jjd
krdtd|jj td|jj | |j|j | |j|jj |jjd
kr| |jjjd n| |jj|jj | |jj|jjjj t|jj }t|jj }|dkr(| ||jj | |tj | jr(| || |j}	| |	jd | |	j|j | |	j|j | |	jd  |jr~|jd }
nd}
| |	j|
 | t|| W d    n1 s0    Y  W t !| nt !| 0 d S )N
<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=%Running test for array with type '%s' endfor class check:.h5wmodeS	somearray
Some arrayrWrite and read arrays differ!Array written shape:Array written itemsize:Array written type:Array read shape:Array read itemsize:Array read type:Array written byteorder:Array read byteorder:string
irrelevantnumpyr      )"r   verboseprintdtypetypetitletempfilemktemptables	open_filerootendiancheckkindbyteswapnewbyteordercreate_arrayr   readr   shapeitemsize	byteorderassertEqualatomr   sysassertNotEqualflavorndim
chunkshapenrows
assertTrueosremove)self	testarrayafilenamefilehr2   babobboobjrC    rP   6lib/python3.9/site-packages/tables/tests/test_array.py
write_read!   sp    

.



2zBasicTestCase.write_readc           	   	   C   s  |}t jr4tdd td|jj dd td| j td}ztj	|dd	P}|j
}| jr|jjd
kr| }|j |_|}||d|d W d    n1 s0    Y  tj	|dd	}|j
}tj||jd}|jj|d | |j|j | |j|jj |jjd
kr*| |jjjd n| |jj|jj | |jj|jjjj t|jj }t|jj }|dkr| ||jj | || | jr| |tj | t|| W d    n1 s0    Y  W t| nt| 0 d S )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r+   outr%   r&   )r   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r'   
empty_liker   r8   r<   r9   r=   r   r;   r?   r>   rD   r   rE   rF   )	rG   rH   rI   rJ   rK   r2   rL   rM   rN   rP   rP   rQ   write_read_out_argp   sJ    

.


2z BasicTestCase.write_read_out_argc              	   C   s6  |}t |j}|j}d }tjrJtdd td|jj dd td| j t	
d}ztj|dd	}|j}| jr|jjd
kr| }	|j |	_|	jjdv rt|	jj }|	}|j|d||d|d}
| ||
j | ||
j ||
d< W d    n1 s0    Y  tj|dd	}|j}|j }	tjrt||	std td|j td|j td|jj td|	j td|	j td|	jj |jjd
krtd|jj td|	jj | |j|	j | |j|jj |jjd
kr | |jjjd n| |jj|	jj | |jj|jjjj t|jj }t|	jj }|dkr| ||jj | |tj | jr| || |j}| |jd | |j|j | |j|j | |jd  |jr|jd }nd}| |j | | !t||	 W d    n1 s0    Y  W t"#| nt"#| 0 d S )Nr   r   r   r   r   r   r   r   r   r   ><r   r   )r=   r9   r-   r;   .r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r   r(   )$r   
from_dtyper+   r9   r   r)   r*   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r;   r   r7   r<   r=   r   r8   r   r:   r>   r?   r@   rA   rB   rC   rD   rE   rF   )rG   rH   rI   r=   r9   r;   rJ   rK   r2   rL   ptarrrM   rN   rO   rC   rP   rP   rQ   write_read_atom_shape_args   s    

&



2z(BasicTestCase.write_read_atom_shape_argsc                 C   s*   t | jtjs tj| jdd}n| j}|S )z2Data integrity during recovery (character objects)r   rS   )
isinstance	tupleCharr'   ndarrayarrayrG   rI   rP   rP   rQ   setup00_char  s    zBasicTestCase.setup00_charc                 C   s   |   }| | d S N)rc   rR   rb   rP   rP   rQ   test00_char  s    zBasicTestCase.test00_charc                 C   s   |   }| | d S rd   )rc   rW   rb   rP   rP   rQ   test00_char_out_arg  s    z!BasicTestCase.test00_char_out_argc                 C   s   |   }| | d S rd   )rc   r]   rb   rP   rP   rQ   test00_char_atom_shape_args  s    z)BasicTestCase.test00_char_atom_shape_argsc              	   C   s   | j }td}ztj|dd"}||jd|d W d   n1 sH0    Y  tj|ddZ}|jj }t	|t
r| t|t
 | || n| t|ttjg W d   n1 s0    Y  W t| nt| 0 dS )/Data integrity during recovery (string objects)r   r   r   r   r   Nr   )r_   r.   r/   r0   r1   r7   r2   r   r8   r^   bytesr<   r,   assertInlistr'   r`   rE   rF   )rG   rI   rJ   rK   rL   rP   rP   rQ   test00b_char  s    
0
6zBasicTestCase.test00b_charc              	      s   | j }td}ztj|dd"jd|d W d   n1 sH0    Y  tj|dd^t| jj	j
dkr| t fd	d
 njj	j d |  tj W d   n1 s0    Y  W t| nt| 0 dS )rh   r   r   r   r   r   Nr   r'   c                      s   j jj dS NrT   r2   r   r8   rP   rL   rK   rP   rQ   <lambda>D      z4BasicTestCase.test00b_char_out_arg.<locals>.<lambda>rT   )r_   r.   r/   r0   r1   r7   r2   r'   rV   r   r@   assertRaises	TypeErrorr8   assertIsInstancer`   rE   rF   )rG   rI   rJ   rP   ro   rQ   test00b_char_out_arg3  s    
0
.z"BasicTestCase.test00b_char_out_argc              	      sT  | j }td}z0tj|ddt|}t|j	}|j
}|j	jdv rZt|j	j }nd}jjd|||dd}| ||j
 | ||j ||d	< W d   n1 s0    Y  tj|d
d^t| jjjdkr| t fdd njjj d |  tj W d   n1 s,0    Y  W t| nt| 0 dS )rh   r   r   r   rX   Nr   r   )r=   r9   r;   r-   .r   r'   c                      s   j jj dS rm   rn   rP   ro   rP   rQ   rp   k  rq   z<BasicTestCase.test00b_char_atom_shape_args.<locals>.<lambda>rT   )r_   r.   r/   r0   r1   r'   Zasarrayr   r[   r+   r9   r;   r   r7   r2   r<   r=   rV   r   r@   rr   rs   r8   rt   r`   rE   rF   )rG   rI   rJ   nparrr=   r9   r;   r\   rP   ro   rQ   test00b_char_atom_shape_argsL  s6    


&
0z*BasicTestCase.test00b_char_atom_shape_argsc                 C   sh   t | jtjs tj| jdd}n| j}|jdkr:| }n*|ddd }t|dkrd| |j	j
d |S )zAData integrity during recovery (non-contiguous character objects)r   rS   r   N   r(   F)r^   r_   r'   r`   ra   rA   copylenr<   flags
contiguous)rG   rI   rL   rP   rP   rQ   setup01_char_ncs  s    

zBasicTestCase.setup01_char_ncc                 C   s   |   }| | d S rd   )r}   rR   rG   rL   rP   rP   rQ   test01_char_nc  s    zBasicTestCase.test01_char_ncc                 C   s   |   }| | d S rd   )r}   rW   r~   rP   rP   rQ   test01_char_nc_out_arg  s    z$BasicTestCase.test01_char_nc_out_argc                 C   s   |   }| | d S rd   )r}   r]   r~   rP   rP   rQ   test01_char_nc_atom_shape_args  s    z,BasicTestCase.test01_char_nc_atom_shape_argsc                 C   s   g d}dD ]$}|  d }tt|r|| q|D ]L}t| j|}| | t| j|}| | t| j|}| 	| q6dS )z0Data integrity during recovery (numerical types)int8int16int32int64Zuint8Zuint16uint32Zuint64float32float64Z	complex64Z
complex128Zfloat16Zfloat96Zfloat128Z
complex192Z
complex256r   N)

capitalizehasattrr0   appendr'   ra   tupleIntrR   rW   r]   )rG   	typecodesnameatomnametypecoderI   rL   crP   rP   rQ   test02_types  s    


zBasicTestCase.test02_typesc           	      C   s  g d}dD ]$}|  d }tt|r|| q|D ]}t| j|}|jdkrl| }| }| }n~|ddd }|ddd }|ddd }t	|dkr| 
|jjd t	|dkr| 
|jjd t	|dkr| 
|jjd | | | | | | q6dS )	z?Data integrity during recovery (non-contiguous numerical types)r   r   r   r   Nrx   r(   F)r   r   r0   r   r'   ra   r   rA   ry   rz   r<   r{   r|   rR   rW   r]   )	rG   r   r   r   r   rI   b1Zb2Zb3rP   rP   rQ   test03_types_nc  s.    




zBasicTestCase.test03_types_ncN)__name__
__module____qualname____doc__r3   rR   rW   r]   rc   re   rf   rg   rl   ru   rw   r}   r   r   r   r   r   rP   rP   rP   rQ   r      s$   O5^
'r   c                   @   s   e Zd ZdZdZdZdZdS )Basic0DOneTestCasezRank-0 case 1      3TNr   r   r   r-   r   r_   r3   rP   rP   rP   rQ   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )Basic0DTwoTestCasezRank-0 case 2!   s   33TNr   rP   rP   rP   rQ   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )Basic1DZeroTestCasezRank-1 case 0rP   FNr   rP   rP   rP   rQ   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )Basic1DOneTestCaseRank-1 case 1r   )   aTNr   rP   rP   rP   rQ   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )Basic1DTwoTestCasezRank-1 case 2)r      )   aaaTNr   rP   rP   rP   rQ   r     s   r   c                   @   s   e Zd ZdZdZdZdZdS )Basic1DThreeTestCasezRank-1 case 3)r   r      )r   s   bbbTNr   rP   rP   rP   rQ   r     s   r   c                   @   sD   e Zd ZdZeedZde_ejdgd ddZ	de	_d	Z
d
S )Basic2DOneTestCasezRank-2 case 1   )r   r   abc	   S3rS   )r   r   TNr   r   r   r-   r'   ra   aranger   r9   r_   r3   rP   rP   rP   rQ   r     s   r   c                   @   sB   e Zd ZdZejedejdfdZejdgd ddZ	dZ
d	S )
Basic2DTwoTestCasezRank-2 case 2r   )r   rS   r   r   )r   r   TN)r   r   r   r-   r'   ra   r   Zint_r   r_   r3   rP   rP   rP   rQ   r     s   r   c                   @   sD   e Zd ZdZeedZde_ejdgd ddZ	de	_dZ
dS )	Basic10DTestCasezRank-10 testi   )
rx   rx   rx   rx   rx   rx   rx   rx   rx   rx   r   r   rS   TNr   rP   rP   rP   rQ   r     s   
r   c                   @   s6   e Zd ZdZedZde_ejdgddZde_dS )Basic32DTestCasezRank-32 test)    ) r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   r(   121r   rS   N)	r   r   r   r-   r'   ra   r   r9   r_   rP   rP   rP   rQ   r     s
   
r   c                       s\   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Z  ZS )ReadOutArgumentTestsc                    s   t t|   d| _d S )N  )superr   setUpsizerG   	__class__rP   rQ   r   "  s    zReadOutArgumentTests.setUpc                 C   s(   t j| jdd}| jdd|}||fS )Nf8rS   /ra   )r'   r   r   h5filer7   )rG   ra   
disk_arrayrP   rP   rQ   r7   &  s    z!ReadOutArgumentTests.create_arrayc                 C   s:   |   \}}t| jfd}|j|d tj|| d S )Nr   rT   r7   r'   emptyr   r8   r   assert_equalrG   ra   r   
out_bufferrP   rP   rQ   test_read_entire_array+  s    z+ReadOutArgumentTests.test_read_entire_arrayc                 C   s   |   \}}tj| jdd}tj|}| }| jd }|j|| j||d  d tj	||d  ||d   tj	|d | |d |  d S )Nr   rS   rx   startstoprU   
r7   r'   r   r   ZrandomZpermutationry   r8   r   r   )rG   ra   r   r   out_buffer_origr   rP   rP   rQ   test_read_contiguous_slice11  s    
z0ReadOutArgumentTests.test_read_contiguous_slice1c                 C   s   |   \}}tj| jdd}tj|}| }| jd }| j| }|j||||| d tj	||| |||  tj	|d | |d |  tj	||d  ||d   d S )Nr   rS   r   r   r   )rG   ra   r   r   r   r   r   rP   rP   rQ   test_read_contiguous_slice2;  s    

z0ReadOutArgumentTests.test_read_contiguous_slice2c                 C   sT   |   \}}tj| jd fdd}|jd| jd|d tj||d| jd  d S )Nrx   r   rS   r   )r   r   steprU   r   r   rP   rP   rQ   0test_read_non_contiguous_slice_contiguous_bufferG  s    zEReadOutArgumentTests.test_read_non_contiguous_slice_contiguous_bufferc              
   C   s   |   \}}t| jfd}|d| jd }| t|jd| jd| z|d| jd| W n4 ty } z| dt| W Y d }~n
d }~0 0 d S )Nr   r   rx   zoutput array not C contiguous)	r7   r'   r   r   rr   
ValueErrorr8   r<   str)rG   ra   r   r   Zout_buffer_sliceexcrP   rP   rQ   test_read_non_contiguous_bufferM  s    z4ReadOutArgumentTests.test_read_non_contiguous_bufferc              
   C   s   |   \}}t| jd fd}| t|jd| jd| z|d| jd| W n4 ty } z| dt| W Y d }~n
d }~0 0 d S )Nrx   r   r   r(   output array size invalid, got	r7   r'   r   r   rr   r   r8   rj   r   rG   ra   r   r   r   rP   rP   rQ   test_buffer_too_smallZ  s    z*ReadOutArgumentTests.test_buffer_too_smallc              
   C   s   |   \}}t| jd fd}| t|jd| jd| z|d| jd| W n4 ty } z| dt| W Y d }~n
d }~0 0 d S )Nr(   r   r   r   r   r   rP   rP   rQ   test_buffer_too_larged  s    z*ReadOutArgumentTests.test_buffer_too_large)r   r   r   r   r7   r   r   r   r   r   r   r   __classcell__rP   rP   r   rQ   r      s   

r   c                       s$   e Zd Z fddZdd Z  ZS )"SizeOnDiskInMemoryPropertyTestCasec                    s4   t t|   d| _| jddt| jd| _d S )N
   r   r   r   i4)	r   r   r   Z
array_sizer   r7   r'   zerosra   r   r   rP   rQ   r   q  s
    z(SizeOnDiskInMemoryPropertyTestCase.setUpc                 C   s$   |  | jjd |  | jjd d S )Ni  )r<   ra   Zsize_on_diskZsize_in_memoryr   rP   rP   rQ   test_all_zerosw  s    z1SizeOnDiskInMemoryPropertyTestCase.test_all_zeros)r   r   r   r   r   r   rP   rP   r   rQ   r   o  s   r   c                       s   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Z  ZS )UnalignedAndComplexTestCaseznBasic test for all the supported typecodes present in numpy.

    Most of them are included on PyTables.

    c                    s   t t|   | jj| _d S rd   )r   r   r   r   r2   r   r   rP   rQ   r     s    z!UnalignedAndComplexTestCase.setUpc                 C   s  t jr tdd td|jj  |}| jr<dddtj }ntj}| jj	| j
d|d|d	 | jrr|   | jj
| _
| j
j }||}t||st jrtd
 td| td|j td|j td|jj td| td|j td|j td|jj | |j|j | |j| j
jj |jjdkr| |j|j | |j| j
jjj | t|jj tj | | j
jj| | t|| d S )Nr   r   z&
Running test for array with type '%s'biglittle)r   r   r   r   )r;   r   zArray written:r   r   r   zArray read:r    r!   r"   |)r   r)   r*   r+   r,   r3   r>   r;   r   r7   r2   reopen_reopenr   r8   r6   r   r9   r:   r<   r=   r   rD   )rG   Z	testArrayrI   r;   rL   r   rP   rP   rQ   rR     sF    




z&UnalignedAndComplexTestCase.write_readc                 C   sJ   t jjdddd}|d }| |jjd | |jjt j | 	| dS )z0Checking an unaligned signed short integer array   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai1,f4,i2r   Zformatsr9   f2FN)
r'   recra   r<   r{   alignedr+   r,   r   rR   rG   r   rI   rP   rP   rQ   test01_signedShort_unaligned  s
    z8UnalignedAndComplexTestCase.test01_signedShort_unalignedc                 C   sJ   t jjdddd}|d }| |jjd | |jjt j | 	| dS )z,Checking an unaligned single precision arrayr   r   r   r   f1r   N
r'   r   ra   r<   r{   r   r+   r,   r   rR   r   rP   rP   rQ   test02_float_unaligned  s
    z2UnalignedAndComplexTestCase.test02_float_unalignedc                 C   s,   t jdt jd}d|_|d }| | dS )z Checking an offsetted byte arrayd   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test03_byte_offset  s    z.UnalignedAndComplexTestCase.test03_byte_offsetc                 C   s,   t jdt jd}d|_|d }| | dS )z8Checking an offsetted unsigned short int precision arrayr   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test04_short_offset  s    z/UnalignedAndComplexTestCase.test04_short_offsetc                 C   s,   t jdt jd}d|_|d }| | dS )z#Checking an offsetted integer arrayr   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test05_int_offset  s    z-UnalignedAndComplexTestCase.test05_int_offsetc                 C   s,   t jdt jd}d|_|d }| | dS )z-Checking an offsetted long long integer arrayr   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test06_longlongint_offset  s    z5UnalignedAndComplexTestCase.test06_longlongint_offsetc                 C   s,   t jdt jd}d|_|d }| | dS )z,Checking an offsetted single precision arrayr   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test07_float_offset  s    z/UnalignedAndComplexTestCase.test07_float_offsetc                 C   s,   t jdt jd}d|_|d }| | dS )z,Checking an offsetted double precision arrayr   rS   r   rx   N)r'   r   r   r9   rR   r   rP   rP   rQ   test08_double_offset  s    z0UnalignedAndComplexTestCase.test08_double_offsetc                 C   sN   t jjdddd}|d d }| |jjd | |jjt j | 	| dS )	z:Checking an unaligned and offsetted single precision arrayr   z	i1,3f4,i2r   r   r   r   FNr   r   rP   rP   rQ   test09_float_offset_unaligned  s
    z9UnalignedAndComplexTestCase.test09_float_offset_unalignedc                 C   sN   t jjdddd}|d d }| |jjd | |jjt j | 	| dS )	z:Checking an unaligned and offsetted double precision arrays  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz	i1,3f8,i2r   r   r   r   FN)
r'   r   ra   r<   r{   r   r+   r,   r   rR   r   rP   rP   rQ   test10_double_offset_unaligned  s
    z:UnalignedAndComplexTestCase.test10_double_offset_unalignedc                 C   s   t jdt jddd}| }| }| j| jjd|d}|ddddf }| }| }||ddddf< | }| }||ddddf< |d	 }t	j
rtd
|j td|jj td| td| | t|| dS )zLChecking setting data with different byteorder in a range
         (integer)   rS   r   ra   zbyteorder (int)rx   r   r   .byteorder of array on disk-->byteorder of subarray-->subarray-->retrieved array-->N)r'   r   r   reshaper5   r6   r   r7   r2   r   r)   r*   r;   r+   rD   r   rG   rI   ra   rL   r   rP   rP   rQ   test11_int_byteorder  s(    

z0UnalignedAndComplexTestCase.test11_int_byteorderc                 C   s   t jdt jddd}| }| }| j| jjd|d}|ddddf }| }| }||ddddf< | }| }||ddddf< |d	 }t	j
rtd
|j td|jj td| td| | t|| dS )zAChecking setting data with different byteorder in a range (float)r   rS   r   ra   zbyteorder (float)rx   r   r   .r   r   r   r   N)r'   r   r   r  r5   r6   r   r7   r2   r   r)   r*   r;   r+   rD   r   r  rP   rP   rQ   test12_float_byteorder-  s(    

z2UnalignedAndComplexTestCase.test12_float_byteorder)r   r   r   r   r   rR   r   r   r   r   r   r   r   r   r   r   r  r  r   rP   rP   r   rQ   r   |  s   1



r   c                   @   s   e Zd ZdZdZdS )!ComplexNotReopenNotEndianTestCaseFNr   r   r   r3   r   rP   rP   rP   rQ   r  J  s   r  c                   @   s   e Zd ZdZdZdS )ComplexReopenNotEndianTestCaseFTNr  rP   rP   rP   rQ   r  O  s   r  c                   @   s   e Zd ZdZdZdS )ComplexNotReopenEndianTestCaseTFNr  rP   rP   rP   rQ   r  T  s   r  c                   @   s   e Zd ZdZdZdS )ComplexReopenEndianTestCaseTNr  rP   rP   rP   rQ   r	  Y  s   r	  c                   @   s    e Zd ZdZdd Zdd ZdS )GroupsArrayTestCasez:This test class checks combinations of arrays with groups.c           	      C   s  t jr tdd td| jj  | jj}g d}ttdrD|	d ttdsXttdrb|	d	 ttd
svttdr|	d t
|D ]Z\}}td|}d| }t jrtd|| | j|||d | j|dt| }q|   | jj}tt|D ]}td|| }t|d||  }| }t jrtd|j td|jdd td|jj  td|jdd td|j  | |j|j | |j|j | t|| t|dt| }q dS )z,Checking combinations of arrays with groups.r   r   z$Running %s.test00_iterativeGroups...)rL   BhHiIlLqfdFDZFloat16AtomeZFloat96AtomZFloat128AtomgZComplex192AtomZComplex256AtomGr   Zarray_zCreating dataset:zLarge arraygroupInfo from dataset:z  shape ==>r   r   z  type ==> %s"Array b read from file. Shape: ==>z. Type ==> %sN)r   r)   r*   r   r   r   r2   r   r0   r   	enumerater'   onesZ_g_joinr7   create_groupr   r   rangerz   getattrr8   _v_pathnamer9   r=   r+   r<   rD   r   )	rG   r  r   r  r   rI   ZdsetnameZdsetrL   rP   rP   rQ   test00_iterativeGroupsa  sL    





z*GroupsArrayTestCase.test00_iterativeGroupsc                 C   s  d}d}t jr2tdd td| jj  td| | jj}t jrLtddd	 t||d D ]X}t	d
| tj
}t jrtd| dd	 | j|d|d|  | j|dt| }qZ|   | jj}t jrt  td t||d D ]}t	d
| tj
}|j }t jrtd| dd	 t jrt||std|jj td|jjdd	 td|jj  td|jdd	 td|j  | |j|j | |j|j | t|| | j|dt| }qt jrt  dS )z~Checking creation of large rank arrays (0 < rank <= 32)
        It also uses arrays ranks which ranges until maxrank.
        r(   r   r   r   z$Running %s.test01_largeRankArrays...zMaximum rank for tested arrays:zRank array writing progress: r   r   )r(   z%3d,ra   zRank: %sr  zRank array reading progress: r  z  Shape: ==>z  typecode ==> %cr  z. Type ==> %cN)r   r)   r*   r   r   r   r2   r   r'   r  r   r7   r  r   r   ra   r8   r   r"  r9   r   r+   r<   rD   get_node)rG   ZminrankZmaxrankr  ZrankrI   rL   rP   rP   rQ   test01_largeRankArrays  sN    


z*GroupsArrayTestCase.test01_largeRankArraysN)r   r   r   r   r#  r%  rP   rP   rP   rQ   r
  ^  s   <r
  c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )CopyTestCasec                 C   s.  t jr tdd td| jj  tjddgddggdd	}| j| jj	d
|d}|
dd}| jrt jrptd |   | jj	j}| jj	j}t jrtd|  td|  tdt|j tdt|j | t| |  | |j|j | |j|j | |jj|jj | |j|j dS )zChecking Array.copy() method.r   r   zRunning %s.test01_copy...  rx   r     r   rS   array1title array1r   array2(closing file version)	array1-->	array2-->attrs array1-->attrs array2-->N)r   r)   r*   r   r   r'   ra   r   r7   r2   ry   closer   r)  r+  r8   reprattrsrD   r   r<   rC   r@   r=   r+   r-   rG   arrr)  r+  rP   rP   rQ   test01_copy  s0    


zCopyTestCase.test01_copyc                 C   s>  t jr tdd td| jj  tjddgddggdd	}| j| jj	d
|d}| j
dd}||d}| jrt jr~td |   | jj	j}| jj	jj}t jrtd|  td|  tdt|j tdt|j | t| |  | |j|j | |j|j | |jj|jj | |j|j dS )z.Checking Array.copy() method (where specified)r   r   zRunning %s.test02_copy...r'  rx   r   r(  r   rS   r)  r*  r   group1r+  r,  r-  r.  r/  r0  N)r   r)   r*   r   r   r'   ra   r   r7   r2   r  ry   r1  r   r)  r7  r+  r8   r2  r3  rD   r   r<   rC   r@   r=   r+   r-   )rG   r5  r)  r7  r+  rP   rP   rQ   test02_copy  s2    

zCopyTestCase.test02_copyc                 C   s   t jr tdd td| jj  tjddgddggdd	}| j| jj	d
|d}d|j
_d|j
_|jdddd}| jrt jrtd |   | jj	j}| jj	j}t jrtd|j | |jd dS )z5Checking Array.copy() method (checking title copying)r   r   zRunning %s.test04_copy...r'  rx   r   r(  r   rS   r)  r*  attr1r   r+  ztitle array2)r-   r,  ztitle of destination array-->N)r   r)   r*   r   r   r'   ra   r   r7   r2   r3  r9  attr2ry   r1  r   r)  r+  r-   r<   r4  rP   rP   rQ   test03_copy*  s&    


zCopyTestCase.test03_copyc                 C   s   t jr tdd td| jj  tjddgddggdd	}| j| jj	d
|d}d|j
_d|j
_|jdddd}| jrt jrtd |   | jj	j}| jj	j}t jrtdt|j
 tdt|j
 | |j
jd | |j
jd dS )z5Checking Array.copy() method (user attributes copied)r   r   zRunning %s.test05_copy...r'  rx   r   r(  r   rS   r)  r*  r9  r   r+  r(   Zcopyuserattrsr,  r/  r0  N)r   r)   r*   r   r   r'   ra   r   r7   r2   r3  r9  r:  ry   r1  r   r)  r+  r2  r<   r4  rP   rP   rQ   test04_copyG  s*    


zCopyTestCase.test04_copyc                 C   s   t jr tdd td| jj  tjddgddggdd	}| j| jj	d
|d}d|j
_d|j
_|jdddd}| jrt jrtd |   | jj	j}| jj	j}t jrtdt|j
 tdt|j
 | t|j
dd | t|j
dd dS )z9Checking Array.copy() method (user attributes not copied)r   r   zRunning %s.test05b_copy...r'  rx   r   r(  r   rS   r)  r*  r9  r   r+  r   r<  r,  r/  r0  r:  N)r   r)   r*   r   r   r'   ra   r   r7   r2   r3  r9  r:  ry   r1  r   r)  r+  r2  r<   r   r4  rP   rP   rQ   test04b_copyg  s*    


zCopyTestCase.test04b_copyN)r   r   r   r6  r8  r;  r=  r>  rP   rP   rP   rQ   r&    s
   &' r&  c                   @   s   e Zd ZdZdS )CloseCopyTestCaser(   Nr   r   r   r1  rP   rP   rP   rQ   r?    s   r?  c                   @   s   e Zd ZdZdS )OpenCopyTestCaser   Nr@  rP   rP   rP   rQ   rA    s   rA  c                   @   s   e Zd Zdd Zdd ZdS )CopyIndexTestCasec                 C   s  t jr tdd td| jj  tjddd}d|_| j	| jj
d|d	}|jd
d| j| j| jd}t jrtd|  td|  tdt|j tdt|j || j| j| j }| t||  t jrtd|j td|jd  | |jd |j dS )z*Checking Array.copy() method with indexes.r   r   zRunning %s.test01_index...   r   rS   r   rx   r)  r*  r   r+  r   r   r   r-  r.  r/  r0  nrows in array2-->and it should be-->r   N)r   r)   r*   r   r   r'   r   r9   r   r7   r2   ry   r   r   r   r8   r2  r3  rD   r   rC   r<   rG   r   r)  r+  Zr2rP   rP   rQ   test01_index  s0    
zCopyIndexTestCase.test01_indexc                 C   s&  t jr tdd td| jj  tjddd}d|_| j	| jj
d|d	}|jd
d| j| j| jd}|   | jj
j}| jj
j}t jrtd|  td|  tdt|j tdt|j || j| j| j }| t||  t jrtd|j td|jd  | |jd |j dS )z>Checking Array.copy() method with indexes (close file version)r   r   z Running %s.test02_indexclosef...rC  r   rS   rD  r)  r*  r   r+  rE  r-  r.  r/  r0  rF  rG  r   N)r   r)   r*   r   r   r'   r   r9   r   r7   r2   ry   r   r   r   r   r)  r+  r8   r2  r3  rD   r   rC   r<   rH  rP   rP   rQ   test02_indexclosef  s6    


z$CopyIndexTestCase.test02_indexclosefN)r   r   r   rI  rJ  rP   rP   rP   rQ   rB    s   #rB  c                   @   s   e Zd ZdZdZdZdS )CopyIndex1TestCaser      r(   Nr   r   r   r   r   r   rP   rP   rP   rQ   rK    s   rK  c                   @   s   e Zd ZdZdZdZdS )CopyIndex2TestCaser   r(   NrM  rP   rP   rP   rQ   rN    s   rN  c                   @   s   e Zd ZdZdZdZdS )CopyIndex3TestCaser(   rL  NrM  rP   rP   rP   rQ   rP    s   rP  c                   @   s   e Zd ZdZdZdZdS )CopyIndex4TestCaser      r(   NrM  rP   rP   rP   rQ   rQ    s   rQ  c                   @   s   e Zd ZdZdZdZdS )CopyIndex5TestCaser   rL  r(   NrM  rP   rP   rP   rQ   rS    s   rS  c                   @   s   e Zd ZdZdZdZdS )CopyIndex6TestCaser   rR  rx   NrM  rP   rP   rP   rQ   rT    s   rT  c                   @   s   e Zd ZdZdZdZdS )CopyIndex7TestCaser   rL  r   NrM  rP   rP   rP   rQ   rU    s   rU  c                   @   s   e Zd ZdZdZdZdS )CopyIndex8TestCaserR  rO  r(   NrM  rP   rP   rP   rQ   rV    s   rV  c                   @   s   e Zd ZdZdZdZdS )CopyIndex9TestCaser   r   r(   NrM  rP   rP   rP   rQ   rW    s   rW  c                   @   s   e Zd ZdZdZdZdS )CopyIndex10TestCaser   r   rx   NrM  rP   rP   rP   rQ   rX    s   rX  c                   @   s   e Zd ZdZdZdZdS )CopyIndex11TestCaserO  rx   NrM  rP   rP   rP   rQ   rY    s   rY  c                   @   s   e Zd ZdZdZdZdS )CopyIndex12TestCaserO  Nr(   rM  rP   rP   rP   rQ   r[     s   r[  c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )GetItemTestCasec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjrjt	d|d t
|d  t	d|d t
|d  | t|d |d  | t
|d t
|d  dS )z'Single element access (character types)r   r   Original first element:r   Read first element:N)charListr   r7   r2   r1  r   r   r   r)   r*   r,   rD   r   r<   rG   rI   r5  rP   rP   rQ   test00_single(  s    
zGetItemTestCase.test00_singlec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjrjt	d|d t
|d  t	d|d t
|d  | |d |d  | t
|d t
|d  dS )z'Single element access (numerical types)r   r   r]  r   r^  N)numericalListr   r7   r2   r1  r   r   r   r)   r*   r,   r<   r`  rP   rP   rQ   test01_single;  s    
zGetItemTestCase.test01_singlec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjr^t	d|dd  t	d|dd  | 
t|dd |dd  dS )z&Range element access (character types)r   r   Original elements:r(   r   Read elements:N
charListMEr   r7   r2   r1  r   r   r   r)   r*   rD   r   r`  rP   rP   rQ   test02_rangeN  s    
zGetItemTestCase.test02_rangec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjr^t	d|dd  t	d|dd  | 
t|dd |dd  dS )z&Range element access (numerical types)r   r   rd  r(   r   re  NnumericalListMEr   r7   r2   r1  r   r   r   r)   r*   rD   r   r`  rP   rP   rQ   test03_range`  s    
zGetItemTestCase.test03_rangec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjrbt	d|ddd  t	d|ddd  | 
t|ddd |ddd  dS )	z/Range element access, strided (character types)r   r   rd  r(   r   rx   re  Nrf  r`  rP   rP   rQ   test04_ranger  s    
zGetItemTestCase.test04_rangec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjrbt	d|ddd  t	d|ddd  | 
t|ddd |ddd  dS )	z/Range element access, strided (numerical types)r   r   rd  r(   r   rx   re  Nri  r`  rP   rP   rQ   test05_range  s    
zGetItemTestCase.test05_rangec                 C   sr   | j }| j| jjd|d}| jr4|   | jjj}tjrVt	d|d  t	d|d  | 
t|d |d  dS )z/Negative Index element access (character types)r   r   Original last element:rO  Read last element:Nrf  r`  rP   rP   rQ   test06_negativeIndex  s    
z$GetItemTestCase.test06_negativeIndexc                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjrVt	d|d  t	d|d  t
|d tjr| t|d |d  n| |d |d  dS )z/Negative Index element access (numerical types)r   r   Original before last element:Read before last element:Nrj  r   r7   r2   r1  r   r   r   r)   r*   r^   r'   r`   rD   r   r<   r`  rP   rP   rQ   test07_negativeIndex  s    
z$GetItemTestCase.test07_negativeIndexc                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjr^t	d|dd  t	d|dd  | 
t|dd |dd  dS )z/Negative range element access (character types)r   r   Original last elements:rO  Read last elements:Nrf  r`  rP   rP   rQ   test08_negativeRange  s    
z$GetItemTestCase.test08_negativeRangec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}tjr^t	d|dd  t	d|dd  | 
t|dd |dd  dS )z/Negative range element access (numerical types)r   r   rv  rw  rO  rx  Nri  r`  rP   rP   rQ   test09_negativeRange  s    
z$GetItemTestCase.test09_negativeRangeN)r   r   r   ra  rc  rh  rk  rl  rm  rp  ru  ry  rz  rP   rP   rP   rQ   r\  &  s   r\  c                   @   sH   e Zd ZdZedgZeg dZedgdZeg ddZ	dS )GI1NATestCaser   r   r   rx   r(   r   r   r   rR  3r   Z321Z221r   Z021Z421Z521621N
r   r   r   r-   r'   ra   rb  rj  r_  rg  rP   rP   rP   rQ   r{    s   r{  c                   @   s   e Zd ZdZdS )GI1NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd ZdZdS )GI1NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r    s   r  c                	   @   s   e Zd ZdZeddgZeg dg dg dg dg dgZeddgd	Zeg d
g dg dg d
g dg dgd	Z	dS )GI2NATestCaseRank-1,2 case 2r   r   r|  rx   r(   r   r   r   rR  rL  r   r   rx   r(   r   r   r   rI   rL   r   r~  21r  Z11Z02Z42r  Z61Z31r  Z12r  Z41Z51r  Z3241Z2321Z13216Z0621Z4421Z5421Za621Za321Zs221Zd121Zg021Zb421Z5vvv21Z6zxzxs21Nr  rP   rP   rP   rQ   r    s&   
r  c                   @   s   e Zd ZdZdS )GI2NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r  	  s   r  c                   @   s   e Zd ZdZdS )GI2NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r    s   r  c                   @   sd   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd ZdS )SetItemTestCasec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}d|d< d|d< tjrht	d|d  t	d|d  | 
t|d |d  dS )	z'Single element update (character types)r   r   rI      br   r]  r^  N)r_  r   r7   r2   r1  r   r   r   r)   r*   rD   r   r`  rP   rP   rQ   ra    s    

zSetItemTestCase.test00_singlec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}d|d< d|d< tjrht	d|d  t	d|d  | 
|d |d  dS )	z'Single element update (numerical types)r   r   rI   iM  r   r]  r^  Nrb  r   r7   r2   r1  r   r   r   r)   r*   r<   r`  rP   rP   rQ   rc  )  s    

zSetItemTestCase.test01_singlec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}d|dd< d|dd< tjrxt	d|dd  t	d	|dd  | 
t|dd |dd  d
S )z&Range element update (character types)r   r   rI      xXxr(   r   rd  r   re  Nrf  r`  rP   rP   rQ   rh  ?  s    

zSetItemTestCase.test02_rangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}tddd}t	|| j
d d }|| j|_|||< |||< tjrtd|dd	  td
|dd	  | t|dd	 |dd	  dS )z&Range element update (numerical types)r   r   rI   r(   r   Nrx   rd  r   re  rj  r   r7   r2   r1  r   r   slicer'   r   r   r9   r   r)   r*   rD   r   rG   rI   r5  srngrP   rP   rQ   rk  U  s     

zSetItemTestCase.test03_rangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}tddd}d||< d||< tj	rt
d|ddd  t
d	|ddd  | t|ddd |ddd  d
S )z/Range element update, strided (character types)r   r   rI   r(   r   rx   r  rd  re  Nrg  r   r7   r2   r1  r   r   r  r   r)   r*   rD   r   rG   rI   r5  r  rP   rP   rQ   rl  n  s    

zSetItemTestCase.test04_rangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}tddd}t	|| j
d d }|| j|_|||< |||< tjrtd|ddd  td	|ddd  | t|ddd |ddd  d
S )z/Range element update, strided (numerical types)r   r   rI   r(   r   rx   r   rd  re  Nr  r  rP   rP   rQ   rm    s     

zSetItemTestCase.test05_rangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}d}d||< d||< tjrlt	d|d  t	d|d  | 
t|d |d  dS )	z/Negative Index element update (character types)r   r   rI   rO  r  rn  ro  Nrf  r  rP   rP   rQ   rp    s    

z$SetItemTestCase.test06_negativeIndexc                 C   s   | j }| j| jjd|d}| jr6| d | jjj}d}|| d d ||< || d d ||< tjrt	d|d  t	d|d  t
|d tjr| t|d |d  n| |d |d  d	S )
z/Negative Index element update (numerical types)r   r   rI   rr  rx   r   rq  rs  Nrt  r  rP   rP   rQ   ru    s     

z$SetItemTestCase.test07_negativeIndexc                 C   s   | j }| j| jjd|d}| jr6| d | jjj}tddd}d||< d||< tj	r|t
d|dd  t
d	|dd  | t|dd |dd  dS )
z/Negative range element update (character types)r   r   rI   rw  rO  Nr  rv  rx  r  r  rP   rP   rQ   ry    s    

z$SetItemTestCase.test08_negativeRangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}tddd}t	|| j
d d }|| j|_|||< |||< tjrtd	|d
d  td|d
d  | t|d
d |d
d  dS )z/Negative range element update (numerical types)r   r   rI   rZ  rO  Nrx   r   rv  rw  rx  r  r  rP   rP   rQ   rz    s     

z$SetItemTestCase.test09_negativeRangec                 C   s   | j }| j| jjd|d}| jr6| d | jjj}td|jd d d}tddd}t	
|| jd d	 }|| j|_|||< t	
|| jd d	 }|| j|_|||< tjrtd
|dd  td|dd  | t|dd |dd  dS )z%Out of range update (numerical types)r   r   rI   r(   r   Nr   rx   r   rv  rw  rO  rx  )rj  r   r7   r2   r1  r   r   r  r9   r'   r   r   r   r)   r*   rD   r   )rG   rI   r5  r  s2r  Zrng2rP   rP   rQ   test10_outOfRange  s&    

z!SetItemTestCase.test10_outOfRangeN)r   r   r   ra  rc  rh  rk  rl  rm  rp  ru  ry  rz  r  rP   rP   rP   rQ   r    s   r  c                   @   sH   e Zd ZdZedgZeg dZedgdZeg ddZ	dS )SI1NATestCaser   r   r|  r}  r   r~  Nr  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd ZdZdS )SI1NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r  %  s   r  c                   @   s   e Zd ZdZdS )SI1NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r  )  s   r  c                	   @   s   e Zd ZdZeddgZeg dg dg dg dg dgZeddgd	Zeg d
g dg dg d
g dg dgd	Z	dS )SI2NATestCaser  r   r   r|  r  r  rI   rL   r   r~  r  r  r  r  Nr  rP   rP   rP   rQ   r  -  s&   
r  c                   @   s   e Zd ZdZdS )SI2NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r  C  s   r  c                   @   s   e Zd ZdZdS )SI2NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r  G  s   r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
GeneratorTestCasec                 C   sz   | j }| j| jjd|d}| jr4|   | jjj}dd |D }dd |D }tjrjt	d| t	d| | 
|| dS )	z:Testing generator access to Arrays, single elements (char)r   r   c                 S   s   g | ]}|qS rP   rP   .0r  rP   rP   rQ   
<listcomp>Z  rq   z4GeneratorTestCase.test00a_single.<locals>.<listcomp>c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r  [  rq   Result of original iterator:Result of read generator:N)r_  r   r7   r2   r1  r   r   r   r)   r*   r<   rG   rI   r5  gagarrrP   rP   rQ   test00a_singleM  s    


z GeneratorTestCase.test00a_singlec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}dd |D }dd |D }tjrjt	d| t	d| t
t|D ]}| t|| ||  qvdS )	z<Testing generator access to Arrays, multiple elements (char)r   r   c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r  n  rq   z0GeneratorTestCase.test00b_me.<locals>.<listcomp>c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r  o  rq   r  r  N)rg  r   r7   r2   r1  r   r   r   r)   r*   r   rz   rD   r   rG   rI   r5  r  r  r  rP   rP   rQ   
test00b_mea  s    


zGeneratorTestCase.test00b_mec                 C   sz   | j }| j| jjd|d}| jr4|   | jjj}dd |D }dd |D }tjrjt	d| t	d| | 
|| dS )	z=Testing generator access to Arrays, single elements (numeric)r   r   c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r    rq   z4GeneratorTestCase.test01a_single.<locals>.<listcomp>c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r    rq   r  r  Nr  r  rP   rP   rQ   test01a_singlew  s    


z GeneratorTestCase.test01a_singlec                 C   s   | j }| j| jjd|d}| jr4|   | jjj}dd |D }dd |D }tjrjt	d| t	d| t
t|D ]}| t|| ||  qvdS )	z?Testing generator access to Arrays, multiple elements (numeric)r   r   c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r    rq   z0GeneratorTestCase.test01b_me.<locals>.<listcomp>c                 S   s   g | ]}|qS rP   rP   r  rP   rP   rQ   r    rq   r  r  N)rj  r   r7   r2   r1  r   r   r   r)   r*   r   rz   rD   r   r  rP   rP   rQ   
test01b_me  s    


zGeneratorTestCase.test01b_meN)r   r   r   r  r  r  r  rP   rP   rP   rQ   r  K  s   r  c                   @   sH   e Zd ZdZedgZeg dZedgdZeg ddZ	dS )GE1NATestCaser   r   r|  r}  r   r~  Nr  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd ZdZdS )GE1NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd ZdZdS )GE1NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r    s   r  c                	   @   s   e Zd ZdZeddgZeg dg dg dg dg dgZeddgd	Zeg d
g dg dg d
g dg dgd	Z	dS )GE2NATestCaser  r   r   r|  r  r  rI   rL   r   r~  r  r  r  r  Nr  rP   rP   rP   rQ   r    s&   
r  c                   @   s   e Zd ZdZdS )GE2NAOpenTestCaser   Nr@  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd ZdZdS )GE2NACloseTestCaser(   Nr@  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd Zdd ZdS )NonHomogeneousTestCasec              	   C   s8   |  ttf| jjdddddgg |  t| jjd dS )z,Test for creation of non-homogeneous arrays.r   testr(   rx   r   z/testN)rr   r   rs   r   r7   r   Zremove_noder   rP   rP   rQ   r    s    
zNonHomogeneousTestCase.testNr   r   r   r  rP   rP   rP   rQ   r    s   r  c                   @   s   e Zd Zdd ZdS )TruncateTestCasec                 C   s(   | j ddddg}| t|jd dS )z-Test for unability to truncate Array objects.r   r)  r   rx   N)r   r7   rr   rs   truncate)rG   r)  rP   rP   rQ   r    s    zTruncateTestCase.testNr  rP   rP   rP   rQ   r    s   r  c                       s\   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Z  ZS )PointSelectionTestCasec                    s\   t t|   g d| _t| j}tj|tjd	| j}|| _
| j| jjd|| _d S )N)r   r(   )   )r  r   )r   r   rS   ra   )r   r  r   limitsr'   prodr9   r   r   r  rv   r   r7   r2   tbarr)rG   r   rv   r   rP   rQ   r     s    
zPointSelectionTestCase.setUpc                 C   sf   | j }| j}| jD ]N\}}||k||k @ }tjr:td| || }|| }| t||kd qdS )z/Test for point-selections (read, boolean keys).Selection to test:3NumPy array and PyTables selections does not match.N	rv   r  r  r   r)   r*   rD   r'   alltruerG   rv   r  value1value2keyrI   rL   rP   rP   rQ   test01a_read  s    
z#PointSelectionTestCase.test01a_readc                 C   sl   | j }| j}| jD ]T\}}t||k||k @ }tjr@td| || }|| }| t	||kd qdS )z/Test for point-selections (read, integer keys).r  r  N
rv   r  r  r'   wherer   r)   r*   rD   r  r  rP   rP   rQ   test01b_read  s    
z#PointSelectionTestCase.test01b_readc                 C   sf   | j }| j}| jD ]N\}}t||k||k @ }tjr@td| t|d}| 	t
tf|j| qdS )z-Test for point-selections (read, float keys).r  Zf4N)rv   r  r  r'   r  r   r)   r*   ra   rr   
IndexErrorrs   __getitem__)rG   rv   r  r  r  r  ZfkeyrP   rP   rQ   test01c_read  s    
z#PointSelectionTestCase.test01c_readc                 C   s\   | j }| j}| jD ]D}|jdkr(t|}tjr8td| || }|| }t	||d qd S )Nr(   r  r  )
rv   r  working_keysetrA   tupler   r)   r*   nptZassert_array_equalrG   rv   r  r  rI   rL   rP   rP   rQ   test01d_read  s    


z#PointSelectionTestCase.test01d_readc                 C   s6   | j }| jD ]$}tjr td| | t|j| qd S )Nr  r  not_working_keysetr   r)   r*   rr   r  r  rG   r  r  rP   rP   rQ   test01e_read-  s
    

z#PointSelectionTestCase.test01e_readc           	      C   s   | j }| j}| jD ]v\}}||k||k @ }tjr:td| || }|d ||< |d ||< |dd }|dd }| t||kd qdS )z0Test for point-selections (write, boolean keys).r  rx   N6NumPy array and PyTables modifications does not match.r  	rG   rv   r  r  r  r  r  rI   rL   rP   rP   rQ   test02a_write6  s    
z$PointSelectionTestCase.test02a_writec           	      C   s   | j }| j}| jD ]|\}}t||k||k @ }tjr@td| || }|d ||< |d ||< |dd }|dd }| t	||kd qdS )z0Test for point-selections (write, integer keys).r  rx   Nr  r  r  rP   rP   rQ   test02b_writeH  s    
z$PointSelectionTestCase.test02b_writec                 C   s   | j }| j}| jD ]l\}}t||k||k @ }tjr@td| d||< d||< |dd }|dd }| t	||kd qdS )z=Test for point-selections (write, integer values, broadcast).r  rx   Nr  r  r  rP   rP   rQ   test02c_writeZ  s    
z$PointSelectionTestCase.test02c_write)r   r   r   r   r  r  r  r  r  r  r  r  r   rP   rP   r   rQ   r    s   	r  c                   @   s6   e Zd ZdZddgddggZddgddgddggZdS )	PointSelection0r   r   r(   rO  r   r   rw  Nr   r   r   r9   r  r  rP   rP   rP   rQ   r  m  s   r  c                   @   s<   e Zd ZdZg dg dgZg dg dg dg dgZdS )	PointSelection1r   r   r   )r   r   r  r  )r  r   rO  r  )r  r   r   r  )r  r   r   r  )r  r   rw  r  )r  r   r  Nr  rP   rP   rP   rQ   r  z  s   r  c                   @   sB   e Zd ZdZddgddgddggZddgddgddgdd	ggZd
S )PointSelection2)rL  r   r  r  r  )r   rr  r  r  r  r  Nr  rP   rP   rP   rQ   r    s   r  c                   @   s6   e Zd ZdZg dg dgZg dg dg dgZdS )PointSelection3)r   r   rx   r(   )r  r  r  r  )r  r  r  r  )r  r  r  r  )r  r  r  r  )r  r  r  r  Nr  rP   rP   rP   rQ   r    s   r  c                   @   s6   e Zd ZdZg dg dgZg dg dg dgZdS )PointSelection4)r(   r   rx   r   rR  )r  r  r  r  r  )r  r  r  r  r  )r  r  r  r  r  )r  r  r  r  r  )r  r  r  r  r  Nr  rP   rP   rP   rQ   r    s   r  c                       sL   e Zd Z fddZdd Zdd Zdd Zd	d
 Zdd Zdd Z	  Z
S )FancySelectionTestCasec                    s  t t|   | j\}}}ddgtd|d df|d dddgtd dft||d ddgtd ftd|dtd||d ddgf|d ddgdfdddgddfddgddfddgdtftddgftddgdddftddgd	ddfg| _tjd
dgddg dddfddgdddgfg ddftddgtfd
dgg| _	ddgddfddgddfg| _
ddgdddfg| _tj| jtjd}tj|| tjd||}t|D ]}|| ||< q|| _| j| jjd|| _d S )Nr(   r   rx   r   )r(   rx   r(   rr  rO  r   Zi8FTr   rS   r   i  ra   )r   r  r   r9   r  Ellipsisr'   ra   r  r  not_working_oobnot_working_too_manyr   r   r   r  r   rv   r   r7   r2   r  )rG   MNOrv   datar  r   rP   rQ   r     sR     
zFancySelectionTestCase.setUpc                 C   sR   | j }| j}| jD ]:}tjr&td| || }|| }| t||kd qdS )z5Test for fancy-selections (working selections, read).r  r  N	rv   r  r  r   r)   r*   rD   r'   r  r  rP   rP   rQ   r    s    

z#FancySelectionTestCase.test01a_readc                 C   s6   | j }| jD ]$}tjr td| | t|j| qdS )z9Test for fancy-selections (not working selections, read).r  Nr  r  rP   rP   rQ   r    s
    

z#FancySelectionTestCase.test01b_readc                 C   sL   | j }| j}| jD ]4}tjr&td| | t|j| | t|j| qdS )z7Test for fancy-selections (out-of-bound indexes, read).r  N)	rv   r  r  r   r)   r*   rr   r  r  rG   rv   r  r  rP   rP   rQ   r  	  s    

z#FancySelectionTestCase.test01c_readc                 C   sP   | j }| j}| jD ]8}tjr&td| | ttf|j	| | t|j	| qdS )z3Test for fancy-selections (too many indexes, read).r  N)
rv   r  r  r   r)   r*   rr   r   r  r  r  rP   rP   rQ   r  	  s    

z#FancySelectionTestCase.test01d_readc                 C   sz   | j }| j}| jD ]b}tjr&td| || }|d ||< |d ||< |dd }|dd }| t||kd qdS )z6Test for fancy-selections (working selections, write).r  rx   Nr  r  )rG   rv   r  r  r  rI   rL   rP   rP   rQ   r   	  s    

z$FancySelectionTestCase.test02a_writec                 C   sj   | j }| j}| jD ]R}tjr&td| d||< d||< |dd }|dd }| t||kd qdS )zATest for fancy-selections (working selections, write, broadcast).r  rx   Nr  r  r  rP   rP   rQ   r  1	  s    

z$FancySelectionTestCase.test02b_write)r   r   r   r   r  r  r  r  r  r  r   rP   rP   r   rQ   r    s   <r  c                   @   s   e Zd ZdZdS )FancySelection1r  Nr   r   r   r9   rP   rP   rP   rQ   r  F	  s   r  c                   @   s   e Zd ZdZdS )FancySelection2)rL  r   r   Nr  rP   rP   rP   rQ   r  J	  s   r  c                   @   s   e Zd ZdZdS )FancySelection3)rL  r   r   Nr  rP   rP   rP   rQ   r  O	  s   r  c                   @   s   e Zd ZdZdS )FancySelection4)r   r   r   Nr  rP   rP   rP   rQ   r  T	  s   r  c                       s8   e Zd Z fddZ fddZdd Zdd Z  ZS )	CopyNativeHDF5MDAtomc                    sh   t t|   td}t|d| _| jjj| _t	
d| _tj| jdd| _| jj| jjdd| _d S )Nzarray_mdatom.h5r   r   r   r   arr2)Znewname)r   r  r   r
   r0   r1   r   r2   r5  r.   r/   ry   copyhr  )rG   rJ   r   rP   rQ   r   [	  s    zCopyNativeHDF5MDAtom.setUpc                    s2   | j   | j  t| j tt|   d S rd   )	r   r1  r  rE   rF   ry   r   r  tearDownr   r   rP   rQ   r  d	  s    

zCopyNativeHDF5MDAtom.tearDownc                 C   s,   |  | jj| jj |  | jj| jj dS )z.Checking that native MD atoms are copied as-isN)r<   r5  r=   r  r9   r   rP   rP   rQ   r6  j	  s    z CopyNativeHDF5MDAtom.test01_copyc                 C   sT   | j   tj| jdd| _ | j jj| _| | jj	| jj	 | | jj
| jj
 dS )z8Checking that native MD atoms are copied as-is (re-open)r   r   N)r  r1  r0   r1   ry   r2   r  r<   r5  r=   r9   r   rP   rP   rQ   test02_reopenp	  s
    
z"CopyNativeHDF5MDAtom.test02_reopen)r   r   r   r   r  r6  r  r   rP   rP   r   rQ   r  Y	  s   	r  c                       s4   e Zd Z fddZdd Zdd Zdd Z  ZS )	AccessClosedTestCasec                    s2   t t|   td}| j| jjd|| _d S )Nr   ra   )	r   r   r   r'   r   r   r7   r2   ra   rb   r   rP   rQ   r   |	  s    
zAccessClosedTestCase.setUpc                 C   s   | j   | t| jj d S rd   )r   r1  rr   r   ra   r8   r   rP   rP   rQ   	test_read	  s    
zAccessClosedTestCase.test_readc                 C   s    | j   | t| jjd d S Nr   )r   r1  rr   r   ra   r  r   rP   rP   rQ   test_getitem	  s    
z!AccessClosedTestCase.test_getitemc                 C   s"   | j   | t| jjdd d S r  )r   r1  rr   r   ra   __setitem__r   rP   rP   rQ   test_setitem	  s    
z!AccessClosedTestCase.test_setitem)r   r   r   r   r  r  r  r   rP   rP   r   rQ   r   z	  s   r   c                   @   s   e Zd Zdd ZdS )BroadcastTestc                 C   sx   d}d}t t j|f}t|}| jj| jjd||d}t |}t 	|
|}||d< | t |d |k dS )z<Test correct broadcasting when the array atom is not scalar.)rx   r   r   ra   )r=   r9   r   N)r'   r+   intr   r[   r   r7   r2   r  r   r  rD   all)rG   Zarray_shapeZelement_shaper+   r=   Zh5arrr   rv   rP   rP   rQ   r  	  s    

zBroadcastTest.testNr  rP   rP   rP   rQ   r  	  s   r  c                   @   s   e Zd ZdZdZeddgddggZdZdZ	d	Z
eejZejZd
d Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# ZdS )$TestCreateArrayArgsr   ra   r(   rx   r   r   r-   NFc                 C   s   | j | j| j| j| j | j   t| j	| _ | j 
| j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S rd   )r   r7   r  r   rO   r-   r1  r0   r1   h5fnamer$  r8   r<   r9   r=   r+   rD   r   rG   r\   rv   rP   rP   rQ   test_positional_args	  s    
z(TestCreateArrayArgs.test_positional_argsc              
   C   s   | j | j| jd | j| j| j| j| j | j 	  t
| j| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | tt| j| d S rd   )r   r7   r  r   r-   r;   createparentsr=   r9   r1  r0   r1   r
  r$  r8   r<   r+   rD   r   r'   
zeros_likerO   r  rP   rP   rQ   test_positional_args_atom_shape	  s    
z3TestCreateArrayArgs.test_positional_args_atom_shapec                 C   s   | j j| j| j| j| jd | j   t| j	| _ | j 
| j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S )N)r-   rO   )r   r7   r  r   r-   rO   r1  r0   r1   r
  r$  r8   r<   r9   r=   r+   rD   r   r  rP   rP   rQ   test_kwargs_obj	  s    
z#TestCreateArrayArgs.test_kwargs_objc                 C   s   | j j| j| j| j| j| jd}| j|d< | j   t	
| j| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S )Nr-   r=   r9   .)r   r7   r  r   r-   r=   r9   rO   r1  r0   r1   r
  r$  r8   r<   r+   rD   r   r  rP   rP   rQ   test_kwargs_atom_shape_01	  s    

z-TestCreateArrayArgs.test_kwargs_atom_shape_01c                 C   s   | j j| j| j| j| j| jd}| j   t	| j
| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | tt| j| d S )Nr  )r   r7   r  r   r-   r=   r9   r1  r0   r1   r
  r$  r8   r<   r+   rD   r   r'   r  rO   r  rP   rP   rQ   test_kwargs_atom_shape_02	  s    
z-TestCreateArrayArgs.test_kwargs_atom_shape_02c                 C   s   | j j| j| j| j| j| jd}| j   t	| j
| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S )Nr-   rO   r=   )r   r7   r  r   r-   rO   r=   r1  r0   r1   r
  r$  r8   r<   r9   r+   rD   r   r  rP   rP   rQ   test_kwargs_obj_atom	  s    
z(TestCreateArrayArgs.test_kwargs_obj_atomc                 C   s   | j j| j| j| j| j| jd}| j   t	| j
| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S N)r-   rO   r9   )r   r7   r  r   r-   rO   r9   r1  r0   r1   r
  r$  r8   r<   r=   r+   rD   r   r  rP   rP   rQ   test_kwargs_obj_shape
  s    
z)TestCreateArrayArgs.test_kwargs_obj_shapec                 C   s   | j j| j| j| j| j| j| jd}| j   t	
| j| _ | j | j| j}| }| |j| j | |j| j | |j| j | |jj| jj | t| j| d S Nr-   rO   r=   r9   )r   r7   r  r   r-   rO   r=   r9   r1  r0   r1   r
  r$  r8   r<   r+   rD   r   r  rP   rP   rQ   test_kwargs_obj_atom_shape
  s    
z.TestCreateArrayArgs.test_kwargs_obj_atom_shapec              	   C   s8   t td}| jt| jj| j| j	| j
| j|d d S )Ncomplexr  )r   r[   r'   r+   rr   rs   r   r7   r  r   r-   rO   rG   r=   rP   rP   rQ   test_kwargs_obj_atom_error0
  s    z.TestCreateArrayArgs.test_kwargs_obj_atom_errorc              	   C   s4   | j | j  }| jt| jj| j| j| j| j|d d S r  )	r9   rr   rs   r   r7   r  r   r-   rO   rG   r9   rP   rP   rQ   test_kwargs_obj_shape_error;
  s    z/TestCreateArrayArgs.test_kwargs_obj_shape_errorc              
   C   s<   t td}| jt| jj| j| j	| j
| j|| jd d S Nr  r  )r   r[   r'   r+   rr   rs   r   r7   r  r   r-   rO   r9   r  rP   rP   rQ   #test_kwargs_obj_atom_shape_error_01F
  s    z7TestCreateArrayArgs.test_kwargs_obj_atom_shape_error_01c              
   C   s8   | j | j  }| jt| jj| j| j| j| j| j	|d d S r  )
r9   rr   rs   r   r7   r  r   r-   rO   r=   r  rP   rP   rQ   #test_kwargs_obj_atom_shape_error_02R
  s    z7TestCreateArrayArgs.test_kwargs_obj_atom_shape_error_02c              
   C   sF   t td}| j| j }| jt| jj| j	| j
| j| j||d d S r   )r   r[   r'   r+   r9   rr   rs   r   r7   r  r   r-   rO   )rG   r=   r9   rP   rP   rQ   #test_kwargs_obj_atom_shape_error_03^
  s    z7TestCreateArrayArgs.test_kwargs_obj_atom_shape_error_03)r   r   r   r  r   r'   ra   rO   r-   r;   r  r   r[   r+   r=   r9   r  r  r  r  r  r  r  r  r  r  r!  r"  r#  rP   rP   rP   rQ   r	  	  s*   r	  c                  C   s  t  } d}t|D ]}| t t | t t | t t | t t | t t	 | t t
 | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t | t t  | t t! | t t" | t t# | t t$ | t t% | t t& | t t' | t t( | t t) | t t* | t t+ | t t, | t t- | t t. | t t/ | t t0 | t t1 | t t2 | t t3 | t t4 | t t5 | t t6 | t t7 | t t8 | t t9 | t t: | t t; | t t< q| S )Nr(   )=r	   Z	TestSuiter   ZaddTestZ	makeSuiter   r   r   r   r   r   r   r   r   r   r
  r  r  r  r	  r?  rA  rK  rN  rP  rQ  rS  rT  rU  rV  rW  rX  rY  r[  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r	  r  )ZtheSuiteZniterr  rP   rP   rQ   suitek
  s|    r$  __main__)ZdefaultTest)erE   r>   r.   warningsr'   r   r  r0   r   r   r   Ztables.utilsr   Ztables.testsr   Ztables.tests.commonr   r	   r
   r   ZTestCaser   r   r   r   r   r   r   r   r   r   r   ZTempFileMixinr   r   r   r  r  r  r	  r
  r&  r?  rA  rB  rK  rN  rP  rQ  rS  rT  rU  rV  rW  rX  rY  r[  r\  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r	  r$  r   Z
parse_argvargvZprint_versionsmainrP   rP   rP   rQ   <module>   s      3	
	O O} .N =	  	V	
  ! IF
