o
    i                     @   sx   d Z ddlZddlZddlmZ ddlmZm	Z	 ddlm
Z ddlZddlmZ dd ZG dd	 d	ZG d
d dZdS )z1Test functions for the sparse.linalg.norm module
    N)norm)assert_allcloseassert_equal)raisesc                  C   s   t g d} t g d}t g d}tjj|| |ffdd}tjj|| |ffdd}tt|dddt g d tt|dddt g d tt|dddt d	d
g tt|dddt d	d
g d S )N)r   r      r   )r   r         )         	   )r   r	   )shaper   r   ordaxisr      )nparrayscipysparse	coo_array
coo_matrixr   spnorm)rowcoldatatest_arrtest_mat r   ^/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/scipy/sparse/linalg/tests/test_norm.pytest_sparray_norm   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 )TestNormc                 C   s*   t dd }|d}tj|| _d S )Nr   r	   r   r   )r   arangereshaper   r   
csr_matrixb)selfar&   r   r   r   setup_method   s   
zTestNorm.setup_methodc                 C   s   t t| jd t t| jdd t t| jtjd t t| jtj d t t| jdd t t| jdd tjtd	d
 t t| jtj	dd W d    n1 sWw   Y  t
tt| jd d S )NNO@fror   r   r   r      zThe problem size)matchgűd@)r   r   r&   r   infpytestwarnsUserWarningastypefloat64assert_raisesNotImplementedError)r'   r   r   r   test_matrix_norm!   s   zTestNorm.test_matrix_normc                 C   s   | j d f| j df| j jdffD ]B\}}tt||dd tt|d|dd tt|tj|dd tt|tj |dd tt|d|dd	 tt|d
|dd qd S )Nr   r   r   r   r   r*   r+   r   r   r   r   r,   r-   r&   Tr   r   r   r0   )r'   mr   r   r   r   test_matrix_norm_axis3   s   &zTestNorm.test_matrix_norm_axisc                 C   s   g d}| j df| j jdffD ]I\}}||f|d |d ffD ]8}tt|d|dg d tt|tj|dg d tt||d| tt|d|d| tt|d |d| qqd S )	N)T@glv@r@   r   r   r   r;   )r   r-   r   )r	   r   r	   r   r<   )r'   vr>   r(   r   r   r   r   test_vector_norm<   s   zTestNorm.test_vector_normc                 C   s   | j }ttt|d d ttt|d dg ttt|d d ttt|d d ttt|d d ttt|d d ttt|d d ttt|d d ttt|d d ttt|d	d
 ttt|d	d d S )Ng      ?r   r   )r   r   r   )r   r   )r   r   )r   rC   plate_of_shrimpr   r9   )r&   r6   	TypeErrorr   
ValueError)r'   r>   r   r   r   test_norm_exceptionsF   s   zTestNorm.test_norm_exceptionsN)__name__
__module____qualname__r)   r8   r?   rB   rG   r   r   r   r   r!      s    	
r!   c                   @   s   e Zd Zejjejjejjejjejj	ejj
ejjfZedd dg dg dgg dg dgfZdd	 Zd
d Zdd ZdS )TestVsNumpyNormr   r	   r"   )r   r   r   )r,   r   r	   )r   r   r   )r,   r   y              @c                 C   s   | j D ]R}| jD ]L}||}tt|t| tt|dt|d tt|tjt|tj tt|tj t|tj  tt|dt|d tt|dt|d qqd S )Nr+   r   r,   _sparse_types_test_matricesr   r   npnormr   r0   )r'   sparse_typeMSr   r   r   test_sparse_matrix_normsi   s   

z(TestVsNumpyNorm.test_sparse_matrix_normsc                 C   s   | j D ]j}| jD ]d}||}dD ]+}tt||dt||d dtjtj ddfD ]}tt|||dt|||d q)qdD ]-}tt||dt||d tt|d|dt|d|d tt|d|dt|d|d q>qqd S )N)Nr9   r:   r;   r+   r   r,   ))r/   r,   )r,   r/   )r   r/   frL   r'   rP   rQ   rR   r   r   r   r   r   "test_sparse_matrix_norms_with_axist   s*   

z2TestVsNumpyNorm.test_sparse_matrix_norms_with_axisc                 C   s   | j D ]<}| jD ]6}||}dD ]-}tt||dt||d d dtjtj dddfD ]}tt|||dt|||d q+qqqd S )N)r   r   r,   r/   )r   )r   )r,   )r/   r;   r   r   g      ?gzG?rL   rU   r   r   r   test_sparse_vector_norms   s   

z(TestVsNumpyNorm.test_sparse_vector_normsN)rH   rI   rJ   r   r   
bsr_matrixr   
csc_matrixr%   
dia_matrix
dok_matrix
lil_matrixrM   r   r#   r$   rN   rS   rV   rW   r   r   r   r   rK   U   s(    

rK   )__doc__r1   numpyr   numpy.linalgr   rO   numpy.testingr   r   r   r6   scipy.sparser   scipy.sparse.linalgr   r    r!   rK   r   r   r   r   <module>   s    :