o
    :ήc+                     @   s  d dl Z d dl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 e	 Zed Zdd	 Zejd
g ddd Zdd Zdd Zdd Zejd
g ddd Zdd Zdd Zdd Zejd
g ddd Zdd  Zd!d" Z d#d$ Z!d%d& Z"ejd
g dd'd( Z#d)d* Z$d+d, Z%d-d. Z&ejd
g dd/d0 Z'd1d2 Z(ejd3g d4ejd5ej)ej*gd6d7 Z+dS )8    N)assert_almost_equalassert_array_equalassert_equal)data)expected_warnings)_supported_float_type)pyramids).r   c               
   C   s   t j\} }}tdg tjt ddd}W d    n1 sw   Y  t|j| d |d |f tdg tt dd dddd}W d    n1 sKw   Y  t|j| d |d |f d S )	N'`multichannel` is a deprecated argument   T	downscalemultichannel%Providing the `multichannel` argument   reflectr   )imageshaper   r   pyramid_reducer   rowscolsdimout r   L/tmp/pip-target-vg8gfxp4/lib/python/skimage/transform/tests/test_pyramids.py/test_pyramid_reduce_rgb_deprecated_multichannel      r   channel_axis)r   r   c                 C   s`   t  }|j\}}}tj|d| d}tj|d| d}t|| d}t|j|d |d |f d S Nr   sourcedestinationr
   r   r   )r   	astronautr   npmoveaxisr   r   r   )r   r   r   r   r   out_r   r   r   r   test_pyramid_reduce_rgb   s   r(   c                  C   st   t j\} }tjt dd d}t|j| d |d f t| ddd tjt dd dd}t| t   ddd d S )Nr
   r#         ?decimalT)r   r   preserve_range
image_grayr   r   r   r   r   ptpr   r   out1out2r   r   r   test_pyramid_reduce_gray(   s   
r3   c                  C   sj   t j\} }tt }t|j| d |d f t| ddd tjt dd}t| t   ddd d S )Nr
   r)   r*   T)r,   r-   r0   r   r   r   !test_pyramid_reduce_gray_defaults3   s   

r4   c                  C   sJ   dD ] } t jjd|   }tj|dd d}t |jd }t|j| qd S Nr   r
         )   r
   r#   )r%   randomrandnr   r   asarrayr   r   ndimimgr   expected_shaper   r   r   test_pyramid_reduce_nd<      rA   )r   r   r
   r   c                 C   sf   t  }|j\}}}tj|d| d}tj|d| d}|d |d g}|| |j | t	|j| d S )Nr   r    r
   upscaler   )
r   r$   r   r%   r&   r   pyramid_expandinsertr>   r   )r   r   r   r   r   r   r@   r   r   r   test_pyramid_expand_rgbE   s   rI   c               
   C   s   t j\} }}tdg tjt ddd}W d    n1 sw   Y  t|j| d |d |f tdg tt dd dddd}W d    n1 sKw   Y  t|j| d |d |f d S )	Nr	   r
   T)rF   r   r   r   r   r   )r   r   r   r   rG   r   r   r   r   r   /test_pyramid_expand_rgb_deprecated_multichannelQ   r   rJ   c                  C   s4   t j\} }tjt dd}t|j| d |d f d S )Nr
   )rF   )r.   r   r   rG   r   )r   r   r   r   r   r   test_pyramid_expand_gray]   s   
rK   c                  C   sJ   dD ] } t jjd|   }tj|dd d}t |jd }t|j| qd S )Nr6   )r8   r
   rE   )r%   r:   r;   r   rG   r<   r   r   r=   r   r   r   test_pyramid_expand_ndc   rB   rL   c           	      C      t  }|j\}}}tj|d| d}tj|d| d}t|D ]"\}}|d|  |d|  g}|| |j	 | |jt
|ks@J qd S r   )r   r$   r   r%   r&   r   pyramid_gaussian	enumeraterH   r>   tuple	r   r   r   r   r   pyramidlayerr   layer_shaper   r   r   test_build_gaussian_pyramid_rgbl      rU   c                  C      t j\} }}tdg tjt ddd}W d    n1 sw   Y  t|D ]\}}| d|  |d|  |f}t|j| q'tdg tt ddd ddd	d}W d    n1 s[w   Y  t|D ]\}}| d|  |d|  |f}t|j| qdd S 
Nr	   r
   Tr   r   r   r   r   r   )r   r   r   r   rN   rO   r   r   r   r   rR   rS   r   rT   r   r   r   7test_build_gaussian_pyramid_rgb_deprecated_multichannely   $   rZ   c                  C   sT   t j\} }tjt dd d}t|D ]\}}| d|  |d|  f}t|j| qd S )Nr
   r#   r.   r   r   rN   rO   r   r   r   rR   rS   r   rT   r   r   r    test_build_gaussian_pyramid_gray   s   
r^   c                  C   N   t j\} }tt }t|D ]\}}| d|  |d|  f}t|j| qd S Nr
   r\   r]   r   r   r   )test_build_gaussian_pyramid_gray_defaults      

ra   c                  C   d   dD ]-} t jjd|   }t |j}tj|dd d}t|D ]\}}|d|  }t|j| qqd S r5   )	r%   r:   r;   r<   r   r   rN   rO   r   r>   r?   original_shaperR   rS   r   rT   r   r   r   test_build_gaussian_pyramid_nd      rf   c           	      C   rM   r   )r   r$   r   r%   r&   r   pyramid_laplacianrO   rH   r>   rP   rQ   r   r   r    test_build_laplacian_pyramid_rgb   rV   ri   c                  C   rW   rX   )r   r   r   r   rh   rO   r   rY   r   r   r   8test_build_laplacian_pyramid_rgb_deprecated_multichannel   r[   rj   c                  C   r_   r`   )r.   r   r   rh   rO   r   r]   r   r   r   %test_build_laplacian_pyramid_defaults   rb   rk   c                  C   rc   )Nr6   )   r
   r#   )	r%   r:   r;   r<   r   r   rh   rO   r   rd   r   r   r   test_build_laplacian_pyramid_nd   rg   rm   c                 C   s  dD ]|}| d u rd}|}nd}t |d }d}t|}|| | | t|}t|}tj||| d}t	t
t||}t|D ]/\}	}
| d u rO|
j}n|
j|  |ksXJ t|
j}||  t|}|	|k rrt|dksrJ qCt||	 |dks~J qd S )N)r
   r7         )    r9   r   rn   r#   )r   r   )lenlistrH   rP   r%   onesr   rh   mathceillogmaxrO   r   popr   )r   r   r   shape_without_channelsr>   
n_channelsr?   rR   	max_layerrS   r   out_shape_without_channelsr   r   r   !test_laplacian_pyramid_max_layers   s8   



r}   c                   C   sn   t t td W d    n1 sw   Y  t t td W d    d S 1 s0w   Y  d S )NgGz?rC   )pytestraises
ValueErrorr   _check_factorr   r   r   r   test_check_factor   s   "r   dtype)float16float32float64uint8int64pyramid_funcc                    sD   t jdd|}| |}t| t  fdd|D s J d S )Nrp   r9   c                    s   g | ]}|j  kqS r   )r   ).0imfloat_dtyper   r   
<listcomp>  s    z.test_pyramid_dtype_support.<locals>.<listcomp>)r%   r:   r;   astyper   all)r   r   r?   rR   r   r   r   test_pyramid_dtype_support  s    r   ),rt   r~   numpyr%   numpy.testingr   r   r   skimager   skimage._shared._warningsr   skimage._shared.utilsr   skimage.transformr   r$   r   r.   r   markparametrizer(   r3   r4   rA   rI   rJ   rK   rL   rU   rZ   r^   ra   rf   ri   rj   rk   rm   r}   r   rN   rh   r   r   r   r   r   <module>   sT    

		
	
	

%