U
    /ev                     @   s   d dl Z e jjZd dlmZ d dlmZ e 	dZ
e 	dZdd Ze jdd dgd	d
 Ze jdddge jddddddddddddddddgdd ZdS )    N)	assert_eqcupycupyxc                  C   sv   t d tjdtjddd} tj| dddd}|jt	j
jjtjd}| }t	j
j|sdtt| |  d S )	Nr      dtype      )      FchunksZasarrayZfancy)pytestimportorskipr   ZarangeZfloat32Zreshapeda
from_array
map_blocksr   scipysparse
csr_matrixcompute
isspmatrixAssertionErrorr   todense)xspy r   E/tmp/pip-unpacked-wheel-dbjnr7gq/dask/array/tests/test_cupy_sparse.pytest_sparse_hstack_vstack_csr   s    
r   axis   c           
      C   s   t d tjjtjjd}tjj	d}g }g }t
dD ]B}|jddd}d||d	k < || ||jtjjj	|d
 q:tj|| d}| }| dkrtjjj}n| dkrtjjj}|dd |D }	| |	 k std S )Nr   )RandomState)r   r   r
   )i  
   )d   r#   )r   r   g?meta)r    r!   c                 S   s   g | ]}t jj| qS r   )r   r   r   r   r   ).0er   r   r   
<listcomp>0   s     z+test_sparse_concatenate.<locals>.<listcomp>)r   r   r   randomr"   r   r   r   r   r   rangeappendr   Zconcatenater   ZvstackZhstackZtoarrayallr   )
r    rsr&   xsZys_r   zZsp_concatenateZ
z_expectedr   r   r   test_sparse_concatenate   s(    


r2   	sp_formatcsrcscinput_sizes)r      )r7   r	   )r
   r   )r   r   )x_shapey_shapex_chunksy_chunks)r   r   )r
   r
   )r   r
   c                 C   s<  t d | dkrtjjj}n| dkr0tjjj}d}d}|d |d  }}|d |d	  }}tjj||d
}	tjj||d
}
d|	|	d| k < d|
|
d| k < |		|
}t
j|	|ddd}t
j|
|ddd}|j||tjdg|d
d}|j||tjdg|d
d}t
	|| }tjj|s*tt||  d S )Nr   r4   r5   fg333333?r8   r:   r9   r;   r   r   r!   Fr   r%   )r   r   r   r   r   r   Z
csc_matrixr   r*   dotr   r   r   arrayr   r   r   r   r   )r3   r6   Z	sp_matrixr   Zdensityr8   r:   r9   r;   r   r   r1   Zda_xZda_yZda_zr   r   r   test_sparse_dot6   s*    


r?   )r   markZgpuZ
pytestmarkZ
dask.arrayr>   r   Zdask.array.utilsr   r   r   r   r   Zparametrizer2   r?   r   r   r   r   <module>   s:   


