B
    i\u                @   s  d dl mZ d dl m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
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 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 d0d1 d1ej%eZ-G d2d3 d3ej%eZ.G d4d5 d5e.Z/G d6d7 d7e.Z0G d8d9 d9ej%eZ1G d:d; d;e1Z2G d<d= d=e1Z3G d>d? d?e1Z4G d@dA dAe1Z5G dBdC dCe1Z6G dDdE dEe1Z7G dFdG dGe1Z8G dHdI dIe1Z9G dJdK dKe1Z:G dLdM dMe1Z;G dNdO dOe1Z<G dPdQ dQe1Z=G dRdS dSej%eZ>G dTdU dUe>eZ?G dVdW dWe?Z@G dXdY dYe?ZAG dZd[ d[e>ZBG d\d] d]eBZCG d^d_ d_eBZDG d`da daej%eZEG dbdc dceEeZFG ddde deeFZGG dfdg dgeFZHG dhdi dieEZIG djdk dkeIZJG dldm dmeIZKG dndo doej%eZLG dpdq dqeLZMG drds dseMZNG dtdu dueMZOG dvdw dweLZPG dxdy dyePZQG dzd{ d{ePZRG d|d} d}ej%eZSG d~d dej%eZTG dd dej%eZUG dd deUZVG dd deUZWG dd deUZXG dd deUZYG dd deUZZG dd dej%eZ[G dd de[Z\G dd de[Z]G dd de[Z^G dd de[Z_G dd deZ`G dd dej%eZaG dd dej%eZbG dd dej%eZcdd Zdeedkrefejg eh  ejidd dS )    )print_function)absolute_importN)testing)AtomClosedNodeErrorNoSuchNodeError)
byteorders)common)allequal)unittesttest_filename)PyTablesTestCase)rangec               @   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}zXtj	|dd	F}|j
}| jr|jjd
kr| }|j |_|}||d|d W d Q R X tj	|dd	}|j
}|j }t jrPt||sPt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rPt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rj|jd }
nd}
| |	j|
 | t|| W d Q R X W d t !| X d S )N
z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z%Running test for array with type '%s' )endzfor class check:z.h5w)modeS	somearrayz
Some arrayrzWrite and read arrays differ!zArray written shape:zArray written itemsize:zArray written type:zArray read shape:zArray read itemsize:zArray read type:zArray written byteorder:z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filehr%   babobboobjr6    rC   6lib/python3.7/site-packages/tables/tests/test_array.py
write_read$   sl    




zBasicTestCase.write_readc       	   	   C   s  |}t jr4tdd td|jj dd td| j td}zptj	|dd	F}|j
}| jr|jjd
kr| }|j |_|}||d|d W d Q R X 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 Q R X W d t| X d S )Nr   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z%Running test for array with type '%s'r   )r   zfor class check:z.h5r   )r   r   r   z
Some arrayr   )r   )outr   r   )r	   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r   
empty_liker   r+   r/   r,   r0   r   r.   r2   r1   r7   r
   r8   r9   )	r:   r;   r<   r=   r>   r%   r?   r@   rA   rC   rC   rD   write_read_out_args   sF    



z BasicTestCase.write_read_out_argc          	   C   s  |}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krt|	jj }|	}|j|d||d|d}
| ||
j | ||
j ||
d< W d Q R X 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rl| ||jj | |tj | jrl| || |j}| |jd | |j|j | |j|j | |jd  |jr|jd }nd}| |j | | !t||	 W d Q R X W d t"#| X d S )Nr   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z%Running test for array with type '%s'r   )r   zfor class check:z.h5r   )r   r   )><r   z
Some array)r0   r,   r    r.   .r   zWrite and read arrays differ!zArray written shape:zArray written itemsize:zArray written type:zArray read shape:zArray read itemsize:zArray read type:zArray written byteorder:zArray read byteorder:r   r   r   r   r   )$r   
from_dtyper   r,   r	   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r.   r   r*   r/   r0   r   r+   r
   r-   r1   r2   r3   r4   r5   r6   r7   r8   r9   )r:   r;   r<   r0   r,   r.   r=   r>   r%   r?   ptarrr@   rA   rB   r6   rC   rC   rD   write_read_atom_shape_args   s    




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   )r   )
isinstance	tupleCharr   ndarrayarray)r:   r<   rC   rC   rD   setup00_char  s    zBasicTestCase.setup00_charc             C   s   |   }| | d S )N)rR   rE   )r:   r<   rC   rC   rD   test00_char  s    zBasicTestCase.test00_charc             C   s   |   }| | d S )N)rR   rH   )r:   r<   rC   rC   rD   test00_char_out_arg  s    z!BasicTestCase.test00_char_out_argc             C   s   |   }| | d S )N)rR   rM   )r:   r<   rC   rC   rD   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Q R X tj|ddR}|jj }t	|t
r| t|t
 | || n| t|ttjgk W dQ R X W dt| X dS )z/Data integrity during recovery (string objects)z.h5r   )r   r   z
Some arrayNr   )rO   r!   r"   r#   r$   r*   r%   r   r+   rN   bytesr/   r   r7   listr   rP   r8   r9   )r:   r<   r=   r>   r?   rC   rC   rD   test00b_char  s    

&zBasicTestCase.test00b_charc          	      s   | j }td}ztj|ddjd|d W dQ R X tj|ddXt| jj	j
dkr~| t fd	d
 njj	j d | t tj W dQ R X W dt| X dS )z/Data integrity during recovery (string objects)z.h5r   )r   r   z
Some arrayNr   r   c                  s   j jj dS )N)rF   )r%   r   r+   rC   )r?   r>   rC   rD   <lambda>G  s    z4BasicTestCase.test00b_char_out_arg.<locals>.<lambda>)rF   )rO   r!   r"   r#   r$   r*   r%   r   rG   r   r3   assertRaises	TypeErrorr+   r7   r   rP   r8   r9   )r:   r<   r=   rC   )r?   r>   rD   test00b_char_out_arg6  s    

 z"BasicTestCase.test00b_char_out_argc          	      s$  | j }td}z tj|dd|t|}t|j	}|j
}|j	jdkrZt|j	j }nd}jjd|||dd}| ||j
 | ||j ||d	< W dQ R X tj|d
dXt| jjjdkr| t fdd njjj d | t tj W dQ R X W dt| X dS )z/Data integrity during recovery (string objects)z.h5r   )r   )rI   rJ   Nr   z
Some array)r0   r,   r.   r    .r   r   c                  s   j jj dS )N)rF   )r%   r   r+   rC   )r?   r>   rC   rD   rY   n  s    z<BasicTestCase.test00b_char_atom_shape_args.<locals>.<lambda>)rF   )rO   r!   r"   r#   r$   r   Zasarrayr   rK   r   r,   r.   r   r*   r%   r/   r0   rG   r   r3   rZ   r[   r+   r7   r   rP   r8   r9   )r:   r<   r=   nparrr0   r,   r.   rL   rC   )r?   r>   rD   test00b_char_atom_shape_argsO  s2    



 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   )r   r   N   r   F)rN   rO   r   rP   rQ   r4   copylenr/   flags
contiguous)r:   r<   r?   rC   rC   rD   setup01_char_ncv  s    

zBasicTestCase.setup01_char_ncc             C   s   |   }| | d S )N)rd   rE   )r:   r?   rC   rC   rD   test01_char_nc  s    zBasicTestCase.test01_char_ncc             C   s   |   }| | d S )N)rd   rH   )r:   r?   rC   rC   rD   test01_char_nc_out_arg  s    z$BasicTestCase.test01_char_nc_out_argc             C   s   |   }| | d S )N)rd   rM   )r:   r?   rC   rC   rD   test01_char_nc_atom_shape_args  s    z,BasicTestCase.test01_char_nc_atom_shape_argsc             C   s   ddddddddd	d
ddg}x,dD ]$}|  d }tt|r"|| q"W xT|D ]L}t| j|}| | t| j|}| | t| j|}| 	| qPW dS )z0Data integrity during recovery (numerical types)int8int16int32int64uint8uint16uint32uint64float32float64	complex64
complex128)float16float96float128
complex192
complex256r   N)

capitalizehasattrr#   appendr   rQ   tupleIntrE   rH   rM   )r:   	typecodesnameatomnametypecoder<   r?   crC   rC   rD   test02_types  s    




zBasicTestCase.test02_typesc       	      C   s,  ddddddddd	d
ddg}x,dD ]$}|  d }tt|r"|| q"W x|D ]}t| j|}|jdkr| }| }| }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 | | | | | | qPW dS )z?Data integrity during recovery (non-contiguous numerical types)rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   )rt   ru   rv   rw   rx   r   r   Nr_   r   F)ry   rz   r#   r{   r   rQ   r|   r4   r`   ra   r/   rb   rc   rE   rH   rM   )	r:   r}   r~   r   r   r<   b1Zb2Zb3rC   rC   rD   test03_types_nc  s4    






zBasicTestCase.test03_types_ncN)__name__
__module____qualname____doc__r&   rE   rH   rM   rR   rS   rT   rU   rX   r\   r^   rd   re   rf   rg   r   r   rC   rC   rC   rD   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|   rO   r&   rC   rC   rC   rD   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   33TN)r   r   r   r    r|   rO   r&   rC   rC   rC   rD   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )Basic1DZeroTestCasezRank-1 case 0rC   FN)r   r   r   r    r|   rO   r&   rC   rC   rC   rD   r     s   r   c               @   s   e Zd ZdZdZdZdZdS )Basic1DOneTestCasezRank-1 case 1)r   )   aTN)r   r   r   r    r|   rO   r&   rC   rC   rC   rD   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      )s   aaaTN)r   r   r   r    r|   rO   r&   rC   rC   rC   rD   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      )s   aaas   bbbTN)r   r   r   r    r|   rO   r&   rC   rC   rC   rD   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	   S3)r   )r   r   TN)r   r   r   r    r   rQ   aranger|   r,   rO   r&   rC   rC   rC   rD   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   )r   r   r   )r   )r   TN)r   r   r   r    r   rQ   r   Zint_r|   rO   r&   rC   rC   rC   rD   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   )
r_   r_   r_   r_   r_   r_   r_   r_   r_   r_   r   r   )r   TN)r   r   r   r    r   rQ   r   r|   r,   rO   r&   rC   rC   rC   rD   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   )r   N)	r   r   r   r    r   rQ   r|   r,   rO   rC   rC   rC   rD   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 )Ni  )superr   setUpsize)r:   )	__class__rC   rD   r   %  s    zReadOutArgumentTests.setUpc             C   s(   t j| jdd}| jdd|}||fS )Nf8)r   /rQ   )r   r   r   h5filer*   )r:   rQ   
disk_arrayrC   rC   rD   r*   )  s    z!ReadOutArgumentTests.create_arrayc             C   s:   |   \}}t| jfd}|j|d tj|| d S )Nr   )rF   )r*   r   emptyr   r+   r   assert_equal)r:   rQ   r   
out_bufferrC   rC   rD   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   )r   r_   )startstoprF   )
r*   r   r   r   randompermutationr`   r+   r   r   )r:   rQ   r   r   out_buffer_origr   rC   rC   rD   test_read_contiguous_slice14  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   )r   r   )r   r   rF   )
r*   r   r   r   r   r   r`   r+   r   r   )r:   rQ   r   r   r   r   r   rC   rC   rD   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 )Nr_   r   )r   r   )r   r   steprF   )r*   r   r   r   r+   r   r   )r:   rQ   r   r   rC   rC   rD   0test_read_non_contiguous_slice_contiguous_bufferJ  s    zEReadOutArgumentTests.test_read_non_contiguous_slice_contiguous_bufferc          
   C   s   |   \}}t| jfd}|d| jd }| t|jd| jd| y|d| jd| W n2 tk
r } z| dt| W d d }~X Y nX d S )Nr   r   r_   zoutput array not C contiguous)	r*   r   r   r   rZ   
ValueErrorr+   r/   str)r:   rQ   r   r   Zout_buffer_sliceexcrC   rC   rD   test_read_non_contiguous_bufferP  s    z4ReadOutArgumentTests.test_read_non_contiguous_bufferc          
   C   s   |   \}}t| jd fd}| t|jd| jd| y|d| jd| W n4 tk
r } z| dt|k W d d }~X Y nX d S )Nr_   r   r   r   zoutput array size invalid, got)	r*   r   r   r   rZ   r   r+   r7   r   )r:   rQ   r   r   r   rC   rC   rD   test_buffer_too_small]  s    z*ReadOutArgumentTests.test_buffer_too_smallc          
   C   s   |   \}}t| jd fd}| t|jd| jd| y|d| jd| W n4 tk
r } z| dt|k W d d }~X Y nX d S )Nr   r   r   zoutput array size invalid, got)	r*   r   r   r   rZ   r   r+   r7   r   )r:   rQ   r   r   r   rC   rC   rD   test_buffer_too_largeg  s    z*ReadOutArgumentTests.test_buffer_too_large)r   r   r   r   r*   r   r   r   r   r   r   r   __classcell__rC   rC   )r   rD   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   r*   r   zerosrQ   )r:   )r   rC   rD   r   t  s    z(SizeOnDiskInMemoryPropertyTestCase.setUpc             C   s$   |  | jjd |  | jjd d S )Ni  )r/   rQ   Zsize_on_diskZsize_in_memory)r:   rC   rC   rD   test_all_zerosz  s    z1SizeOnDiskInMemoryPropertyTestCase.test_all_zeros)r   r   r   r   r   r   rC   rC   )r   rD   r   r  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 )N)r   r   r   r   r%   )r:   )r   rC   rD   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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z&
Running test for array with type '%s'biglittle)r   r   r   z
Some array)r.   zWrite and read arrays differ!zArray written:zArray written shape:zArray written itemsize:zArray written type:zArray read:zArray read shape:zArray read itemsize:zArray read type:|)r	   r   r   r   r   r&   r1   r.   r   r*   r%   reopen_reopenr   r+   r)   r
   r,   r-   r/   r0   r   r7   )r:   Z	testArrayr<   r.   r?   r   rC   rC   rD   rE     sB    




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 arrays   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazi1,f4,i2r   )formatsr,   f2FN)
r   recrQ   r/   rb   alignedr   r   ri   rE   )r:   r   r<   rC   rC   rD   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 arrays   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazi1,f4,i2r   )r   r,   f1r   N)
r   r   rQ   r/   rb   r   r   r   rp   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rh   r,   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rn   r,   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rj   r,   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rk   r,   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rp   r,   rE   )r:   r   r<   rC   rC   rD   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   )r   )r   r   r_   N)r   r   rq   r,   rE   )r:   r   r<   rC   rC   rD   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 arrays   aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz	i1,3f4,i2r   )r   r,   r   r   FN)
r   r   rQ   r/   rb   r   r   r   rp   rE   )r:   r   r<   rC   rC   rD   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   r   FN)
r   r   rQ   r/   rb   r   r   r   rq   rE   )r:   r   r<   rC   rC   rD   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)   )r   r   rQ   zbyteorder (int)r_   r   r   .zbyteorder of array on disk-->zbyteorder of subarray-->zsubarray-->zretrieved array-->N)r   r   rj   reshaper(   r)   r   r*   r%   r	   r   r   r.   r   r7   r
   )r:   r<   rQ   r?   r   rC   rC   rD   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   )r   r   rQ   zbyteorder (float)r_   r   r   .zbyteorder of array on disk-->zbyteorder of subarray-->zsubarray-->zretrieved array-->N)r   r   rq   r   r(   r)   r   r*   r%   r	   r   r   r.   r   r7   r
   )r:   r<   rQ   r?   r   rC   rC   rD   test12_float_byteorder0  s&    

z2UnalignedAndComplexTestCase.test12_float_byteorder)r   r   r   r   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   rC   rC   )r   rD   r     s   1



r   c               @   s   e Zd ZdZdZdS )!ComplexNotReopenNotEndianTestCaseFN)r   r   r   r&   r   rC   rC   rC   rD   r   M  s   r   c               @   s   e Zd ZdZdZdS )ComplexReopenNotEndianTestCaseFTN)r   r   r   r&   r   rC   rC   rC   rD   r   R  s   r   c               @   s   e Zd ZdZdZdS )ComplexNotReopenEndianTestCaseTFN)r   r   r   r&   r   rC   rC   rC   rD   r   W  s   r   c               @   s   e Zd ZdZdZdS )ComplexReopenEndianTestCaseTN)r   r   r   r&   r   rC   rC   rC   rD   r   \  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}dddddd	d
ddddddg}ttdrZ|	d ttdsnttdrx|	d ttdsttdr|	d xft
|D ]Z\}}td|}d| }t jrtd|| | j|||d | j|dt| }qW |   | jj}xt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W d%S )&z,Checking combinations of arrays with groups.r   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z$Running %s.test00_iterativeGroups...r?   BhHiIlLqfdFDZFloat16AtomeZFloat96AtomZFloat128AtomgZComplex192AtomZComplex256AtomG)r   Zarray_zCreating dataset:zLarge arraygroupzInfo from dataset:z  shape ==>r   )r   z  type ==> %sz"Array b read from file. Shape: ==>z. Type ==> %sN)r	   r   r   r   r   r   r%   rz   r#   r{   	enumerater   onesZ_g_joinr*   create_groupr   r   r   ra   getattrr+   _v_pathnamer,   r0   r   r/   r7   r
   )	r:   r   r}   r   r   r<   ZdsetnameZdsetr?   rC   rC   rD   test00_iterativeGroupsd  sJ    






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	 xjt||d D ]X}t	d
| tj
}t jrtd| dd	 | j|d|d|  | j|dt| }q\W |   | jj}t jrt  td xt||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| }qW t 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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z$Running %s.test01_largeRankArrays...zMaximum rank for tested arrays:zRank array writing progress: r   )r   )r   z%3d,rQ   zRank: %sr   zRank array reading progress: zInfo from dataset:z  Shape: ==>z  typecode ==> %cz"Array b read from file. Shape: ==>z. Type ==> %cN)r	   r   r   r   r   r   r%   r   r   r   rj   r*   r   r   r   rQ   r+   r
   r   r,   r   r   r/   r7   get_node)r:   ZminrankZmaxrankr   Zrankr<   r?   rC   rC   rD   test01_largeRankArrays  sL    


z*GroupsArrayTestCase.test01_largeRankArraysN)r   r   r   r   r   r   rC   rC   rC   rD   r   a  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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test01_copy...i  r_   r   i  ri   )r   array1ztitle array1r   array2z(closing file version)z	array1-->z	array2-->zattrs array1-->zattrs array2-->N)r	   r   r   r   r   r   rQ   r   r*   r%   r`   closer   r   r   r+   reprattrsr7   r
   r/   r6   r3   r0   r   r    )r:   arrr   r   rC   rC   rD   test01_copy  s.    


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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test02_copy...i  r_   r   i  ri   )r   r   ztitle array1r   group1r   z(closing file version)z	array1-->z	array2-->zattrs array1-->zattrs array2-->N)r	   r   r   r   r   r   rQ   r   r*   r%   r   r`   r   r   r   r  r   r+   r   r   r7   r
   r/   r6   r3   r0   r   r    )r:   r   r   r  r   rC   rC   rD   test02_copy  s0    

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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test04_copy...i  r_   r   i  ri   )r   r   ztitle array1attr1r   r   ztitle array2)r    z(closing file version)ztitle of destination array-->N)r	   r   r   r   r   r   rQ   r   r*   r%   r   r  attr2r`   r   r   r   r   r    r/   )r:   r   r   r   rC   rC   rD   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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test05_copy...i  r_   r   i  ri   )r   r   ztitle array1r  r   r   r   )copyuserattrsz(closing file version)zattrs array1-->zattrs array2-->N)r	   r   r   r   r   r   rQ   r   r*   r%   r   r  r  r`   r   r   r   r   r   r/   )r:   r   r   r   rC   rC   rD   test04_copyJ  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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test05b_copy...i  r_   r   i  ri   )r   r   ztitle array1r  r   r   r   )r  z(closing file version)zattrs array1-->zattrs array2-->r  N)r	   r   r   r   r   r   rQ   r   r*   r%   r   r  r  r`   r   r   r   r   r   r/   rz   )r:   r   r   r   rC   rC   rD   test04b_copyj  s(    


zCopyTestCase.test04b_copyN)r   r   r   r   r  r  r  r  rC   rC   rC   rD   r     s
   &' r   c               @   s   e Zd ZdZdS )CloseCopyTestCaser   N)r   r   r   r   rC   rC   rC   rD   r	    s   r	  c               @   s   e Zd ZdZdS )OpenCopyTestCaser   N)r   r   r   r   rC   rC   rC   rD   r
    s   r
  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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=zRunning %s.test01_index...   rj   )r   )r   r_   r   ztitle array1r   r   )r   r   r   z	array1-->z	array2-->zattrs array1-->zattrs array2-->znrows in array2-->zand it should be-->r   N)r	   r   r   r   r   r   r   r,   r   r*   r%   r`   r   r   r   r+   r   r   r7   r
   r6   r/   )r:   r   r   r   r2rC   rC   rD   test01_index  s,    

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   z<-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=z Running %s.test02_indexclosef...r  rj   )r   )r   r_   r   ztitle array1r   r   )r   r   r   z	array1-->z	array2-->zattrs array1-->zattrs array2-->znrows in array2-->zand it should be-->r   N)r	   r   r   r   r   r   r   r,   r   r*   r%   r`   r   r   r   r   r   r   r+   r   r   r7   r
   r6   r/   )r:   r   r   r   r  rC   rC   rD   test02_indexclosef  s2    



z$CopyIndexTestCase.test02_indexclosefN)r   r   r   r  r  rC   rC   rC   rD   r    s   #r  c               @   s   e Zd ZdZdZdZdS )CopyIndex1TestCaser      r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex2TestCaser   r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex3TestCaser   r  N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex4TestCaser      r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex5TestCaser   r  r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex6TestCaser   r  r_   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex7TestCaser   r  r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex8TestCaser  r  r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex9TestCaser   r   r   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex10TestCaser   r   r_   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex11TestCaser  r_   N)r   r   r   r   r   r   rC   rC   rC   rD   r    s   r  c               @   s   e Zd ZdZdZdZdS )CopyIndex12TestCaser  Nr   )r   r   r   r   r   r   rC   rC   rC   rD   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   z
Some arrayzOriginal first element:r   zRead first element:N)charListr   r*   r%   r   r   r   r	   r   r   r   r7   r
   r/   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal first element:r   zRead first element:N)numericalListr   r*   r%   r   r   r   r	   r   r   r   r/   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal elements:r   r   zRead elements:N)
charListMEr   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   test02_rangeQ  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   z
Some arrayzOriginal elements:r   r   zRead elements:N)numericalListMEr   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   test03_rangec  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   z
Some arrayzOriginal elements:r   r   r_   zRead elements:N)r%  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   test04_rangeu  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   z
Some arrayzOriginal elements:r   r   r_   zRead elements:N)r'  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal last element:r  zRead last element:N)r%  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal before last element:zRead before last element:N)r'  r   r*   r%   r   r   r   r	   r   r   rN   r   rP   r7   r
   r/   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal last elements:r  zRead last elements:N)r%  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   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   z
Some arrayzOriginal last elements:r.  r  zRead last elements:N)r'  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   test09_negativeRange  s    
z$GetItemTestCase.test09_negativeRangeN)r   r   r   r"  r$  r&  r(  r)  r*  r+  r-  r/  r0  rC   rC   rC   rD   r   )  s   r   c            	   @   s\   e Zd ZdZedgZedddddddgZed	gd
Zedddddddgd
Z	dS )GI1NATestCasezRank-1 case 1r   r_   r   r   r   r   r  3r   321221r   021421521621N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   r1    s   r1  c               @   s   e Zd ZdZdS )GI1NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   r9    s   r9  c               @   s   e Zd ZdZdS )GI1NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   r:    s   r:  c               @   s   e Zd ZdZeddgZedddddddgddddddd	gdddddddgdddddddgdddddddggZed
dgdZedddddddgdddddddgdddddddgdddddddgdddd d!d"d#gd$d%d&d'd(d)d*ggdZ	d+S ),GI2NATestCasezRank-1,2 case 2r   r   r_   r   r   r   r  r  r<   r?   r   r3  r4  r   r5  r6  r7  r8  2111024261311241513241232113216062144215421a621a321s221d121g021b4215vvv216zxzxs21N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   r;    s"   
r;  c               @   s   e Zd ZdZdS )GI2NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   rS    s   rS  c               @   s   e Zd ZdZdS )GI2NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   rT    s   rT  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   z
Some arrayr<      br   zOriginal first element:zRead first element:N)r!  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   r"    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   z
Some arrayr<   iM  r   zOriginal first element:zRead first element:N)r#  r   r*   r%   r   r   r   r	   r   r   r/   )r:   r<   r   rC   rC   rD   r$  ,  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   z
Some arrayr<   s   xXxr   r   zOriginal elements:r   zRead elements:N)r%  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rC   rC   rD   r&  B  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   z
Some arrayr<   r   r   Nr_   zOriginal elements:r   zRead elements:)r'  r   r*   r%   r   r   r   slicer   r   r   r,   r	   r   r   r7   r
   )r:   r<   r   srngrC   rC   rD   r(  X  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   z
Some arrayr<   r   r   r_   s   xXxzOriginal elements:zRead elements:N)r%  r   r*   r%   r   r   r   rW  r	   r   r   r7   r
   )r:   r<   r   rX  rC   rC   rD   r)  q  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   z
Some arrayr<   r   r   r_   r   zOriginal elements:zRead elements:N)r'  r   r*   r%   r   r   r   rW  r   r   r   r,   r	   r   r   r7   r
   )r:   r<   r   rX  rY  rC   rC   rD   r*    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   z
Some arrayr<   r  s   xXxzOriginal last element:zRead last element:N)r%  r   r*   r%   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rX  rC   rC   rD   r+    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   z
Some arrayr<   r,  r_   r   zOriginal before last element:zRead before last element:N)r'  r   r*   r%   r   r   r   r	   r   r   rN   r   rP   r7   r
   r/   )r:   r<   r   rX  rC   rC   rD   r-    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   z
Some arrayr<   r.  r  Ns   xXxzOriginal last elements:zRead last elements:)r%  r   r*   r%   r   r   r   rW  r	   r   r   r7   r
   )r:   r<   r   rX  rC   rC   rD   r/    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   z
Some arrayr<   r  r  Nr_   r   zOriginal last elements:r.  zRead last elements:)r'  r   r*   r%   r   r   r   rW  r   r   r   r,   r	   r   r   r7   r
   )r:   r<   r   rX  rY  rC   rC   rD   r0    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   z
Some arrayr<   r   r   Ni  r_   r   zOriginal last elements:r.  r  zRead last elements:)r'  r   r*   r%   r   r   r   rW  r,   r   r   r   r	   r   r   r7   r
   )r:   r<   r   rX  s2rY  Zrng2rC   rC   rD   test10_outOfRange  s$    

z!SetItemTestCase.test10_outOfRangeN)r   r   r   r"  r$  r&  r(  r)  r*  r+  r-  r/  r0  r[  rC   rC   rC   rD   rU    s   rU  c            	   @   s\   e Zd ZdZedgZedddddddgZed	gd
Zedddddddgd
Z	dS )SI1NATestCasezRank-1 case 1r   r_   r   r   r   r   r  r2  r   r3  r4  r   r5  r6  r7  r8  N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   r\    s   r\  c               @   s   e Zd ZdZdS )SI1NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   r]  (  s   r]  c               @   s   e Zd ZdZdS )SI1NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   r^  ,  s   r^  c               @   s   e Zd ZdZeddgZedddddddgddddddd	gdddddddgdddddddgdddddddggZed
dgdZedddddddgdddddddgdddddddgdddddddgdddd d!d"d#gd$d%d&d'd(d)d*ggdZ	d+S ),SI2NATestCasezRank-1,2 case 2r   r   r_   r   r   r   r  r  r<   r?   r   r3  r4  r   r5  r6  r7  r8  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   r_  0  s"   
r_  c               @   s   e Zd ZdZdS )SI2NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   r`  F  s   r`  c               @   s   e Zd ZdZdS )SI2NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   ra  J  s   ra  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   z
Some arrayc             S   s   g | ]}|qS rC   rC   ).0r   rC   rC   rD   
<listcomp>]  s    z4GeneratorTestCase.test00a_single.<locals>.<listcomp>c             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd  ^  s    zResult of original iterator:zResult of read generator:N)r!  r   r*   r%   r   r   r   r	   r   r   r/   )r:   r<   r   gagarrrC   rC   rD   test00a_singleP  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| x,t
t|D ]}| t|| ||  qxW dS )	z<Testing generator access to Arrays, multiple elements (char)r   z
Some arrayc             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd  q  s    z0GeneratorTestCase.test00b_me.<locals>.<listcomp>c             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd  r  s    zResult of original iterator:zResult of read generator:N)r%  r   r*   r%   r   r   r   r	   r   r   r   ra   r7   r
   )r:   r<   r   re  rf  r   rC   rC   rD   
test00b_med  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   z
Some arrayc             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd    s    z4GeneratorTestCase.test01a_single.<locals>.<listcomp>c             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd    s    zResult of original iterator:zResult of read generator:N)r#  r   r*   r%   r   r   r   r	   r   r   r/   )r:   r<   r   re  rf  rC   rC   rD   test01a_singlez  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| x,t
t|D ]}| t|| ||  qxW dS )	z?Testing generator access to Arrays, multiple elements (numeric)r   z
Some arrayc             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd    s    z0GeneratorTestCase.test01b_me.<locals>.<listcomp>c             S   s   g | ]}|qS rC   rC   )rc  r   rC   rC   rD   rd    s    zResult of original iterator:zResult of read generator:N)r'  r   r*   r%   r   r   r   r	   r   r   r   ra   r7   r
   )r:   r<   r   re  rf  r   rC   rC   rD   
test01b_me  s    


zGeneratorTestCase.test01b_meN)r   r   r   rg  rh  ri  rj  rC   rC   rC   rD   rb  N  s   rb  c            	   @   s\   e Zd ZdZedgZedddddddgZed	gd
Zedddddddgd
Z	dS )GE1NATestCasezRank-1 case 1r   r_   r   r   r   r   r  r2  r   r3  r4  r   r5  r6  r7  r8  N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   rk    s   rk  c               @   s   e Zd ZdZdS )GE1NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   rl    s   rl  c               @   s   e Zd ZdZdS )GE1NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   rm    s   rm  c               @   s   e Zd ZdZeddgZedddddddgddddddd	gdddddddgdddddddgdddddddggZed
dgdZedddddddgdddddddgdddddddgdddddddgdddd d!d"d#gd$d%d&d'd(d)d*ggdZ	d+S ),GE2NATestCasezRank-1,2 case 2r   r   r_   r   r   r   r  r  r<   r?   r   r3  r4  r   r5  r6  r7  r8  r<  r=  r>  r?  r@  rA  rB  rC  rD  rE  rF  rG  rH  rI  rJ  rK  rL  rM  rN  rO  rP  rQ  rR  N)
r   r   r   r    r   rQ   r#  r'  r!  r%  rC   rC   rC   rD   rn    s"   
rn  c               @   s   e Zd ZdZdS )GE2NAOpenTestCaser   N)r   r   r   r   rC   rC   rC   rD   ro    s   ro  c               @   s   e Zd ZdZdS )GE2NACloseTestCaser   N)r   r   r   r   rC   rC   rC   rD   rp    s   rp  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   r_   r   z/testN)rZ   r   r[   r   r*   r   Zremove_node)r:   rC   rC   rD   rr    s    
zNonHomogeneousTestCase.testN)r   r   r   rr  rC   rC   rC   rD   rq    s   rq  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   r_   N)r   r*   rZ   r[   truncate)r:   r   rC   rC   rD   rr    s    zTruncateTestCase.testN)r   r   r   rr  rC   rC   rC   rD   rs    s   rs  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|   ddddg| _t| j}tj|tjd	| j}|| _
| j| jjd|| _d S )N)r   r   )   i)ir   )r   r   )r   rQ   )r   ru  r   limitsr   prodr,   r   rj   r   r]   r   r*   r%   tbarr)r:   r   r]   )r   rC   rD   r     s    zPointSelectionTestCase.setUpc             C   sj   | j }| j}xX| jD ]N\}}||k||k @ }tjr<td| || }|| }| t||kd qW dS )z/Test for point-selections (read, boolean keys).zSelection to test:z3NumPy array and PyTables selections does not match.N)	r]   ry  rw  r	   r   r   r7   r   alltrue)r:   r]   ry  value1value2keyr<   r?   rC   rC   rD   test01a_read  s    
z#PointSelectionTestCase.test01a_readc             C   sp   | j }| j}x^| jD ]T\}}t||k||k @ }tjrBtd| || }|| }| t	||kd qW dS )z/Test for point-selections (read, integer keys).zSelection to test:z3NumPy array and PyTables selections does not match.N)
r]   ry  rw  r   wherer	   r   r   r7   rz  )r:   r]   ry  r{  r|  r}  r<   r?   rC   rC   rD   test01b_read  s    
z#PointSelectionTestCase.test01b_readc             C   sj   | j }| j}xX| jD ]N\}}t||k||k @ }tjrBtd| t|d}| 	t
tf|j| qW dS )z-Test for point-selections (read, float keys).zSelection to test:Zf4N)r]   ry  rw  r   r  r	   r   r   rQ   rZ   
IndexErrorr[   __getitem__)r:   r]   ry  r{  r|  r}  ZfkeyrC   rC   rD   test01c_read  s    
z#PointSelectionTestCase.test01c_readc             C   s`   | j }| j}xN| jD ]D}|jdkr*t|}tjr:td| || }|| }t	||d qW d S )Nr   zSelection to test:z3NumPy array and PyTables selections does not match.)
r]   ry  working_keysetr4   tupler	   r   r   nptZassert_array_equal)r:   r]   ry  r}  r<   r?   rC   rC   rD   test01d_read"  s    

z#PointSelectionTestCase.test01d_readc             C   s:   | j }x.| jD ]$}tjr"td| | t|j| qW d S )NzSelection to test:)ry  not_working_keysetr	   r   r   rZ   r  r  )r:   ry  r}  rC   rC   rD   test01e_read0  s
    
z#PointSelectionTestCase.test01e_readc       	      C   s   | j }| j}x| jD ]v\}}||k||k @ }tjr<td| || }|d ||< |d ||< |dd }|dd }| t||kd qW dS )z0Test for point-selections (write, boolean keys).zSelection to test:r_   Nz6NumPy array and PyTables modifications does not match.)	r]   ry  rw  r	   r   r   r7   r   rz  )	r:   r]   ry  r{  r|  r}  rX  r<   r?   rC   rC   rD   test02a_write9  s    
z$PointSelectionTestCase.test02a_writec       	      C   s   | j }| j}x| jD ]|\}}t||k||k @ }tjrBtd| || }|d ||< |d ||< |dd }|dd }| t	||kd qW dS )z0Test for point-selections (write, integer keys).zSelection to test:r_   Nz6NumPy array and PyTables modifications does not match.)
r]   ry  rw  r   r  r	   r   r   r7   rz  )	r:   r]   ry  r{  r|  r}  rX  r<   r?   rC   rC   rD   test02b_writeK  s    
z$PointSelectionTestCase.test02b_writec             C   s   | j }| j}xv| jD ]l\}}t||k||k @ }tjrBtd| d||< d||< |dd }|dd }| t	||kd qW dS )z=Test for point-selections (write, integer values, broadcast).zSelection to test:r_   Nz6NumPy array and PyTables modifications does not match.)
r]   ry  rw  r   r  r	   r   r   r7   rz  )r:   r]   ry  r{  r|  r}  r<   r?   rC   rC   rD   test02c_write]  s    
z$PointSelectionTestCase.test02c_write)r   r   r   r   r~  r  r  r  r  r  r  r  r   rC   rC   )r   rD   ru    s   	ru  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 )	PointSelection0)r   r   r   r  r   r   r.  N)r   r   r   r,   r  r  rC   rC   rC   rD   r  p  s   
r  c               @   sH   e Zd ZdZdddgdddggZdddgdddgdddgdddggZd	S )
PointSelection1)r   r   r   )r   r   )r   r   )r   r  )r   r   )r   r   )r   r.  )r   N)r   r   r   r,   r  r  rC   rC   rC   rD   r  }  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)r  r   )r   r   )r   r   )r   r  )r   r,  )r   r   )r   r   )r   r.  )r   r  N)r   r   r   r,   r  r  rC   rC   rC   rD   r    s   
r  c               @   sJ   e Zd ZdZddddgddddggZddddgddddgddddggZdS )	PointSelection3)r   r   r_   r   )r   r   )r   r   )r   r  )r   r   )r   r   )r   r.  N)r   r   r   r,   r  r  rC   rC   rC   rD   r    s   


r  c               @   sT   e Zd ZdZdddddgdddddggZdddddgdddddgdddddggZdS )	PointSelection4)r   r   r_   r   r  )r   r   )r   r   )r   r  )r   r   )r   r   )r   r.  N)r   r   r   r,   r  r  rC   rC   rC   rD   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dddg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||}xt|D ]}|| ||< qW || _| j| jjd|| _d S )Nr   r   r_   r   )r   r_   r   r,  r  r   Zi8FTr   )r   i  i  rQ   )r   r  r   r,   rW  Ellipsisr   rQ   r  r  not_working_oobnot_working_too_manyr   rj   r   r   r   r]   r   r*   r%   ry  )r:   MNOr]   datar   )r   rC   rD   r     s>     
zFancySelectionTestCase.setUpc             C   sV   | j }| j}xD| jD ]:}tjr(td| || }|| }| t||kd qW dS )z5Test for fancy-selections (working selections, read).zSelection to test:z3NumPy array and PyTables selections does not match.N)	r]   ry  r  r	   r   r   r7   r   rz  )r:   r]   ry  r}  r<   r?   rC   rC   rD   r~    s    
z#FancySelectionTestCase.test01a_readc             C   s:   | j }x.| jD ]$}tjr"td| | t|j| qW dS )z9Test for fancy-selections (not working selections, read).zSelection to test:N)ry  r  r	   r   r   rZ   r  r  )r:   ry  r}  rC   rC   rD   r  	  s
    
z#FancySelectionTestCase.test01b_readc             C   sP   | j }| j}x>| jD ]4}tjr(td| | t|j| | t|j| qW dS )z7Test for fancy-selections (out-of-bound indexes, read).zSelection to test:N)	r]   ry  r  r	   r   r   rZ   r  r  )r:   r]   ry  r}  rC   rC   rD   r  	  s    
z#FancySelectionTestCase.test01c_readc             C   sT   | j }| j}xB| jD ]8}tjr(td| | ttf|j	| | t|j	| qW dS )z3Test for fancy-selections (too many indexes, read).zSelection to test:N)
r]   ry  r  r	   r   r   rZ   r   r  r  )r:   r]   ry  r}  rC   rC   rD   r  	  s    
z#FancySelectionTestCase.test01d_readc             C   s~   | j }| j}xl| jD ]b}tjr(td| || }|d ||< |d ||< |dd }|dd }| t||kd qW dS )z6Test for fancy-selections (working selections, write).zSelection to test:r_   Nz6NumPy array and PyTables modifications does not match.)	r]   ry  r  r	   r   r   r7   r   rz  )r:   r]   ry  r}  rX  r<   r?   rC   rC   rD   r  $	  s    
z$FancySelectionTestCase.test02a_writec             C   sn   | j }| j}x\| jD ]R}tjr(td| d||< d||< |dd }|dd }| t||kd qW dS )zATest for fancy-selections (working selections, write, broadcast).zSelection to test:r_   Nz6NumPy array and PyTables modifications does not match.)	r]   ry  r  r	   r   r   r7   r   rz  )r:   r]   ry  r}  r<   r?   rC   rC   rD   r  5	  s    
z$FancySelectionTestCase.test02b_write)r   r   r   r   r~  r  r  r  r  r  r   rC   rC   )r   rD   r    s   =r  c               @   s   e Zd ZdZdS )FancySelection1)r   r   r   N)r   r   r   r,   rC   rC   rC   rD   r  J	  s   r  c               @   s   e Zd ZdZdS )FancySelection2)r  r   r   N)r   r   r   r,   rC   rC   rC   rD   r  N	  s   r  c               @   s   e Zd ZdZdS )FancySelection3)r  r   r   N)r   r   r   r,   rC   rC   rC   rD   r  S	  s   r  c               @   s   e Zd ZdZdS )FancySelection4)r   r   r   N)r   r   r   r,   rC   rC   rC   rD   r  X	  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   z.h5r   )r   arr2)Znewname)r   r  r   r   r#   r$   r   r%   r   r!   r"   r`   copyhr  )r:   r=   )r   rC   rD   r   _	  s    zCopyNativeHDF5MDAtom.setUpc                s2   | j   | j  t| j tt|   d S )N)	r   r   r  r8   r9   r`   r   r  tearDown)r:   )r   rC   rD   r  h	  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/   r   r0   r  r,   )r:   rC   rC   rD   r   n	  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  r   r#   r$   r`   r%   r  r/   r   r0   r,   )r:   rC   rC   rD   test02_reopent	  s
    
z"CopyNativeHDF5MDAtom.test02_reopen)r   r   r   r   r  r   r  r   rC   rC   )r   rD   r  ]	  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 )N)r   r   rQ   )	r   r  r   r   r   r   r*   r%   rQ   )r:   r<   )r   rC   rD   r   	  s    
zAccessClosedTestCase.setUpc             C   s   | j   | t| jj d S )N)r   r   rZ   r   rQ   r+   )r:   rC   rC   rD   	test_read	  s    
zAccessClosedTestCase.test_readc             C   s    | j   | t| jjd d S )Nr   )r   r   rZ   r   rQ   r  )r:   rC   rC   rD   test_getitem	  s    
z!AccessClosedTestCase.test_getitemc             C   s"   | j   | t| jjdd d S )Nr   )r   r   rZ   r   rQ   __setitem__)r:   rC   rC   rD   test_setitem	  s    
z!AccessClosedTestCase.test_setitem)r   r   r   r   r  r  r  r   rC   rC   )r   rD   r  ~	  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.)r_   r   )r   rQ   )r0   r,   r   N)r   r   intr   rK   r   r*   r%   rx  r   r   r7   all)r:   Zarray_shapeZelement_shaper   r0   Zh5arrr   r]   rC   rC   rD   rr  	  s    


zBroadcastTest.testN)r   r   r   rr  rC   rC   rC   rD   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   rQ   r   r_   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 )N)r   r*   r  r~   rB   r    r   r#   r$   h5fnamer   r+   r/   r,   r0   r   r7   r
   )r:   rL   r]   rC   rC   rD   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 )N)r   r*   r  r~   r    r.   createparentsr0   r,   r   r#   r$   r  r   r+   r/   r   r7   r
   r   
zeros_likerB   )r:   rL   r]   rC   rC   rD   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    rB   )r   r*   r  r~   r    rB   r   r#   r$   r  r   r+   r/   r,   r0   r   r7   r
   )r:   rL   r]   rC   rC   rD   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    r0   r,   .)r   r*   r  r~   r    r0   r,   rB   r   r#   r$   r  r   r+   r/   r   r7   r
   )r:   rL   r]   rC   rC   rD   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 )N)r    r0   r,   )r   r*   r  r~   r    r0   r,   r   r#   r$   r  r   r+   r/   r   r7   r
   r   r  rB   )r:   rL   r]   rC   rC   rD   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    rB   r0   )r   r*   r  r~   r    rB   r0   r   r#   r$   r  r   r+   r/   r,   r   r7   r
   )r:   rL   r]   rC   rC   rD   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    rB   r,   )r   r*   r  r~   r    rB   r,   r   r#   r$   r  r   r+   r/   r0   r   r7   r
   )r:   rL   r]   rC   rC   rD   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    rB   r0   r,   )r   r*   r  r~   r    rB   r0   r,   r   r#   r$   r  r   r+   r/   r   r7   r
   )r:   rL   r]   rC   rC   rD   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complex)r    rB   r0   )r   rK   r   r   rZ   r[   r   r*   r  r~   r    rB   )r:   r0   rC   rC   rD   test_kwargs_obj_atom_error4
  s    z.TestCreateArrayArgs.test_kwargs_obj_atom_errorc          	   C   s4   | j | j  }| jt| jj| j| j| j| j|d d S )N)r    rB   r,   )	r,   rZ   r[   r   r*   r  r~   r    rB   )r:   r,   rC   rC   rD   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    rB   r0   r,   )r   rK   r   r   rZ   r[   r   r*   r  r~   r    rB   r,   )r:   r0   rC   rC   rD   #test_kwargs_obj_atom_shape_error_01J
  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 )N)r    rB   r0   r,   )
r,   rZ   r[   r   r*   r  r~   r    rB   r0   )r:   r,   rC   rC   rD   #test_kwargs_obj_atom_shape_error_02V
  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 )Nr  )r    rB   r0   r,   )r   rK   r   r   r,   rZ   r[   r   r*   r  r~   r    rB   )r:   r0   r,   rC   rC   rD   #test_kwargs_obj_atom_shape_error_03b
  s    z7TestCreateArrayArgs.test_kwargs_obj_atom_shape_error_03)r   r   r   r  r~   r   rQ   rB   r    r.   r  r   rK   r   r0   r,   r  r  r  r  r  r  r  r  r  r  r  r  r  rC   rC   rC   rD   r  	  s*   r  c              C   s  t  } d}xt|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W | S )Nr   )=r   Z	TestSuiter   ZaddTestZ	makeSuiter   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  r9  r:  rS  rT  r]  r^  r`  ra  rl  rm  ro  rp  rq  rs  r  r  r  r  r  r  r  r  r  r  r  r  r  )ZtheSuiteZniterr   rC   rC   rD   suiteo
  sz    r  __main__)ZdefaultTest)jZ
__future__r   r   r8   r1   r!   warningsr   r   r  r#   r   r   r   Ztables.utilsr   Ztables.testsr	   Ztables.tests.commonr
   r   r   r   ZTestCaseZ	six.movesr   r   r   r   r   r   r   r   r   r   r   r   ZTempFileMixinr   r   r   r   r   r   r   r   r   r	  r
  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r1  r9  r:  r;  rS  rT  rU  r\  r]  r^  r_  r`  ra  rb  rk  rl  rm  rn  ro  rp  rq  rs  ru  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   Z
parse_argvargvZprint_versionsmainrC   rC   rC   rD   <module>   s      3	
	O O} .N =	  	V	
  ! IF
