%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python3.9/site-packages/numpy/linalg/tests/__pycache__/
Upload File :
Create Path :
Current File : //lib64/python3.9/site-packages/numpy/linalg/tests/__pycache__/test_linalg.cpython-39.opt-1.pyc

a

z[yc(.�@sN
dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddlm
Z
mZmZm
Z
mZmZmZmZddlmZddlmZmZmZmZddlmZddlmZmZmZmZmZddlm Z dd	l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*d
d�Z+e&Z,d�dd�Z&dd�Z-dd�Z.dd�Z/hd�Z0Gdd�d�Z1dd�Z2e	j3�4d�gZ5e5e2de1de
ddgd d!gged"�e
ddged"��e1d#e
ddgd d!gged"�e
ddged"��e1d$e
ddgd d!gged"�e
gd%�gd&�ged"��e1d'e
d(d)gd*d+gge
d"�e
d,d(ge
d"��e1d-e
d(d)gd*d+gged"�e
d,d(ged"��e1d.e
d(d)gd*d+gged"�e
gd/�gd0�ged"��e1d1e	j6d2ed"�e	j6d3ed"�d4hd5�e1d6e	j3�7d7d7�e	j3�7d7��e1d8e	j3�7d9d9�e	j3�7d9��e1d:d9d;gd<d=ggd;d9g�g
�7Z5e5e2d>e1d?e
gd@�gd&�ged"�e
ddged"��e1dAe
ddgd d!gdBdCgged"�e
gdD�ed"��e1dEe
gd@�gd&�ged"�e
ddged"��e1dFe
ddgd d!gdBdCgged"�e
gdD�ed"��e1dGe
gdH�gdI�ge
d"�e
d,d(ge
d"��e1dJe
dKdLgdMdNgdOdPgge
d"�e
gdQ�e
d"��e1dRe
gdH�gdI�ged"�e
d,d(ged"��e1dSe
dKdLgdMdNgdOdPgged"�e
gdQ�ed"��e1dTe
gdH�gdI�ged"�e
d,d(gdUdVgged"��e1dWe
dKdLgdMdNgdOdPgged"�e
d,d(gdUdVgdUdVgged"��e1dXe	j3�7d7dY�e	j3�7d7��e1dZe	j3�7d9d[�e	j3�7d9��e1d\e	j3�7d[d9�e	j3�7d[��e1d]e	j3�7dd=�e	j3�7d�d4hd5�e1d^e	j3�7d=d�e	j3�7d=�d4hd5�g�7Z5e5e2d_e1d`e
ddgddgged"�d�e1dae
ddgddgged"�d�e1dbe
dd)gdcd9gge
d"�d�e1dde
dd)gdcd9gged"�d�e1dee	j6d2ed"�dd4hd5�e1dfd9d;gd;d9ggd�e1dge
ddgddgg�d�e1dhe	j3�7d9d9�d�g�7Z5didj�Z8e5e8�7Z5dkdl�Z9dmdn�Z:e5e:�7Z5Gdodp�dp�Z;Gdqdr�dre;�Z<Gdsdt�dte;�Z=Gdudv�dve;�Z>Gdwdx�dxe;�Z?Gdydz�dze;�Z@Gd{d|�d|e;�ZAd}d~�ZBdd��ZCGd�d��d�e<e?�ZDGd�d��d�eD�ZEGd�d��d�e<e?�ZFGd�d��d�eF�ZGGd�d��d�e<e?�ZHGd�d��d�eH�ZIGd�d��d�e<e?�ZJGd�d��d�eJ�ZKGd�d��d��ZLGd�d��d�e<e?�ZMGd�d��d�eMeL�ZNGd�d��d�e>eA�ZOGd�d��d�eOeL�ZPGd�d��d�e<e?�ZQGd�d��d�eQ�ZRGd�d��d�e<e=e?e@�ZSGd�d��d�eS�ZTGd�d��d�e>eA�ZUGd�d��d�eU�ZVGd�d��d�e<e?�ZWGd�d��d�eW�ZXGd�d��d�e<e=�ZYGd�d��d�eY�ZZej[�\d�d�d��d�D��Gd�d��d���Z]Gd�d��d�e>eA�Z^Gd�d��d��Z_Gd�d��d�e>eA�Z`Gd�d��d��ZaGd�d��d��ZbGd�d��d�eb�ZcGd�d„d�eb�ZdGd�dĄd�edec�ZeGd�dƄdƃZfGd�dȄd�eb�ZgGd�dʄd�eb�ZhGd�d̄d�eb�ZiGd�d΄d�eeeg�ZjGd�dЄd�eeeh�ZkGd�d҄d�eeei�ZlGd�dԄdԃZmd�dքZnGd�d؄d؃ZoGd�dڄdڃZpd�d܄Zqd�dބZrd�d�Zsej[jtd�d��ZuGd�d�d�ZvGd�d�d�ZwGd�d�d�Zxd�d�Zyej[jzd�d�d�d��Z{ej[j|e*d�d�d�d��Z}dS)�z# Test functions for linalg module

�N)�array�single�double�csingle�cdouble�dot�identity�matmul)�swapaxes)�multiply�
atleast_2d�inf�asarray)�linalg)�matrix_power�norm�matrix_rank�	multi_dot�LinAlgError)�_multi_dot_matrix_chain_order)	�assert_�assert_equal�
assert_raises�assert_array_equal�assert_almost_equal�assert_allclose�suppress_warnings�assert_raises_regex�HAS_LAPACK64cCs"t|�t|tj�rt|�ntjuS�N)�type�
isinstance�np�ndarray)�outZin_�r%�D/usr/lib64/python3.9/site-packages/numpy/linalg/tests/test_linalg.py�consistent_subclasss�r'��cKs8t|�jjttfvr|}n|}t||fd|i|��dS)N�decimal)r�dtyper rr�old_assert_almost_equal)�a�b�single_decimal�double_decimal�kwr*r%r%r&r$srcCstttttttti|Sr)rrrr�r+r%r%r&�get_real_dtype,s
��r3cCstttttttti|Sr)rrrrr2r%r%r&�get_complex_dtype1s
��r4cCs|ttfvrdSdSdS)Ng�h㈵��>g�dy���=)rrr2r%r%r&�get_rtol6sr5>�square�strided�	nonsquare�	hermitian�generalized�size-0c@s*eZdZe�fdd�Zdd�Zdd�ZdS)�
LinalgCasecCs.tt|t��||_||_||_t|�|_dS)z�
        A bundle of arguments to be passed to a test case, with an identifying
        name, the operands a and b, and a set of tags to filter the tests
        N)rr!�str�namer-r.�	frozenset�tags)�selfr>r-r.r@r%r%r&�__init__Fs
zLinalgCase.__init__cCs||j|j|jd�dS)zN
        Run the function `do` on this test case, expanding arguments
        �r@N)r-r.r@)rA�dor%r%r&�checkQszLinalgCase.checkcCsd|j�d�S)Nz
<LinalgCase: �>)r>�rAr%r%r&�__repr__WszLinalgCase.__repr__N)�__name__�
__module__�__qualname__�setrBrErHr%r%r%r&r<Esr<cCs|D]}|j|hB|_q|S)z^
    Add the given tag (a string) to each of the cases (a list of LinalgCase
    objects)
    rC)�tagZcases�caser%r%r&�	apply_tag[srO��r6r��?�@�@�@r2rZdouble_2)rRrQrT)rSrT�@r��?@y@@y@@y@@�@�?rZ	cdouble_2)rWrVy�?@)y�?�y�?�y�?�Z0x0�rr�rr;rCZ8x8�Z1x1�Znonarray���r8Zsingle_nsq_1)rQrRrSZsingle_nsq_2g@rU)rRrQrSZdouble_nsq_1Zdouble_nsq_2Z
csingle_nsq_1)��?�?�@@�@�)y@�y@"@y@@Z
csingle_nsq_2r_r`ray@"�y@�y@ @)rWrVraZ
cdouble_nsq_1Z
cdouble_nsq_2Zcdouble_nsq_1_2y�?�y@�Zcdouble_nsq_2_2Z8x11�Z1x5�Z5x1Z0x4Z4x0r9ZhsingleZhdoubleZhcsingley@�ZhcdoubleZhemptyZ	hnonarrayZ
matrix_b_onlyZhmatrix_1x1cCsg}tD�]}t|jtj�sqt�|jd|jd|jg�}|jdurLd}nt�|jd|jd|jg�}t|jd|||j	dhBd�}|�
|�t�|jgdd��d|jj�}|jdur�d}n$t�|jgdd��d|jj�}t|jd	|||j	dhBd�}|�
|�q|S)
Nr\r]�r(Z_tile3r:rC�r]r\Z_tile213)
�CASESr!r-r"r#rr.r<r>r@�append�reshape�shape)�	new_casesrNr-r.�new_caser%r%r&�_make_generalized_cases�s*


�
$
$
�rlccs�t|tj�s|dfVdSdg|j}d|d<|jdkr@d|d<|jdkrRd	|d
<tjt|��D�]�}dd�t|j|�D�}td
d�|D��}tj	||j
d�}|�tj��
d�||}||d<|�|j�}tt�||k��|dd�dd�|D��fV|jdk�rF|jddk�rFt|j�}d|d<tjjj||d�}|dfV|jdk�r�|jddk�r�t|j�}d|d<tjjj||d�}|dfV|jdkr`|jdd�dkr`t|j�}d|d<d|d<tjjj||d�}|dfVq`dS)z<
    Generate cartesian product of strides for all axes
    ZnopN�r[)r[r]������r[���r\)r[rn���cSsg|]\}}t||��qSr%)�abs)�.0r-r.r%r%r&�
<listcomp>�z%_stride_comb_iter.<locals>.<listcomp>cSsg|]}tdd|��qSr)�slice)rs�repeatr%r%r&rtrur2l�>[=.Zstride_�_cSsg|]}d|�qS)z%+dr%)rs�jr%r%r&rt(rur)�stridesZstride_xxx_0Zstride_xxx_0_x�r[r[Zstride_xxx_0_0)r!r"r#�ndim�	itertools�product�tuple�zipri�emptyr+�viewZuint32�fill�	__class__r�all�join�listrz�libZ
stride_tricksZ
as_strided)�xZ
stride_setZrepeats�	new_shapeZslicesZxi�sr%r%r&�_stride_comb_iter
sF







r�c	Csng}tD]`}t|j�D]P\}}t|j�D]<\}}t|jd|d||||jdhBd�}|�|�q(qq|S)Nrxr7rC)rfr�r-r.r<r>r@rg)rjrNr-Za_labelr.Zb_labelrkr%r%r&�_make_strided_cases=s
�r�c@s"eZdZeZe�e�fdd�ZdS)�LinalgTestCasecCs�|jD]x}|j|@|krq|j|@r&qz|�|j�Wqty|}z.d|�d�}|t��7}t|�|�WYd}~qd}~00qdS)zx
        Run func on each of the cases with all of the tags in require, and none
        of the tags in exclude
        zIn test case: z

N)�
TEST_CASESr@rErD�	Exception�	traceback�
format_exc�AssertionError)rA�require�excluderN�e�msgr%r%r&�check_casesQs

zLinalgTestCase.check_casesN)rIrJrKrfr�rLr�r%r%r%r&r�Nsr�c@seZdZdd�Zdd�ZdS)�LinalgSquareTestCasecCs|jdhddhd�dS)Nr6r:r;�r�r��r�rGr%r%r&�
test_sq_casesgs�z"LinalgSquareTestCase.test_sq_casescCs|jddhdhd�dS)Nr6r;r:r�r�rGr%r%r&�test_empty_sq_casesks
�z(LinalgSquareTestCase.test_empty_sq_casesN)rIrJrKr�r�r%r%r%r&r�esr�c@seZdZdd�Zdd�ZdS)�LinalgNonsquareTestCasecCs|jdhddhd�dS)Nr8r:r;r�r�rGr%r%r&�test_nonsq_casesrs�z(LinalgNonsquareTestCase.test_nonsq_casescCs|jddhdhd�dS)Nr8r;r:r�r�rGr%r%r&�test_empty_nonsq_casesvs
�z.LinalgNonsquareTestCase.test_empty_nonsq_casesN)rIrJrKr�r�r%r%r%r&r�psr�c@seZdZdd�Zdd�ZdS)�HermitianTestCasecCs|jdhddhd�dS)Nr9r:r;r�r�rGr%r%r&�test_herm_cases}s�z!HermitianTestCase.test_herm_casescCs|jddhdhd�dS)Nr9r;r:r�r�rGr%r%r&�test_empty_herm_cases�s
�z'HermitianTestCase.test_empty_herm_casesN)rIrJrKr�r�r%r%r%r&r�{sr�c@s,eZdZejjdd��Zejjdd��ZdS)�LinalgGeneralizedSquareTestCasecCs|jddhdhd�dS)Nr:r6r;r�r�rGr%r%r&�test_generalized_sq_cases�s
�z9LinalgGeneralizedSquareTestCase.test_generalized_sq_casescCs|jhd�d�dS)N>r6r:r;�r�r�rGr%r%r&�test_generalized_empty_sq_cases�sz?LinalgGeneralizedSquareTestCase.test_generalized_empty_sq_casesN)rIrJrK�pytest�mark�slowr�r�r%r%r%r&r��s
r�c@s,eZdZejjdd��Zejjdd��ZdS)�"LinalgGeneralizedNonsquareTestCasecCs|jddhdhd�dS)Nr:r8r;r�r�rGr%r%r&�test_generalized_nonsq_cases�s
�z?LinalgGeneralizedNonsquareTestCase.test_generalized_nonsq_casescCs|jhd�d�dS)N>r:r8r;r�r�rGr%r%r&�"test_generalized_empty_nonsq_cases�szELinalgGeneralizedNonsquareTestCase.test_generalized_empty_nonsq_casesN)rIrJrKr�r�r�r�r�r%r%r%r&r��s
r�c@s,eZdZejjdd��Zejjdd��ZdS)�HermitianGeneralizedTestCasecCs|jddhdhd�dS)Nr:r9r;r�r�rGr%r%r&�test_generalized_herm_cases�s
�z8HermitianGeneralizedTestCase.test_generalized_herm_casescCs|jhd�dhd�dS)N>r:r;r9Znoner�r�rGr%r%r&�!test_generalized_empty_herm_cases�s
�z>HermitianGeneralizedTestCase.test_generalized_empty_herm_casesN)rIrJrKr�r�r�r�r�r%r%r%r&r��s
r�cCs�t|�}|jdkr�|j|jkr<|jdd�|jdd�}n(|j|jdkr\|jdd�}ntd��tj|t�||�d�}tjt	t
|jdd���D]}t||||�||<q�|St||�SdS)Nr]ror[zNot implemented...r2rp)rr|ri�
ValueErrorr"r�Zcommon_typer}r~�map�ranger)r-r.r��r�cr%r%r&�dot_generalized�s
r�cCsLt|�}|jdkr:tj|j|jd�}t|jd�|d<|St|jd�SdS)Nr]r2rp.r)rr|r"r�rir+r)r-r�r%r%r&�identity_like_generalized�s
r�c@seZdZdd�ZdS)�
SolveCasescCs.t�||�}t|t||��tt||��dSr)r�solverr�rr')rAr-r.r@r�r%r%r&rD�sz
SolveCases.doN�rIrJrKrDr%r%r%r&r��sr�c@s:eZdZej�deeee	g�dd��Z
dd�Zdd�ZdS)	�	TestSolver+cCs2tjddgddgg|d�}tt�||�j|�dS�Nr[��?r2)r"rrrr�r+�rAr+r�r%r%r&�
test_types�szTestSolve.test_typesc	Cs.Gdd�dtj�}t�d��ddd�}t�d��ddd��|�}t�||�dd�dd�dd�f}t�|dd�dd�dd�f|dd�dd�dd�f�}t||�tt	||��t
tjtj|dd�dd�dd�f|�t
ttj||dd�dd�dd�f�t�d��ddd�}t
ttj||�t
ttj|dd�|dd��t�d��dd��|�}t�||�dd�dd�f}t�|dd�dd�dd�f|dd�dd�f�}t||�tt	||��t�d��dd�}t
ttj||�t
ttj|dd�|dd��t
ttj|dd�dd�dd�f|�dS)	Nc@seZdZdS)z,TestSolve.test_0_size.<locals>.ArraySubclassN�rIrJrKr%r%r%r&�
ArraySubclass�sr�rZr\r(r[r]r)
r"r#�arangerhr�rr�rrr!rrr��rAr�r-r.�expected�resultr%r%r&�test_0_size�s*"8
(& 2
 zTestSolve.test_0_sizecCsGdd�dtj�}t�d��ddd�}t�d��ddd��|�}t�||�dd�dd�dd�f}t�||dd�dd�dd�f�}t||�tt	||��t�||�dd�dd�dd�f}t�|dd�dd�dd�f|dd�dd�dd�f�}t||�tt	||��dS)	Nc@seZdZdS)z.TestSolve.test_0_size_k.<locals>.ArraySubclassNr�r%r%r%r&r��sr�r^r[r\r(r]r)
r"r#r�rhr�rr�rrr!r�r%r%r&�
test_0_size_k�s""
"8
zTestSolve.test_0_size_kN)
rIrJrKr�r��parametrizerrrrr�r�r�r%r%r%r&r��s
!r�c@seZdZdd�ZdS)�InvCasescCs0t�|�}tt||�t|��tt||��dSr)r�invrr�r�rr')rAr-r.r@Za_invr%r%r&rDs


�zInvCases.doNr�r%r%r%r&r�
sr�c@s2eZdZej�deeee	g�dd��Z
dd�ZdS)�TestInvr+cCs0tjddgddgg|d�}tt�|�j|�dSr�)r"rrrr�r+r�r%r%r&r�szTestInv.test_typescCs�Gdd�dtj�}tjdtjd��|�}t�|�}t|jj	tj
u�t|j|j�tt
||��tjdtjd��|�}t�|�}t|jj	tju�t|j|j�tt
||��dS)Nc@seZdZdS)z*TestInv.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r�sr��rr[r[r2rX)r"r#�zeros�int_r�rr�rr+r �float64rrir!�	complex64�rAr�r-�resr%r%r&r�s

zTestInv.test_0_sizeN�rIrJrKr�r�r�rrrrr�r�r%r%r%r&r�s
r�c@seZdZdd�ZdS)�EigvalsCasescCs&t�|�}t�|�\}}t||�dSr)r�eigvals�eigr)rAr-r.r@�ev�evalues�evectorsr%r%r&rD,s
zEigvalsCases.doNr�r%r%r%r&r�*sr�c@s2eZdZej�deeee	g�dd��Z
dd�ZdS)�TestEigvalsr+cCs`tjddgddgg|d�}tt�|�j|�tjddgddgg|d�}tt�|�jt|��dS�Nr[r�r2ro)r"rrrr�r+r4r�r%r%r&r�3szTestEigvals.test_typescCs�Gdd�dtj�}tjdtjd��|�}t�|�}t|jj	tj
u�td|j�tt
|tj��tjdtjd��|�}t�|�}t|jj	tju�td|j�tt
|tj��dS)Nc@seZdZdS)z.TestEigvals.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r�<sr�r�r2�rr[rXrY)r"r#r�r�r�rr�rr+r r�rrir!r�r�r%r%r&r�:s

zTestEigvals.test_0_sizeNr�r%r%r%r&r�2s
r�c@seZdZdd�ZdS)�EigCasescCsXt�|�\}}tt||�t�|�t�|�dddd�ft|j�d�tt	||��dS)N.��rtol)
rr�rr�r"rr5r+rr')rAr-r.r@r�r�r%r%r&rDOs
 �zEigCases.doNr�r%r%r%r&r�Msr�c@s2eZdZej�deeee	g�dd��Z
dd�ZdS)�TestEigr+cCs�tjddgddgg|d�}tj�|�\}}t|j|�t|j|�tjddgddgg|d�}tj�|�\}}t|jt|��t|jt|��dSr�)r"rrr�rr+r4�rAr+r��w�vr%r%r&r�XszTestEig.test_typescCs�Gdd�dtj�}tjdtjd��|�}t�|�\}}t|jj	tj
u�t|jj	tj
u�t|j|j�td|j�tt
|tj��tjdtjd��|�}t�|�\}}t|jj	tju�t|jj	tju�t|j|j�td|j�tt
|tj��dS)Nc@seZdZdS)z*TestEig.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r�fsr�r�r2r�rXrY)r"r#r�r�r�rr�rr+r r�rrir!r��rAr�r-r�Zres_vr%r%r&r�dszTestEig.test_0_sizeNr�r%r%r%r&r�Ws
r�c@s.eZdZdZej�deee	e
g�dd��ZdS)�SVDBaseTestsFr+cCsxtjddgddgg|d�}t�|�\}}}t|j|�t|jt|��t|j|�tj|d|jd�}t|jt|��dS)Nr[r�r2F��
compute_uvr9)r"rr�svdrr+r3r9)rAr+r��ur��vhr%r%r&r�~szSVDBaseTests.test_typesN)rIrJrKr9r�r�r�rrrrr�r%r%r%r&r�{sr�c@seZdZdd�ZdS)�SVDCasesc	Cspt�|d�\}}}t|tt�|�t�|�dddd�ft�|��t|j�d�tt	||��tt	||��dS)NF.r�)
rr�rr�r"rr5r+rr')rAr-r.r@r�r��vtr%r%r&rD�s&��zSVDCases.doNr�r%r%r%r&r��sr�c@seZdZdd�ZdS)�TestSVDcCs�t�d�}tj|d|jd�\}}}t|jd�t|jd�t|t�d��t�d�}tj|d|jd�\}}}t|jd�t|jd�t|t�d��dS)	z6 Empty input should put an identity matrix in u or vh )r^rTr��r^r^rXr^)rr^N)r"r�rr�r9rri�eye)rAr�r�r�r�r%r%r&�test_empty_identity�s

zTestSVD.test_empty_identityN)rIrJrKr�r%r%r%r&r��sr�c@seZdZdd�ZdS)�SVDHermitianCasesc	Cs�tj|ddd�\}}}t|tt�|�t�|�dddd�ft�|��t|j�d�dd�}tt�	|||��t�
t�|jd�|j��tt�	|||��t�
t�|jd�|j��t
t�|�dddd�f|�tt||��tt||��dS)	NFT�r9.r�cSs<tt|j��}|d|d|d<|d<t�tj||d��S)Nrpro��axes)r�r�r|r"�conj�	transpose)�matr�r%r%r&r9�sz'SVDHermitianCases.do.<locals>.hermitianro)rr�rr�r"rr5r+rr	�broadcast_tor�rir�sortrr')rAr-r.r@r�r�r�r9r%r%r&rD�s&��,,zSVDHermitianCases.doNr�r%r%r%r&r��sr�c@seZdZdZdS)�TestSVDHermitianTN)rIrJrKr9r%r%r%r&r��sr�c@seZdZdd�ZdS)�	CondCasescCs�t|�}d|vr"tttj|�dStj|dd�}tt�|�|d|dddd�tt�|d	�|d|dddd�tt�|d
�|d|dddd�tj�|�}tt�|d�t	|��
d
��d�t	|��
d
��d�ddd�tt�|d�t	|��
d
��d�t	|��
d
��d�ddd�tt�|tj
�t	|��
d��d�t	|��
d��d�ddd�tt�|tj
�t	|��
d��d�t	|��
d��d�ddd�tt�|d
�t�t	|�d	�
d��
d�t	|�d	�
d��
d��ddd�dS)Nr;F)r�).r).rorcrb�r/r0r\rpr[ro�fro)rrrr�condr�rr"r�rr�sum�max�minr
�sqrt)rAr-r.r@r�r�Zcinvr%r%r&rD�sZ���
&�
&�&�&�
��zCondCases.doNr�r%r%r%r&r��sr�c@s>eZdZdd�Zdd�Zejjdddd�d	d
��Zdd�Z	d
S)�TestCondcCs�tgd�gd�gd�g�}tt�|t�d�tt�|t�d�tt�|d�d�tt�|d�d�tt�|d	�t�d
��dS)N)rQrr[)rg�r)rrrSr^gUUUUUU�?r[ror�r�gUUUUU6@)rrrr�r
r"r�rA�Ar%r%r&�test_basic_nonsvd�szTestCond.test_basic_nonsvdcCstt�d�t�d�g}gd�}ddg}t�||�D]\}}tt�||�dk�q0t�||�D]\}}t�||�qZdS)N�r\r\�Nr[r\r�rorp�4&�kC)r"r��onesr}r~rrr�)rAZAs�p_posZp_negr�pr%r%r&�
test_singular�szTestCond.test_singularTFz/Platform/LAPACK-dependent failure, see gh-18914)�run�reasoncCs�gd�}gd�}t�d�}tj|d<|D].}t�||�}tt|tj��tt�|��q(t�d�}tj|d<|D]t}t�||�}tt�|d��||vr�t|dd	k�t|d
d	k�qptt�|d��tt�|d
��qpdS)N)Nr[ror\rpr�rrr�)r]r\r\�r[rr[r[rr	r\)	r"r
�nanrr�rr!Zfloat_Zisnan)rAZpsrrrr�r%r%r&�test_nans$



zTestCond.test_nancCs�tj�d�tj�dddd�}d|d<d|d<dD]T}t�||�}t|dtj�t|dtj�tt�	|d��tt�	|d��q2dS)	NrPr\rrXr{)Nr[r\r�rorpr��r[r)
r"�random�seed�randrr�rr
rZisfinite)rArrr�r%r%r&�test_stacked_singularszTestCond.test_stacked_singularN)
rIrJrKrr
r�r��xfailrrr%r%r%r&r�s	
�
rc@seZdZdd�ZdS)�	PinvCasescCs<t�|�}t}t||||�|�|ddd�tt||��dS)Nrcrbr��r�pinvr�rrr'�rAr-r.r@Za_ginvrr%r%r&rD1s
zPinvCases.doNr�r%r%r%r&r,src@seZdZdS)�TestPinvNr�r%r%r%r&r9src@seZdZdd�ZdS)�PinvHermitianCasescCs@tj|dd�}t}t||||�|�|ddd�tt||��dS)NTr�rcrbr�rrr%r%r&rD?szPinvHermitianCases.doNr�r%r%r%r&r=src@seZdZdS)�TestPinvHermitianNr�r%r%r%r&rGsrc@seZdZdd�ZdS)�DetCasesc
Cs�t�|�}t�|�\}}t|�jjttfvr<t|��t�}nt|��t	�}t�
|�}t|tj
|dd��t|t�|�tj
|dd��t�|�}t�|�}|dk}	tt�||	�d�t||	t�dS)Nro��axisrr[)r�det�slogdetrr+r rr�astyperr�rr�reducer"ZexpZ
atleast_1drrrr
)
rAr-r.r@�dr�ZldZadr��mr%r%r&rDMs



zDetCases.doNr�r%r%r%r&r Ksr c@s:eZdZdd�Zej�deee	e
g�dd��Zdd�ZdS)	�TestDetcCstt�dgg�d�ttt�dgg��t�tt�dgg�d�ttt�dgg��t�tt�dgg�dtf�ttt�dgg�d�t�ttt�dgg�d�t�tt�dgg�dtf�ttt�dgg�d�t�ttt�dgg�d�t�dS)N�yrr[)rrr#r rrr$r
rGr%r%r&�	test_zero`szTestDet.test_zeror+cCs^tjddgddgg|d�}ttj�|�j|�tj�|�\}}t|jt|��t|j|�dSr�)r"rrrr#r+r$r3)rAr+r��phr�r%r%r&r�ms
zTestDet.test_typescCs�tjdtjd�}t�|�}t|d�t|jjtju�t�	|�}t|d�t|djjtju�t|djjtj
u�tjdtjd�}t�|�}t|d�t|jjtju�t�	|�}t|d�t|djjtju�t|djjtju�dS)NrXr2rQrrr[)r"r�r�rr#rrr+r r$�float32r�)rAr-r�r%r%r&r�us 







zTestDet.test_0_sizeN)
rIrJrKr+r�r�r�rrrrr�r�r%r%r%r&r)_s

r)c@seZdZdd�ZdS)�
LstsqCasescCsLt�|�}|j\}}t�|d�\}}}	tj||dd�\}
}}}
|dkrVt|
dk���||krzt|t	||
��t
||�n
t
||�t|
|
�|��||kr�||kr�t�tt�	||
�|��dj
dd�}t�|�}t�|�jdkr�d|_t
|j|j�nt�g��t|
��}t||�tt�|jtj��tt|
|��tt||��dS)	NFro�Zrcondrr\r!r[rm)r"rrirr��lstsqrr�rrrZ__array_wrap__rrr�r|rr�r �
issubdtyper+�floatingr')rAr-r.r@�arrr(�nr�r�r�r��	residuals�rank�svZ
expect_residsr%r%r&rD�s2


��

z
LstsqCases.doNr�r%r%r%r&r.�sr.c@s:eZdZdd�Zej�gd�gd��dd��Zdd�Zd	S)
�	TestLstsqc	Cs�t�gd�gd�gd�gd�g�j}t�gd��}t���}|�td�}t�||�\}}}}t|dk�tj||dd	�\}}}}t|dk�tj||dd	�\}}}}t|d
k�tt	|�dk�Wd�n1s�0YdS)N)r*rQr*rQrRr*)r*rRr*r*rQr*)rQr*rQr*r*rT)r*r*r*rRrSr*)r[rrrrrz`rcond` parameter will changer^ror/r]r[)
r"r�Tr�record�
FutureWarningrr0r�len)	rAr-r.�supr�r�r5r6r�r%r%r&�test_future_rcond�s
�zTestLstsq.test_future_rcond)r(r4�n_rhs))r^r\r\)rr^r[)rr^r\)r^rr[)r^rr\)r^r\r)rrrcCs�t�||��||�}t�||f�}tj||dd�\}}}}	|dkrTt|dk���t|j	||f�t|j	||krx|fnd�||kr�|dkr�|t�
||�}
t||
|
jdd��t|t
||��t|	j	t
||�f�dS)Nr/rrYrpr!)r"r�rhr
rr0rr�rrirrr�r)rAr(r4r?r-r.r�r5r6r�r�r%r%r&�test_empty_a_b�s
zTestLstsq.test_empty_a_bcCstt�gd��}t�gd��}t�|t�t|��g�j}ttd�� tj	||dd�Wd�n1sf0YdS)N)rr[r\r])rog�������?g�������?g������@gffffff
@zIncompatible dimensionsr/)
r"rZvstackr
r<r9rrrr0)rAr��yrr%r%r&�test_incompatible_dims�s
z TestLstsq.test_incompatible_dimsN)	rIrJrKr>r�r�r�r@rBr%r%r%r&r8�s	
r8�dtcCsg|]}t�|��qSr%)r"r+)rsr�r%r%r&rt�rurtz?bBhHiIqQefdgFDGOc@s�eZdZe�d�Zegd�Zegd�Zegd�ZeeeegZ	e
ddgddgg�Ze�egggd�Z
ee�d�e�d	�e�d
�gZdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestMatrixPowerr^)r]rr[r\)r\r]rr[)r[r\r]rr[rr\r��g�GcCs�|j�|�}tt|ddddd�|j�tt|ddddd�|j�tt|ddddd�|j�tt|ddddd�|j�dS)Nr\�di� rr[r])�rshft_1r%rr�rshft_0�rshft_2�rshft_3)rArCZrshftr%r%r&�test_large_power�s����z TestMatrixPower.test_large_powercCs>dd�}|jD]*}||�|��|tkr||j�|��qdS)NcSs*t|d�}t|t|��t|j|j�dS)Nr)rrr�r+)�M�mzr%r%r&�tz�s
z.TestMatrixPower.test_power_is_zero.<locals>.tz��	rshft_allr%�object�stacked�rArCrPr�r%r%r&�test_power_is_zero�s

z"TestMatrixPower.test_power_is_zerocCs>dd�}|jD]*}||�|��|tkr||j�|��qdS)NcSs&t|d�}t||�t|j|j�dS)Nr[)rrr+)r�rOr%r%r&rP�s

z-TestMatrixPower.test_power_is_one.<locals>.tzrQrUr%r%r&�test_power_is_one�s

z!TestMatrixPower.test_power_is_onecCs>dd�}|jD]*}||�|��|tkr||j�|��qdS)NcSs>t|d�}|jtkrtnt}t||||��t|j|j�dS)Nr\)rr+rSr	rr)r�rO�mmulr%r%r&rP
s
z-TestMatrixPower.test_power_is_two.<locals>.tzrQrUr%r%r&�test_power_is_two	s

z!TestMatrixPower.test_power_is_twocCs0dd�}|jD]}||jvr||�|��qdS)NcSs4t|d�}|jtkrtnt}t|||�t|��dS�Nro)rr+rSr	rrr�)r�ZinvmatrXr%r%r&rPs

�z3TestMatrixPower.test_power_is_minus_one.<locals>.tz)rR�dtnoinvr%rUr%r%r&�test_power_is_minus_ones

z'TestMatrixPower.test_power_is_minus_onecCs.|j�|�}ttt|d�ttt|dg�dS)Ng�?r[)rJr%r�	TypeErrorr�rArCr�r%r%r&�test_exceptions_bad_power sz)TestMatrixPower.test_exceptions_bad_powercCsPtttt�dg|�d�tttt�dgdgg|�d�tttt�d|�d�dS)Nr[r\)r^r]r\)rrrr"rr
)rArCr%r%r&�test_exceptions_non_square%sz*TestMatrixPower.test_exceptions_non_squarecCs,||jvrdS|j�|�}ttt|d�dSrZ)r[�noninvr%rrrr^r%r%r&�test_exceptions_not_invertible*s
z.TestMatrixPower.test_exceptions_not_invertibleN)rIrJrKr"r�rJrIrKrLrRrra�blockrTrSr+r[rMrVrWrYr\r_r`rbr%r%r%r&rD�s 
rDc@seZdZdd�ZdS)�TestEigvalshCasescCs^t�|d�}t�|�\}}|jdd�t||t|j�d�t�|d�}t||t|j�d�dS)N�Lror!r��U)r�eigvalshr�r�rr5r+)rAr-r.r@r�r�r��ev2r%r%r&rD3szTestEigvalshCases.doNr�r%r%r%r&rd1srdc@sBeZdZej�deeee	g�dd��Z
dd�Zdd�Zdd	�Z
d
S)�TestEigvalshr+cCs:tjddgddgg|d�}tj�|�}t|jt|��dSr�)r"rrrgrr+r3)rAr+r�r�r%r%r&r�@szTestEigvalsh.test_typescCsXtjddgddggtjd�}tttjj|dd�tttjj|d�tttjj|d�dS�Nr[r�r2Zlrong�ZUPLO�lower�upper)r"rr-rr�rrg�rAr�r%r%r&�test_invalidFszTestEigvalsh.test_invalidcCs�tjddgddggtjd�}tjddgddggtjd�}tjddgtjd�}ttj�}tj�|�}t|||d�tjj|dd�}t|||d�tjj|dd�}t|||d�tjj|d	d�}t|||d�tjj|d
d�}t|||d�dS�Nrr[r2ror�rerk�lrfr�)r"rrr5rrgr)rA�Klo�Kup�tgtr�r�r%r%r&�	test_UPLOLs
zTestEigvalsh.test_UPLOcCs�Gdd�dtj�}tjdtjd��|�}t�|�}t|jj	tj
u�td|j�tt
|tj��tjdtjd��|�}t�|�}t|jj	tju�td|j�tt
|tj��dS)Nc@seZdZdS)z/TestEigvalsh.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r�dsr�r�r2r�rXrY)r"r#r�r�r�rrgrr+r r�rrir!r�r-r�r%r%r&r�bs

zTestEigvalsh.test_0_sizeN�rIrJrKr�r�r�rrrrr�rorur�r%r%r%r&ri?s

ric@seZdZdd�ZdS)�
TestEighCasesc
Cs�t�|�\}}t�|�\}}|jdd�t||�tt||�t�|�dddd�ft�|�t	|j
�d�t�|d�\}}	t||�tt||	�t�|�dddd�ft�|	�t	|j
�t|�d�dS)Nror!.r�rf)r��err_msg)r�eighr�r�rrr�r"rr5r+�repr)
rAr-r.r@r�Zevcr�r�rhZevc2r%r%r&rDws

 �

 �zTestEighCases.doNr�r%r%r%r&rwusrwc@sBeZdZej�deeee	g�dd��Z
dd�Zdd�Zdd	�Z
d
S)�TestEighr+cCsJtjddgddgg|d�}tj�|�\}}t|jt|��t|j|�dSr�)r"rrryrr+r3r�r%r%r&r��szTestEigh.test_typescCsXtjddgddggtjd�}tttjj|dd�tttjj|d�tttjj|d�dSrj)r"rr-rr�rryrnr%r%r&ro�szTestEigh.test_invalidcCstjddgddggtjd�}tjddgddggtjd�}tjddgtjd�}ttj�}tj�|�\}}t|||d�tjj|dd�\}}t|||d�tjj|dd�\}}t|||d�tjj|d	d�\}}t|||d�tjj|d
d�\}}t|||d�dSrp)r"rrr5rryr)rArrrsrtr�r�r�r%r%r&ru�s
zTestEigh.test_UPLOcCs�Gdd�dtj�}tjdtjd��|�}t�|�\}}t|jj	tj
u�t|jj	tj
u�t|j|j�td|j�tt
|tj��tjdtjd��|�}t�|�\}}t|jj	tju�t|jj	tju�t|j|j�td|j�tt
|tj��dS)Nc@seZdZdS)z+TestEigh.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r��sr�r�r2r�rXrY)r"r#r�r�r�rryrr+r r�rrir!r�r-r�r%r%r&r��szTestEigh.test_0_sizeNrvr%r%r%r&r{�s

r{c@s eZdZdZdZedd��ZdS)�
_TestNormBaseNcCs:t|jjtj�r"t|j|jj�ntt|jjtj��dSr)	�
issubclassr+r r"Zinexactr�realrr2)r�r�r%r%r&�check_dtype�sz_TestNormBase.check_dtype)rIrJrKrC�dec�staticmethodrr%r%r%r&r|�sr|c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�_TestNormGeneralcCsFttg�d�tttg|jd��d�ttttg|jd���d�dS)Nr*r2)rrrrCrrGr%r%r&�
test_empty�sz_TestNormGeneral.test_emptyc		Cs�t�gd��}tjd}tjd}||}|D�]N}|�|�}t|tj�}|�||�t|d�t��<}|�	t
d�t|d�}|�||�t|d�Wd�n1s�0Yt|d�}|�||�t|d�t|d	�}|�||�t|d
�t|d�}|�||�t||j�d
�|j�d��t|d�}|�||�t||j�d
�|j�d
��t|tj�}|�||�t|d�q.dS)Nr�
AllIntegerZAllFloatr*�divide by zero encounteredrorr\r[rRr�r^g�?rQ)
r"r�	typecodesr%rr
rrr�filter�RuntimeWarningr+r �	rAr-Zexact_typesZ
inexact_typesZ	all_typesZ	each_typeZatZanr=r%r%r&�test_vector_return_type�s:





(





z(_TestNormGeneral.test_vector_return_typecsvgd�}gd�}gd�}�fdd�}|||fD]}||�q.t|�jd�t|�jd�t|�jd�fD]}||�qddS)N)r[r\r]r^)rorprqrn)ror\rqr^cs�tjjt|�d�jd�tjjt|t�d�jd�tjjt|t�d�jd�tjjt|d�d�jd�tjjt|d�d�jd�tjjt|d	�d�jd�tjjt|d
�d�jd�tjjt|d�d
�jd�dS)Ng��6ҭ�@�r*rTrQr[�$@rog���Q��?r\rpg�s�c���?rr^)r"�testingrrr�r
)r�rGr%r&�_tests0��������z+_TestNormGeneral.test_vector.<locals>._testr2)rrC)rAr-r.r�r�r�r%rGr&�test_vectors
�z_TestNormGeneral.test_vectorc		s�tgd�gd�g|jd��ddddddtjtjfD]h���fd	d
�t�jd�D�}tt��dd�|���fdd
�t�jd�D�}tt��dd�|�q4tjdd
|jd��	ddd���j
}dddddtjtjdfD]؉t�t||�d�D]�}|\}}|dk�r||7}|dk�r"||7}||k�r@t
tt��|d�q�t��|d�}|||�||k�r����fdd
�t�j��D�}n ���fdd
�t�j��D�}t||�q�q�dS)N�r[r\r]�r^rcr(r2rorr[r\r]cs$g|]}t�dd�|f�d��qS�N��ord�r�rs�k�r�orderr%r&rt'ruz._TestNormGeneral.test_axis.<locals>.<listcomp>�r�r"cs$g|]}t�|dd�f�d��qSr�r�r�r�r%r&rt)ru�r^rpr�cs*g|]"}t�dd�j|�d��d��qS�Nr!r�)r�taker���B�k_indexr�r%r&rt?s�cs,g|]$}t�dd�j|�d�j�d��qSr�)rr�r9r�r�r%r&rtBs�)rrCr"�Infr�rirrr�rhr|r}�combinationsrr�)	rAZ	expected0Z	expected1Zndr"Zrow_axisZcol_axisr4r�r%)rr�r�r�r&�	test_axis!s6



��z_TestNormGeneral.test_axisc	
Cs�tjdd|jd��ddd�}d}d}t|ddd	�}t|ddd
d�}tt�|�||�dd�d�d
}t|j	|k|�|j	|dd��ddddddtj
tj
fD]�}t|j�D]v}t|||d	�}t|||d
d�}tt�|�||�||�d�t
|j	�}d||<t|�}t|j	|k|�|j	|||��q�q�dddddtj
tj
ddf	D]�}t�t|j�d�D]�}t|||d	�}t|||d
d�}tt�|�||�||�d�t
|j	�}d||d<d||d<t|�}t|j	|k|�|j	|||���qT�q>dS)Nr[r�r2r\r]r^zorder {0}, axis = {1}z;Shape mismatch found {0}, expected {1}, order={2}, axis={3}r�T)r�r"Zkeepdims)rx)r[r[r[rorrpr��nuc)r"r�rCrhrrZsqueeze�formatrrir�r�r|r�rr}�permutations)	rArZallclose_errZ	shape_errr��foundZexpected_shaper�r�r%r%r&�
test_keepdimsFsN
�
�
�

� 
�

�z_TestNormGeneral.test_keepdimsN)rIrJrKr�r�r�r�r�r%r%r%r&r��s
)%r�c@s:eZdZejZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)�_TestNorm2DcCs tt|jgg|jd��d�dS)Nr2r*)rrrrCrGr%r%r&�test_matrix_emptyvsz_TestNorm2D.test_matrix_emptyc		Cs�|�gd�gd�g�}tjd}d}||}|D�]N}|�|�}t|tj�}|�||�t|d�t��<}|�	t
d�t|d�}|�||�t|d�Wd�n1s�0Yt|d	�}|�||�t|d�t|d
�}|�||�t|d�t|d�}|�||�t|d�t|tj�}|�||�t|d�t|d
�}|�||�t|d�t|d�}|�||�tjj|ddd�q0dS)Nrr�r�ZfdFDrRr�rorQr[r\g�LX�z��?rpr�r�gU&,t=�@r(r�)rr"r�r%rr
rrrr�r�r�r�r%r%r&�test_matrix_return_typeys@




(









z#_TestNorm2D.test_matrix_return_typecCs�|jddgddgg|jd�}tt|�d�tt|d�d�tt|d�d	�tt|t�d
�tt|t�d�tt|d�d	�tt|d�d
�tt|d�d�tt|d�d�ttt|d�ttt|d�ttt|d�dS)Nr[r]rcrdr2g���T"@r�r�r�g(@rTrorUr\g��W�?"@rpgї�ʄ�?Znofrorqr)rrCrrr
rr�rr%r%r&�test_matrix_2x2�sz_TestNorm2D.test_matrix_2x2cCs�d|jgd�gd�gd�g|jd�}tt|�d�tt|d�d�tt|d�d	�tt|t�d
�tt|t�d�tt|d�d
�tt|d�d�tt|d�d�tt|d�d�dS)Ng�������?r�)r(rrc)r]r\r[r2grj=Q0�?r�r�g�B+pc�?g�������?g333333�?r[rQrog�������?r\g�&��.d�?rpgܸՠ���?)rrCrrr
rr%r%r&�test_matrix_3x3�s �z_TestNorm2D.test_matrix_3x3cCs|jgd�gd�g|jd�}tjdd|jd��ddd�}ttt|d	d
�ttt|dd
�tttddgd	d�tttddgdd�tttddgdd�d
D]4}ttt||d�ttt||d�ttt||d�q�ttjt|dd�ttjt|dd�ttt|dd�dS)Nr�r�r2r[r�r\r]r^r�rr��test�rr]r�)r[r\�r\r])rr[r\)	rrCr"r�rhrr�rZ	AxisError)rArr�r�r%r%r&�
test_bad_args�sz_TestNorm2D.test_bad_argsN)
rIrJrKr"rr�r�r�r�r�r%r%r%r&r�qs3r�c@seZdZdS)�	_TestNormNr�r%r%r%r&r��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�TestNorm_NonSystematiccCs*tjdtjd�}tt|dd�ddd�dS)N�
r2r]r�g�����L)@r\r�)r"r�Z
longdoubler,rrnr%r%r&�test_longdouble_norm�sz+TestNorm_NonSystematic.test_longdouble_normcCs,tjdgtjd�}tt|dd�ddd�dS)Ni�r2r]r�lrcr�)r"rZint32r,rrnr%r%r&�test_intmin�sz"TestNorm_NonSystematic.test_intmincCs�tjdtjd�}d|d<d|d<d}ttjj|dd	�|d
d�|�tj�}ttjj|dd	�|dd�|�tj�}ttjj|dd	�|d
d�dS)N�r\r2y@@ry�@r[g���V;'@r]r�r�r��	rc)	r"r�Zclongdoubler,rrr%�
complex128r�)rAr'r�r%r%r&�test_complex_high_ord�sz,TestNorm_NonSystematic.test_complex_high_ordN)rIrJrKr�r�r�r%r%r%r&r��sr�c@seZdZejZdZdS)�_TestNormDoubleBaser)N)rIrJrKr"rrCr�r%r%r%r&r�	sr�c@seZdZejZdZdS)�_TestNormSingleBaser(N)rIrJrKr"r-rCr�r%r%r%r&r�sr�c@seZdZejZdZdS)�_TestNormInt64Baser)N)rIrJrKr"Zint64rCr�r%r%r%r&r�sr�c@seZdZdS)�TestNormDoubleNr�r%r%r%r&r�sr�c@seZdZdS)�TestNormSingleNr�r%r%r%r&r�sr�c@seZdZdS)�
TestNormInt64Nr�r%r%r%r&r� sr�c@seZdZdd�Zdd�ZdS)�TestMatrixRankcCs�tdtt�d���t�d�}d|d<tt|�d�ttt�d��d�ttgd��d�ttt�d	��d�ttdg�d�t�|t�d�t�d�g�}tt|�t�gd
���ttd�d�dS)Nr^r*�roror]r�r)r[rrrr[)r^)r]r^r)rrr"r�r�r)rA�I�msr%r%r&�test_matrix_rank&s
zTestMatrixRank.test_matrix_rankcCs�tdtt�d�dd��tdtt�d�dd��tdtt�d�dd��t�d�}d|d<td	t|dd��d
|d<tdt|ddd��td	t|dd
d��dS)Nr^Tr�r[r�rr*r�r]g:�0�yE>g��|"�BE>)r9Ztolg�;䡈�E>)rrr"r�r
r�)rAr�r%r%r&�test_symmetric_rank:s
z"TestMatrixRank.test_symmetric_rankN)rIrJrKr�r�r%r%r%r&r�$sr�cCs�tj�d�}td�D]�}|jdd�}|dd�df|dd�df|dd�df<tt|�d�|dd�d	f|dd�d
f|dd�df<tt|�d�qdS)
Ni�3rG)�(r���sizer[r\rr�r^rcr]rZ)r"rZRandomStater��normalrr)�rng�i�Xr%r%r&�test_reduced_rankHs,,r�c	@s�eZdZejZdd�Zej�ddggd��dd��Z	dd	�Z
d
d�Zdd
�Zej�dgd��ej�dgd��ej�dej
ejejejg�dd����ZdS)�TestQRcCs�t|�}|j}|j\}}t||�}tj|dd�\}}t|j|k�t|j|k�tt||��tt||��t|j||fk�t|j||fk�tt	||�|�tt	|j
��|�t�
|��tt�|�|�tj|dd�\}	}
t|	j|k�t|
j|k�tt|	|��tt|
|��t|	j||fk�t|
j||fk�tt	|	|
�|�tt	|	j
��|	�t�
|��tt�|
�|
�tj|dd�}t|j|k�tt||��t||
�dS)N�complete��mode�reducedr�)r r+rirr�qrrr!rrr9r�r"r��triu)rAr-�a_type�a_dtyper(r4r��qr��q1�r1�r2r%r%r&�check_qrYs8

zTestQR.check_qrr(r4)�r]rr�rXcCstt||�}t�||f�}|�|�tjj|dd�\}}t|jtj�t|jtj�t|j	||f�t|j	|f�dS)N�rawr�)
rr"r�r�rr�rr+rri)rAr(r4r�r-�h�taur%r%r&�
test_qr_empty�s

zTestQR.test_qr_emptycCs�|jddgddgddggtjd�}tj|dd	�\}}t|jtjk�t|jtjk�t|jd
k�t|jdk�tj|jdd	�\}}t|jtjk�t|jtjk�t|jdk�t|jdk�dS)
Nr[r\r]r^rcr(r2r�r�r�r�re)	rr"rrr�rr+rir9)rAr-r�r�r%r%r&�
test_mode_raw�s"zTestQR.test_mode_rawcCs�|�ddgddgg�}|�ddgddgddgg�}dD]8}|�|�}|�|�}|�|�|�|�|�|j�q6dD]H}dd|�|�}dd|�|�}|�|�|�|�|�|j�qtdS)	Nr[r\r]r^rcr(�fd��?)rr%r�r9)rAr-r.rCZm1Zm2r%r%r&�test_mode_all_but_economic�s





z!TestQR.test_mode_all_but_economiccCsft|�}|j}|jdd�\}}t||�}tj|dd�\}}t|j|k�t|j|k�tt||��tt||��t|jdd�||fk�t|jdd�||fk�tt	||�|�t
�|jd�}	t
�|	|jdd�|jdfd�}
tt	t
|dd���|�|
�tt
�|ddd�dd�f�|�tj|dd�\}}t|j|k�t|j|k�tt||��tt||��t|jdd�||fk�t|jdd�||fk�tt	||�|�t
�|jd�}	t
�|	|jdd�|jdfd�}
tt	t
|dd���|�|
�tt
�|ddd�dd�f�|�tj|dd�}
t|
j|k�tt|
|��t|
|�dS)	Nrpr�r�ror\.r�r�)r r+rirrr�rr!rr	r"rr�r
r�r�)rAr-r�r�r(r4r�r�r�ZI_matZstack_I_matr�r�r�r%r%r&�check_qr_stacked�sL
�"��"zTestQR.check_qr_stackedr�))r]r^)r^r]r�r�r��
outer_size)rr�)r\r]r^rCcCsPtjj||d��|�}tjj||d��|�}|�|�|�|d|�dS)Nr�r�)r"rr�r%r�)rAr�r�rCrr�r%r%r&�test_stacked_inputs�s

zTestQR.test_stacked_inputsN)rIrJrKr"rr�r�r�r�r�r�r�r�rrrrr�r%r%r%r&r�Us'
-�r�c@sLeZdZej�dgd��ej�dejejej	ej
f�dd���Zdd�ZdS)	�TestCholeskyri)r{r�r]r])�2r�)r]r�r�r+c
Cs�tj�d�tjj|�}t�|tj�r:|dtjj|�}ttt|���}d|dd�<t�	|�
|���|�}tj||d�}tj
�|�}t�	||�
|����}t|||�d|�d|�d|��d|jd	t�|�jd
�dS)Nr[r�)rorprpr2� �
i�r)rxZatol)r"rr�randnr1Zcomplexfloatingr�r�r<r	r�r�rr�choleskyrriZfinfoZeps)rArir+r-�tr�r.r%r%r&�test_basic_property�s�z TestCholesky.test_basic_propertycCs�Gdd�dtj�}tjdtjd��|�}t�|�}t|j|j�t	|j
jtju�t	t
|tj��tjdtjd��|�}t�|�}t|j|j�t	|j
jtju�t	t
|tj��dS)Nc@seZdZdS)z/TestCholesky.test_0_size.<locals>.ArraySubclassNr�r%r%r%r&r�sr�r�r2)r[rr)r"r#r�r�r�rr�rrirr+r r�r!r�r�r%r%r&r�s

zTestCholesky.test_0_sizeN)
rIrJrKr�r�r�r"r-r�r�r�r�r�r%r%r%r&r��s��r�cCs�tjdkrd}nd}tjtjfD]r}tjd|d�}|�|�}|�d���}t|j	jd�t
jt
jt
j
fD](}||�}t|||��t|||��qhq dS)N�little�<rFr^r2�S�=)�sys�	byteorderr"r-r�r�ZnewbyteorderZbyteswaprr+rr�r#rr)ZnativeZdttr3Zn_arrZsw_arrZroutiner�r%r%r&�test_byteorder_check#s

r�cCslt�ddgddgg�}t�ddgddgg�}t�gd��ddd�}||d<||d<ttjjtjj|�dS)Nr[r\r]r^)r^r^r\r\.rX)r"rr�rrrr�)Z
invertibleZnon_invertibler�r%r%r&� test_generalized_raise_multiloop8sr�cCsLd}zt��}Wn ttfy0t�d�Yn0|dk�r"t�d�t�d�ddl}|�|j	d�zt
jj�
�Wn.ty�Ynty�t�tj�Yn0z0t
�dgg�}t
jj�ddd|d||dd�	Wn<t�y}z"dt|�vr�t�|�WYd}~n
d}~00t�tj�n&t��\}}t�|�|k�rHt�d�dS)	N�zNot POSIX or fork failed.rr[rXrQzDORGQR parameter number 5zNumpy xerbla not linked in.)�os�fork�OSError�AttributeErrorr��skip�close�resourceZ	setrlimitZRLIMIT_COREr"r�lapack_liteZxerblar�r��_exit�	EX_CONFIGrZdorgqrr=�wait�WEXITSTATUS)Z	XERBLA_OK�pidrr-r��statusr%r%r&�test_xerbla_overrideFs<


� r	cCsdddg}t�d�}|D]H}|jdd|d�}t�tjd|g�|jdd|d�}t�tjd|g�qdS)	NzPyQt5.QtWidgetsZIPythonz�
    import sys
    {before}
    try:
        import {bad_lib}
    except ImportError:
        sys.exit(0)
    {after}
    x = np.ones(2, dtype=np.float32)
    sys.exit(0 if np.allclose(x.dot(x), 2.0) else 1)
    zimport numpy as np�)�before�after�bad_libz-c)rrr
)�textwrap�dedentr��
subprocessZ
check_callr��
executable)Zbad_libs�templater
�coder%r%r&�test_sdot_bug_8577ws

��rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�TestMultiDotc	Csltj�d�}tj�d�}tj�d�}tt|||g�|�|��|��tt|||g�t�|t�||���dS�N�r(r\�r\r(�r"rrrr)rArr��Cr%r%r&�(test_basic_function_with_three_arguments�s
 z5TestMultiDot.test_basic_function_with_three_argumentscCsNtj�d�}tj�d�}tt||g�|�|��tt||g�t�||��dSrr)rArr�r%r%r&�&test_basic_function_with_two_arguments�sz3TestMultiDot.test_basic_function_with_two_argumentscCs\tj�d�}tj�d�}tj�d�}tj�d�}tt||||g�|�|��|��|��dS)Nrr�r\r[r)rArr�r�Dr%r%r&�9test_basic_function_with_dynamic_programming_optimization�s
zFTestMultiDot.test_basic_function_with_dynamic_programming_optimizationcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nr\rrrr��r"rrrri)rA�A1dr�rrr%r%r&�test_vector_as_first_argument�s
z*TestMultiDot.test_vector_as_first_argumentcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nrrr\)r(r )rArr�r�D1dr%r%r&�test_vector_as_last_argument�s
z)TestMultiDot.test_vector_as_last_argumentcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nr\rrr%r )rAr!r�rr#r%r%r&�&test_vector_as_first_and_last_argument�s
z3TestMultiDot.test_vector_as_first_and_last_argumentc	Csttj�d�}tj�d�}tj�d�}t�d�}t|||g|d�}t||�|��|��t|t�|t�||���dS)Nrr�r$�r"rr�rrr)rArr�rr$�retr%r%r&�test_three_arguments_and_out�s
z)TestMultiDot.test_three_arguments_and_outcCsXtj�d�}tj�d�}t�d�}t||g|d�}t||�|��t|t�||��dS)Nrr)r(r(r&r')rArr�r$r(r%r%r&�test_two_arguments_and_out�s
z'TestMultiDot.test_two_arguments_and_outcCsntj�d�}tj�d�}tj�d�}tj�d�}t�d�}t||||g|d�}t||�|��|��|��dS)Nrrr)r(r[r&r')rArr�rrr$r(r%r%r&�-test_dynamic_programming_optimization_and_out�s
z:TestMultiDot.test_dynamic_programming_optimization_and_outc	Cstj�d�tj�d�tj�d�tj�d�tj�d�tj�d�g}t�gd�gd�gd	�gd
�gd�gd�g�}tjgd
�gd�gd�gd�gd�gd�gtd�}|d8}t|dd�\}}tt�|dd�dd�f�t�|dd�dd�f��tt�|�t�|��dS)N)��#)r-�)r.rc)rcr�)r��)r/r�)r*g��@gþ@g�O�@g�1�@g���@)r*r*g��@g�@gջ@g��@)r*r*r*gp�@g��@g��@)r*r*r*r*g@�@gX�@)r*r*r*r*r*g��@)r*r*r*r*r*r*)rr[r[r]r]r])rrr\r]r]r])rrrr]r]r])rrrrr^rc)rrrrrrc)rrrrrrr2r[T)Zreturn_costsro)r"rr�intrrr�)rAZarraysZ
m_expectedZ
s_expectedr�r(r%r%r&�test_dynamic_programming_logic�s:





�
�
���z+TestMultiDot.test_dynamic_programming_logiccCs&tttg�ttttj�d�g�dS)Nr�)rr�rr"rrGr%r%r&�test_too_few_input_arrayssz&TestMultiDot.test_too_few_input_arraysN)rIrJrKrrrr"r$r%r)r*r+r1r2r%r%r%r&r�s
	




rc@sveZdZej�de�d�dfe�d�dfg�dd��Zej�dd	d
g�dd��Z	ej�d
ddg�dd��Z
dd�ZdS)�
TestTensorinvzarr, ind�r^r(rZr\r\�r]r]r\r[cCs:tt��tj||d�Wd�n1s,0YdS)N��ind)rrr�	tensorinv)rAr3r7r%r%r&�test_non_square_handlings
z&TestTensorinv.test_non_square_handlingz
shape, ind)�r^r(rZr]r\)��rZr]r[cCsNt�d�}||_tj||d�}|j|d�|jd|�}|j}t||�dS)Nr<�r-r7)r"r�rirr8r)rArir7r-�ainvr��actualr%r%r&�test_tensorinv_shape%s
z"TestTensorinv.test_tensorinv_shaper7rrpcCsJt�d�}d|_tt��tj||d�Wd�n1s<0YdS)Nr<r:r=)r"r�rirr�rr8)rAr7r-r%r%r&�test_tensorinv_ind_limit2s

z&TestTensorinv.test_tensorinv_ind_limitcCsJt�d�}d|_tj|dd�}t�d�}tt�||d�tj�||��dS)Nr<r;r[r6)	r"r�rirr8r
r�	tensordot�tensorsolve)rAr-r>r.r%r%r&�test_tensorinv_result;s


z#TestTensorinv.test_tensorinv_resultN)rIrJrKr�r�r�r"r
r9r@rArDr%r%r%r&r3s�
�
�
r3c@sTeZdZej�de�d�dfe�d�dfg�dd��Zej�dgd	��d
d��Z	dS)�TestTensorsolveza, axesr4Nr5)rr\cCsPtt��4t�|jdd��}tj|||d�Wd�n1sB0YdS�Nr\r�)rrr"r
rirrC)rAr-r�r.r%r%r&r9Fs
z(TestTensorsolve.test_non_square_handlingri))r\r]r()r]r^r^r])rr]r]rcCsNtjj|�}t�|jdd��}tj�||�}ttj||t	|j�d�|�dSrF)
r"rr�r
rirrCrrBr<)rArir-r.r�r%r%r&�test_tensorsolve_resultOsz'TestTensorsolve.test_tensorsolve_result)
rIrJrKr�r�r�r"r
r9rGr%r%r%r&rEDs�
�rEcCsRtjddgddggdd�}ttd��t�|�Wd�n1sD0YdS)Nr[rpr\rcZfloat16r2zunsupported in linalg)r"rrr]rr�)r3r%r%r&�test_unsupported_commontypeYsrHz,Bad memory reports lead to OOM in ci testing)rcCsRd}tjd|gtjd�}tjddgtjd�}d|d<t�||�}t|dd�dS)N�r[r2)rro)r"r�r-r
rr)r4r-r.r�r%r%r&�test_blas64_dotdsrJz*Numpy not compiled with 64-bit BLAS/LAPACKc
	Cs�tj}tjjj}d}d}|}tjddg|d�}tjdg|d�}tjdg|d�}|||||||dd�}t|dd�t|d|�t|d|�t|���}	t	d	|	ko�d
kn�dS)Nlr[r2ror�infor(r4rIl)
r"r�rrZdgeqrfr�rr0�itemr)
r+Zlapack_routiner(r4Zldar-Zworkr��resultsZlworkr%r%r&�!test_blas64_geqrf_lwork_smoketestns
rN)r(r))~�__doc__r�r�r}r�rrr�Znumpyr"rrrrrrrr	Z
numpy.corer
rrr
rrZnumpy.linalgrrrrrZnumpy.linalg.linalgrZ
numpy.testingrrrrrrrrrr'r,r3r4r5Zall_tagsr<rOrrrfr�rrlr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr r)r.r8r�r�rDrdrirwr{r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r	r�rrr3rErHr�rJrrNr%r%r%r&�<module>s(,
	�������
�
���#����������������
�
�
�
�
��9��������� 
0


:	
$.C�

*4U6;
x$
!.1
")
	
�

Zerion Mini Shell 1.0