U
    ?hP	                     @   s   d dl Zd dlZd dlmZmZmZmZmZ d dl	m
Z
 ed ejdddd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zejddddgejdejejejejgdd ZdS )    N)imreadimsave
use_pluginreset_pluginsplugin_order)testingZ	SimpleITKT)Zautousec                   c   s   t d dV  t  dS )z%Ensure that SimpleITK plugin is used.	simpleitkN)r   r    r	   r	   Q/var/www/html/venv/lib/python3.8/site-packages/skimage/io/tests/test_simpleitk.pyuse_simpleitk_plugin   s    r   c                  C   sF   t  } | d d dkst| d d dks.t| d d dksBtd S )Nr   r   r   r   Zimread_collection)r   AssertionError)orderr	   r	   r
   test_prefered_plugin   s    r   c                  C   s`   t tddd} | jdks t| jtjks0tt tddd} t| jtj	d ks\td S )Nzdata/color.pngT)Zas_gray   zdata/camera.pngZ
AllInteger)
r   r   fetchndimr   dtypenpfloat64Zsctype2char	typecodes)imgr	   r	   r
   test_imread_as_gray   s
    r   c                  C   s8   t d} d| d d d< ttd}t j||  d S )N
   r      r   zdata/checker_bilevel.png)r   Zzerosr   r   r   Zassert_array_equalexpectedr   r	   r	   r
   test_bilevel#   s    
r   c                	   C   s(   t t ttd W 5 Q R X d S )Nzdata/truncated.jpg)pytestZraisesRuntimeErrorr   r   r   r	   r	   r	   r
   test_imread_truncated_jpg+   s    r    c                  C   sD   t td} ttd}t |jt js2tt j	||  d S )Ndata/chessboard_GRAY_U8.npyzdata/chessboard_GRAY_U16.tif)
r   loadr   r   r   
issubdtyper   uint16r   assert_array_almost_equalr   r	   r	   r
   test_imread_uint160   s    r&   c                  C   s0   t td} ttd}t j||  d S )Nr!   zdata/chessboard_GRAY_U16B.tif)r   r"   r   r   r   r%   r   r	   r	   r
   test_imread_uint16_big_endian7   s    r'   shaper   )r   r      )r   r      r   c                 C   sx   t |t jrt j}nt j}t j||j||jdt | |d}|	| }|d }t
|| t|}t j|| d S )NT)Zendpointnumr   zroundtrip.mha)r   r#   ZfloatingZfinfoZiinfoZlinspaceminmaxprodZreshaper   r   r   r%   )r(   r   Ztmp_pathZ	info_funcr   	file_pathactualr	   r	   r
   test_imsave_roundtrip=   s     

r1   )numpyr   r   Z
skimage.ior   r   r   r   r   Zskimage._sharedr   ZimportorskipZfixturer   r   r   r   r    r&   r'   markZparametrizeZuint8r$   Zfloat32r   r1   r	   r	   r	   r
   <module>   s   


	