https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/numpy/linalg/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/numpy/linalg/tests/__pycache__/test_linalg.cpython-310.pyc
o

6��a#�@sX
dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddlm
Z
mZmZm
Z
mZmZmZmZddlmZmZmZmZddlmZddlmZmZmZmZmZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(dd	l)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�Zwd�d�Zxej[jtej[jye(d�d�d�e*d�d�d�d����Zzej[jye(d�d�d�d��Z{dS)�z# Test functions for linalg module

�N)�array�single�double�csingle�cdouble�dot�identity�matmul)�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_LAPACK64)�requires_memorycCs$t|�t|tj�rt|�uStjuS�N)�type�
isinstance�np�ndarray)�out�in_�r&�@/usr/lib/python3/dist-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,�
��r4cCstttttttti|Sr)rrrrr3r&r&r'�get_complex_dtype1r5r6cCs|ttfvrdSdS)Ng�h㈵��>g�dy���=)rrr3r&r&r'�get_rtol6sr7>�square�strided�	hermitian�	nonsquare�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/rBr&r&r'�__init__Fs
zLinalgCase.__init__cCs||j|j|jd�dS)zN
        Run the function `do` on this test case, expanding arguments
        �rBN)r.r/rB)rC�dor&r&r'�checkQszLinalgCase.checkcCsd|j�d�S)Nz
<LinalgCase: �>)r@�rCr&r&r'�__repr__WszLinalgCase.__repr__N)�__name__�
__module__�__qualname__�setrDrGrJr&r&r&r'r>Esr>cCs,|tvsJd��|D]	}|j|hB|_q
|S)z^
    Add the given tag (a string) to each of the cases (a list of LinalgCase
    objects)
    zInvalid tag)�all_tagsrB)�tag�cases�caser&r&r'�	apply_tag[srS��r8r��?�@�@�@r3r�double_2)rVrUrX)rWrX�@r��?@y@@y@@y@@�@�?r�	cdouble_2)r\r[y�?@)y�?�y�?�y�?��0x0�rr�rr=rE�8x8��1x1��nonarray���r;�single_nsq_1)rUrVrW�single_nsq_2g@rZ)rVrUrW�double_nsq_1�double_nsq_2�
csingle_nsq_1)��?�?�@@�@�)y@�y@"@y@@�
csingle_nsq_2rnrorpy@"�y@�y@ @)r\r[rp�
cdouble_nsq_1�
cdouble_nsq_2�cdouble_nsq_1_2y�?�y@��cdouble_nsq_2_2�8x11��1x5��5x1�0x4�4x0r:�hsingle�hdouble�hcsingley@��hcdouble�hempty�	hnonarray�
matrix_b_only�hmatrix_1x1cCsg}tD]�}t|jtj�sqt�|jd|jd|jg�}|jdur%d}nt�|jd|jd|jg�}t|jd|||j	dhBd�}|�
|�t�|jgdd��d|jj�}|jdurbd}nt�|jgdd��d|jj�}t|jd	|||j	dhBd�}|�
|�q|S)
Nrfrg�r)�_tile3r<rE�rgrf�_tile213)
�CASESr!r.r"r#rr/r>r@rB�append�reshape�shape)�	new_casesrRr.r/�new_caser&r&r'�_make_generalized_cases�s*

�
$
$
�r�ccs��t|tj�s|dfVdSdg|j}d|d<|jdkr!d|d<|jdkr*d	|d
<tjt|��D]�}dd�t|j|�D�}td
d�|D��}tj	||j
d�}|�tj��
d�||}||d<|�|j�}tt�||k��|dd�dd�|D��fV|jdkr�|jddkr�t|j�}d|d<tjjj||d�}|dfV|jdkr�|jddkr�t|j�}d|d<tjjj||d�}|dfV|jdkr�|jdd�dkr�t|j�}d|d<d|d<tjjj||d�}|dfVq1dS)z<
    Generate cartesian product of strides for all axes
    �nopN�rd)rdrg������rd���rf)rdr����cSsg|]
\}}t||��qSr&)�abs)�.0r.r/r&r&r'�
<listcomp>sz%_stride_comb_iter.<locals>.<listcomp>cSsg|]}tdd|��qSr)�slice)r��repeatr&r&r'r�sr3l�>[=.�stride_�_cSsg|]}d|�qS)z%+dr&)r��jr&r&r'r�(sr)�strides�stride_xxx_0�stride_xxx_0_x�rdrd�stride_xxx_0_0)r!r"r#�ndim�	itertools�product�tuple�zipr��emptyr,�view�uint32�fill�	__class__r�all�join�listr��lib�
stride_tricks�
as_strided)�x�
stride_set�repeats�	new_shape�slices�xi�sr&r&r'�_stride_comb_iter
sL�








��r�c	Csng}tD]0}t|j�D](\}}t|j�D]\}}t|jd|d||||jdhBd�}|�|�qqq|S)Nr�r9rE)r�r�r.r/r>r@rBr�)r�rRr.�a_labelr/�b_labelr�r&r&r'�_make_strided_cases=s
���r�c@s"eZdZeZe�e�fdd�ZdS)�LinalgTestCasecCsv|jD]5}|j|@|kr
q|j|@rqz|�|j�Wqty8}zd|�d�}|t��7}t|�|�d}~wwdS)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_CASESrBrGrF�	Exception�	traceback�
format_exc�AssertionError)rC�require�excluderR�e�msgr&r&r'�check_casesQs


���zLinalgTestCase.check_casesN)rKrLrMr�r�rNr�r&r&r&r'r�Nsr�c@�eZdZdd�Zdd�ZdS)�LinalgSquareTestCasecC�|jdhddhd�dS)Nr8r<r=�r�r��r�rIr&r&r'�
test_sq_casesg�
�z"LinalgSquareTestCase.test_sq_casescC�|jddhdhd�dS)Nr8r=r<r�r�rIr&r&r'�test_empty_sq_casesk�

�z(LinalgSquareTestCase.test_empty_sq_casesN)rKrLrMr�r�r&r&r&r'r�e�r�c@r�)�LinalgNonsquareTestCasecCr�)Nr;r<r=r�r�rIr&r&r'�test_nonsq_casesrr�z(LinalgNonsquareTestCase.test_nonsq_casescCr�)Nr;r=r<r�r�rIr&r&r'�test_empty_nonsq_casesvr�z.LinalgNonsquareTestCase.test_empty_nonsq_casesN)rKrLrMr�r�r&r&r&r'r�pr�r�c@r�)�HermitianTestCasecCr�)Nr:r<r=r�r�rIr&r&r'�test_herm_cases}r�z!HermitianTestCase.test_herm_casescCr�)Nr:r=r<r�r�rIr&r&r'�test_empty_herm_cases�r�z'HermitianTestCase.test_empty_herm_casesN)rKrLrMr�r�r&r&r&r'r�{r�r�c@�,eZdZejjdd��Zejjdd��ZdS)�LinalgGeneralizedSquareTestCasecCr�)Nr<r8r=r�r�rIr&r&r'�test_generalized_sq_cases��

�z9LinalgGeneralizedSquareTestCase.test_generalized_sq_casescC�|jhd�d�dS)N>r8r<r=�r�r�rIr&r&r'�test_generalized_empty_sq_cases��z?LinalgGeneralizedSquareTestCase.test_generalized_empty_sq_casesN)rKrLrM�pytest�mark�slowr�r�r&r&r&r'r���

r�c@r�)�"LinalgGeneralizedNonsquareTestCasecCr�)Nr<r;r=r�r�rIr&r&r'�test_generalized_nonsq_cases�r�z?LinalgGeneralizedNonsquareTestCase.test_generalized_nonsq_casescCr�)N>r;r<r=r�r�rIr&r&r'�"test_generalized_empty_nonsq_cases�r�zELinalgGeneralizedNonsquareTestCase.test_generalized_empty_nonsq_casesN)rKrLrMr�r�r�r�r�r&r&r&r'r��r�r�c@r�)�HermitianGeneralizedTestCasecCr�)Nr<r:r=r�r�rIr&r&r'�test_generalized_herm_cases�r�z8HermitianGeneralizedTestCase.test_generalized_herm_casescCs|jhd�dhd�dS)N>r:r<r=�noner�r�rIr&r&r'�!test_generalized_empty_herm_cases�r�z>HermitianGeneralizedTestCase.test_generalized_empty_herm_casesN)rKrLrMr�r�r�r�r�r&r&r&r'r��r�r�cCs�t|�}|jdkrZ|j|jkr|jdd�|jdd�}n|j|jdkr.|jdd�}ntd��tj|t�||�d�}tjt	t
|jdd���D]
}t||||�||<qJ|St||�S)Nrgr�rdzNot implemented...r3r�)r
r�r��
ValueErrorr"r��common_typer�r��map�ranger)r.r/r��r�cr&r&r'�dot_generalized�s

r�cCsHt|�}|jdkrtj|j|jd�}t|jd�|d<|St|jd�S)Nrgr3r�.r)r
r�r"r�r�r,r)r.r�r&r&r'�identity_like_generalized�s
r�c@�eZdZdd�ZdS)�
SolveCasescCs.t�||�}t|t||��tt||��dSr)r�solverr�rr()rCr.r/rBr�r&r&r'rF�sz
SolveCases.doN�rKrLrMrFr&r&r&r'r���r�c@s:eZdZej�deeee	g�dd��Z
dd�Zdd�ZdS)	�	TestSolver,cCs2tjddgddgg|d�}tt�||�j|�dS�Nrd��?r3)r"rrrr�r,�rCr,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@�eZdZdS)z,TestSolve.test_0_size.<locals>.ArraySubclassN�rKrLrMr&r&r&r'�
ArraySubclass��rrbrfr)rdrgr)
r"r#�aranger�r�rr�rrr!rrr��rCrr.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@r�)z.TestSolve.test_0_size_k.<locals>.ArraySubclassNrr&r&r&r'r�rrrhrdrfr)rgr)
r"r#rr�r�rr�rrr!rr&r&r'�
test_0_size_k�s""
"8
zTestSolve.test_0_size_kN)
rKrLrMr�r��parametrizerrrrr�rrr&r&r&r'r��s

!r�c@r�)�InvCasescCs0t�|�}tt||�t|��tt||��dSr)r�invrr�r�rr()rCr.r/rB�a_invr&r&r'rFs


�zInvCases.doNr�r&r&r&r'r

r�r
c@�2eZdZej�deeee	g�dd��Z
dd�ZdS)�TestInvr,cCs0tjddgddgg|d�}tt�|�j|�dSr�)r"rrrrr,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@r�)z*TestInv.test_0_size.<locals>.ArraySubclassNrr&r&r&r'rrr�rrdrdr3r_)r"r#�zeros�int_r�rrrr,r �float64rr�r!�	complex64�rCrr.�resr&r&r'rs

zTestInv.test_0_sizeN�rKrLrMr�r�r	rrrrr�rr&r&r&r'rs
rc@r�)�EigvalsCasescCs&t�|�}t�|�\}}t||�dSr)r�eigvals�eigr)rCr.r/rB�ev�evalues�evectorsr&r&r'rF,s
zEigvalsCases.doNr�r&r&r&r'r*r�rc@r
)�TestEigvalsr,cCs`tjddgddgg|d�}tt�|�j|�tjddgddgg|d�}tt�|�jt|��dS�Nrdr�r3r�)r"rrrrr,r6r�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@r�)z.TestEigvals.test_0_size.<locals>.ArraySubclassNrr&r&r&r'r<rrrr3�rrdr_r`)r"r#rrr�rrrr,r rrr�r!rrr&r&r'r:�

zTestEigvals.test_0_sizeNrr&r&r&r'r2s
rc@r�)�EigCasescCsXt�|�\}}tt||�t�|�t�|�dddd�ft|j�d�tt	||��dS)N.��rtol)
rrrr�r"r
r7r,rr()rCr.r/rBrrr&r&r'rFOs
 �zEigCases.doNr�r&r&r&r'r!Mr�r!c@r
)�TestEigr,cCs�tjddgddgg|d�}tj�|�\}}t|j|�t|j|�tjddgddgg|d�}tj�|�\}}t|jt|��t|jt|��dSr)r"rrrrr,r6�rCr,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@r�)z*TestEig.test_0_size.<locals>.ArraySubclassNrr&r&r&r'rfrrrr3rr_r`)r"r#rrr�rrrr,r rrr�r!r�rCrr.r�res_vr&r&r'rd�zTestEig.test_0_sizeNrr&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)Nrdr�r3F��
compute_uvr:)r"rr�svdrr,r4r:)rCr,r��ur��vhr&r&r'r�~szSVDBaseTests.test_typesN)rKrLrMr:r�r�r	rrrrr�r&r&r&r'r+{sr+c@r�)�SVDCasesc	Cspt�|d�\}}}t|tt�|�t�|�dddd�ft�|��t|j�d�tt	||��tt	||��dS)NF.r")
rr.rr�r"r
r7r,rr()rCr.r/rBr/r��vtr&r&r'rF�s&��zSVDCases.doNr�r&r&r&r'r1�r�r1c@r�)�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 )rhrTr,�rhrhr_rh)rrhN)r"r�rr.r:rr��eye)rCr�r/r�r0r&r&r'�test_empty_identity�s

zTestSVD.test_empty_identityN)rKrLrMr6r&r&r&r'r3�sr3c@r�)�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�r:.r"cSs<tt|j��}|d|d|d<|d<t�tj||d��S)Nr�r�)�axes)r�r�r�r"�conj�	transpose)�matr9r&r&r'r:�sz'SVDHermitianCases.do.<locals>.hermitianr�)rr.rr�r"r
r7r,rr	�broadcast_tor5r�r�sortrr()rCr.r/rBr/r�r2r:r&r&r'rF�s&��,,zSVDHermitianCases.doNr�r&r&r&r'r7�r�r7c@seZdZdZdS)�TestSVDHermitianTN)rKrLrMr:r&r&r&r'r?�sr?c@r�)�	CondCasescCs�t|�}d|vrtttj|�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).r�ryrw�r0r1rfr�rdr��fro)r
rrr�condr.rr"rr��sum�max�minr�sqrt)rCr.r/rBr�r��cinvr&r&r'rF�sZ���
&�
&�&�&�
�
�zCondCases.doNr�r&r&r&r'r@�sr@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)rUrrd)rg�r)rrrWrhgUUUUUU�?rdr�r�rBgUUUUU6@)rrrrCrr"rG�rC�Ar&r&r'�test_basic_nonsvd�szTestCond.test_basic_nonsvdcCstt�d�t�d�g}gd�}ddg}t�||�D]\}}tt�||�dk�qt�||�D]
\}}t�||�q-dS)N�rfrf�NrdrfrBr�r��4&�kC)r"r�onesr�r�rrrC)rC�As�p_pos�p_negrK�pr&r&r'�
test_singular�s�zTestCond.test_singularTFz/Platform/LAPACK-dependent failure, see gh-18914��run�reasoncCs�gd�}gd�}t�d�}tj|d<|D]}t�||�}tt|tj��tt�|��qt�d�}tj|d<|D]:}t�||�}tt�|d��||vr^t|dd	k�t|d
d	k�q8tt�|d��tt�|d
��q8dS)N)Nrdr�rfr�rBrNrMr)rgrfrf�rdrrdrdrrOrf)	r"rP�nanrrCrr!�float_�isnan)rC�psrRrKrTr�r&r&r'�test_nans&



�zTestCond.test_nancCs�tj�d�tj�dddd�}d|d<d|d<dD]*}t�||�}t|dtj�t|dtj�tt�	|d��tt�	|d��qdS)	NrTrfrr_r�)NrdrfrBr�r�r�rdr)
r"�random�seed�randrrCrrr�isfinite)rCrKrTr�r&r&r'�test_stacked_singulars�zTestCond.test_stacked_singularN)
rKrLrMrLrUr�r��xfailr^rdr&r&r&r'rI�s	
�
rIc@r�)�	PinvCasescCs<t�|�}t}t||||�|�|ddd�tt||��dS)NryrwrA�r�pinvr�rrr(�rCr.r/rB�a_ginvrr&r&r'rF1s
zPinvCases.doNr�r&r&r&r'rf,srfc@r�)�TestPinvNrr&r&r&r'rk9rrkc@r�)�PinvHermitianCasescCs@tj|dd�}t}t||||�|�|ddd�tt||��dS)NTr8ryrwrArgrir&r&r'rF?szPinvHermitianCases.doNr�r&r&r&r'rl=r�rlc@r�)�TestPinvHermitianNrr&r&r&r'rmGrrmc@r�)�DetCasesc
Cs�t�|�}t�|�\}}t|�jjttfvrt|��t�}nt|��t	�}t�
|�}t|tj
|dd��t|t�|�tj
|dd��t�|�}t�|�}|dk}	tt�||	�d�t||	t�dS)Nr���axisrrd)r�det�slogdetr
r,r rr�astyperrrr
�reducer"�exp�
atleast_1dr�rr)
rCr.r/rB�dr��ld�adr�mr&r&r'rFMs



zDetCases.doNr�r&r&r&r'rnKr�rnc@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�yrrd)rrrqr rrrrrrIr&r&r'�	test_zero`s zTestDet.test_zeror,cCs^tjddgddgg|d�}ttj�|�j|�tj�|�\}}t|jt|��t|j|�dSr�)r"rrrrqr,rrr4)rCr,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)Nr_r3rUr_rrd)r"rrrrqrrr,r rr�float32r)rCr.rr&r&r'rus 







zTestDet.test_0_sizeN)
rKrLrMr}r�r�r	rrrrr�rr&r&r&r'r{_s

r{c@r�)�
LstsqCasescCsLt�|�}|j\}}t�|d�\}}}	tj||dd�\}
}}}
|dkr+t|
dk���||kr=t|t	||
��t
||�nt
||�t|
|
�|��||kr}||kr}t�tt�	||
�|��dj
dd�}t�|�}t�|�jdkr|d|_t
|j|j�n
t�g��t|
��}t||�tt�|jtj��tt|
|��tt||��dS)	NFr���rcondrrfrordr�)r"r
r�rr.�lstsqrr�rrr�__array_wrap__r�rDr�rr�r �
issubdtyper,�floatingr()rCr.r/rB�arrrz�nr/r�r2r��	residuals�rank�sv�
expect_residsr&r&r'rF�s0


 �
�
z
LstsqCases.doNr�r&r&r&r'r��r�r�c@s:eZdZdd�Zej�gd�gd��dd��Zdd�Zd	S)
�	TestLstsqc	Cs�t�gd�gd�gd�gd�g�j}t�gd��}t��K}|�td�}t�||�\}}}}t|dk�tj||dd	�\}}}}t|dk�tj||dd	�\}}}}t|d
k�tt	|�dk�Wd�dS1sjwYdS)N)r|rUr|rUrVr|)r|rVr|r|rUr|)rUr|rUr|r|rX)r|r|r|rVrWr|)rdrrrrrz`rcond` parameter will changerhr�r�rgrd)
r"r�Tr�record�
FutureWarningrr�r�len)	rCr.r/�supr&r�r�r�r�r&r&r'�test_future_rcond�s$
��"�zTestLstsq.test_future_rcond)rzr��n_rhs))rhrfrf)rrhrd)rrhrf)rhrrd)rhrrf)rhrfr)rrrcCs�t�||��||�}t�||f�}tj||dd�\}}}}	|dkr*t|dk���t|j	||f�t|j	||kr<|fnd�||krZ|dkrZ|t�
||�}
t||
|
jdd��t|t
||��t|	j	t
||�f�dS)Nr�rr`r�ro)r"rr�rPrr�rr�rr�rrrDrF)rCrzr�r�r.r/r�r�r�r�r�r&r&r'�test_empty_a_b�s
zTestLstsq.test_empty_a_bcCsvt�gd��}t�gd��}t�|t�t|��g�j}ttd��tj	||dd�Wd�dS1s4wYdS)N)rrdrfrg)r�g�������?g�������?g������@gffffff
@zIncompatible dimensionsr�)
r"r�vstackrPr�r�rrrr�)rCr��yrKr&r&r'�test_incompatible_dims�s"�z TestLstsq.test_incompatible_dimsN)	rKrLrMr�r�r�r	r�r�r&r&r&r'r��s

	r��dtcCsg|]}t�|��qSr&)r"r,)r�r�r&r&r'r��sr�z?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)�TestMatrixPowerrh)rgrrdrf)rfrgrrd)rdrfrgrrdrrfr��g�GcCs�|j�|�}tt|ddddd�|j�tt|ddddd�|j�tt|ddddd�|j�tt|ddddd�|j�dS)Nrf�di� rrdrg)�rshft_1rsrr�rshft_0�rshft_2�rshft_3)rCr��rshftr&r&r'�test_large_power�s����z TestMatrixPower.test_large_powercC�>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_allrs�object�stacked�rCr�r�r<r&r&r'�test_power_is_zero��
��z"TestMatrixPower.test_power_is_zerocCr�)NcSs&t|d�}t||�t|j|j�dS)Nrd)rrr,)r<r�r&r&r'r��s

z-TestMatrixPower.test_power_is_one.<locals>.tzr�r�r&r&r'�test_power_is_one�r�z!TestMatrixPower.test_power_is_onecCr�)NcSs>t|d�}|jtkrtnt}t||||��t|j|j�dS)Nrf)rr,r�r	rr)r<r��mmulr&r&r'r�
s
z-TestMatrixPower.test_power_is_two.<locals>.tzr�r�r&r&r'�test_power_is_two	s
��z!TestMatrixPower.test_power_is_twocCs0dd�}|jD]}||jvr||�|��qdS)NcSs4t|d�}|jtkrtnt}t|||�t|��dS�Nr�)rr,r�r	rrr�)r<�invmatr�r&r&r'r�s

�z3TestMatrixPower.test_power_is_minus_one.<locals>.tz)r��dtnoinvrsr�r&r&r'�test_power_is_minus_ones

��z'TestMatrixPower.test_power_is_minus_onecCs.|j�|�}ttt|d�ttt|dg�dS)Ng�?rd)r�rsr�	TypeErrorr�rCr�r<r&r&r'�test_exceptions_bad_power sz)TestMatrixPower.test_exceptions_bad_powercCsPtttt�dg|�d�tttt�dgdgg|�d�tttt�d|�d�dS)Nrdrf)rhrgrf)rrrr"rrP)rCr�r&r&r'�test_exceptions_non_square%sz*TestMatrixPower.test_exceptions_non_squarecCs,||jvrdS|j�|�}ttt|d�dSr�)r��noninvrsrrrr�r&r&r'�test_exceptions_not_invertible*s
z.TestMatrixPower.test_exceptions_not_invertibleN)rKrLrMr"r5r�r�r�r�r�rr��blockr�r�r,r�r�r�r�r�r�r�r�r�r&r&r&r'r��s"
r�c@r�)�TestEigvalshCasescCs^t�|d�}t�|�\}}|jdd�t||t|j�d�t�|d�}t||t|j�d�dS)N�Lr�ror"�U)r�eigvalshrr>rr7r,)rCr.r/rBrrr�ev2r&r&r'rF4szTestEigvalshCases.doNr�r&r&r&r'r�2r�r�c@�BeZdZej�deeee	g�dd��Z
dd�Zdd�Zdd	�Z
d
S)�TestEigvalshr,cCs:tjddgddgg|d�}tj�|�}t|jt|��dSr�)r"rrr�rr,r4)rCr,r�r&r&r&r'r�AszTestEigvalsh.test_typescC�Xtjddgddggtjd�}tttjj|dd�tttjj|d�tttjj|d�dS�Nrdr�r3�lrong��UPLO�lower�upper)r"rrrr�rr��rCr�r&r&r'�test_invalidG�zTestEigvalsh.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�Nrrdr3r�r"r�r��lr�r/)r"rrr7rr�r)rC�Klo�Kup�tgtr#r&r&r&r'�	test_UPLOMs
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@r�)z/TestEigvalsh.test_0_size.<locals>.ArraySubclassNrr&r&r&r'rerrrr3rr_r`)r"r#rrr�rr�rr,r rrr�r!rrrr&r&r'rcr zTestEigvalsh.test_0_sizeN�rKrLrMr�r�r	rrrrr�r�r�rr&r&r&r'r�@s
r�c@r�)�
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)Nr�ro.r"r�)r#�err_msg)r�eighrr>rrr�r"r
r7r,�repr)
rCr.r/rBr�evcrrr��evc2r&r&r'rFxs

 �

 
�zTestEighCases.doNr�r&r&r&r'r�vr�r�c@r�)�TestEighr,cCsJtjddgddgg|d�}tj�|�\}}t|jt|��t|j|�dSr�)r"rrr�rr,r4r%r&r&r'r��szTestEigh.test_typescCr�r�)r"rrrr�rr�r�r&r&r'r��r�zTestEigh.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�dSr�)r"rrr7rr�r)rCr�r�r�r#r&r'r&r&r'r��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@r�)z+TestEigh.test_0_size.<locals>.ArraySubclassNrr&r&r&r'r�rrrr3rr_r`)r"r#rrr�rr�rr,r rrr�r!rrr(r&r&r'r�r*zTestEigh.test_0_sizeNr�r&r&r&r'r��s
r�c@seZdZdZdZdS)�
_TestNormBaseN)rKrLrMr��decr&r&r&r'r��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�_TestNormGeneralcCsFttg�d�tttg|jd��d�ttttg|jd���d�dS)Nr|r3)rrrr�rrIr&r&r'�
test_empty�s z_TestNormGeneral.test_emptyc		Cs�t�gd��}tjd}tjd}||}|D]�}|�|�}t|tj�}tt|jj	tj
��t|d�t��"}|�
td�t|d�}tt|jj	tj
��t|d�Wd�n1s\wYt|d�}tt|jj	tj
��t|d�t|d	�}tt|jj	tj
��t|d
�t|d�}tt|jj	tj
��t||j�	d
�|j�	d��t|d�}tt|jj	tj
��t||j�	d
�|j�	d
��t|tj�}tt|jj	tj
��t|d�qdS)NrY�
AllInteger�AllFloatr|�divide by zero encounteredr�rrfrdrVr�rhg�?rU)r"r�	typecodesrsrrr�
issubclassr,r r�rr�filter�RuntimeWarning�	rCr.�exact_types�
inexact_types�	all_types�each_inexact_types�at�anr�r&r&r'�test_vector_return_type�s>




�





�z(_TestNormGeneral.test_vector_return_typecsvgd�}gd�}gd�}�fdd�}|||fD]}||�qt|�jd�t|�jd�t|�jd�fD]}||�q2dS)N)rdrfrgrh)r�r�r�r�)r�rfr�rhcs�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+rXrUrd�$@r�g���Q��?rfr�g�s�c���?rrh)r"�testingrrr�r)r'rIr&r'�_tests0�������
�z+_TestNormGeneral.test_vector.<locals>._testr3)rr�)rCr.r/r�r�r'r&rIr'�test_vector�s
�
�z_TestNormGeneral.test_vectorc		s�tgd�gd�g|jd��ddddddtjtjfD]4���fd	d
�t�jd�D�}tt��dd�|���fdd
�t�jd�D�}tt��dd�|�qtjdd
|jd��	ddd���j
}dddddtjtjdfD]h�t�t||�d�D][}|\}}|dkr�||7}|dkr�||7}||kr�t
tt��|d�qyt��|d�}|||�||kr����fdd
�t�j��D�}n���fdd
�t�j��D�}t||�qyqmdS)N�rdrfrg�rhryr)r3r�rrdrfrgcs$g|]}t�dd�|f�d��qS�N��ord�r�r��k�rK�orderr&r'r� �$z._TestNormGeneral.test_axis.<locals>.<listcomp>�r�rpcs$g|]}t�|dd�f�d��qSr�r�r�r�r&r'r�"r��rhr�rBcs*g|]}t�dd�j|�d��d��qS�Nror�)r�taker���B�k_indexr�r&r'r�8s"�cs,g|]}t�dd�j|�d�j�d��qSr)rrr�r�rr&r'r�;s$�)rr�r"�Infr�r�rrrr�r�r��combinationsrr�)	rC�	expected0�	expected1�ndrp�row_axis�col_axisr�rr&)rKrrr�r'�	test_axiss:����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]C}t|j�D];}t|||d	�}t|||d
d�}tt�|�||�||�d�t
|j	�}d||<t|�}t|j	|k|�|j	|||��qTqMdddddtj
tj
ddf	D]O}t�t|j�d�D]C}t|||d	�}t|||d
d�}tt�|�||�||�d�t
|j	�}d||d<d||d<t|�}t|j	|k|�|j	|||��q�q�dS)Nrdrr3rfrgrhzorder {0}, axis = {1}z;Shape mismatch found {0}, expected {1}, order={2}, axis={3}rT)r�rp�keepdims)r�)rdrdrdr�rr�rB�nuc)r"rr�r�rr�squeeze�formatrr�rr�r�r�r�r��permutations)	rCrK�allclose_err�	shape_errr�found�expected_shaper�r�r&r&r'�
test_keepdims?sT
�
�
�

�� 
�

���z_TestNormGeneral.test_keepdimsN)rKrLrMr�r�r�rrr&r&r&r'r��s)%r�c@s:eZdZejZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dS)�_TestNorm2DcCs tt|jgg|jd��d�dS)Nr3r|)rrrr�rIr&r&r'�test_matrix_emptyos z_TestNorm2D.test_matrix_emptyc		Cs�|�gd�gd�g�}tjd}d}||}|D]�}|�|�}t|tj�}tt|jj	tj
��t|d�t��"}|�
td�t|d�}tt|jj	tj
��t|d�Wd�n1s]wYt|d	�}tt|jj	tj
��t|d�t|d
�}tt|jj	tj
��t|d�t|d�}tt|jj	tj
��t|d�t|tj�}tt|jj	tj
��t|d�t|d
�}tt|jj	tj
��t|d�t|d�}tt|jj	tj
��tjj|ddd�qdS)NrYrr��fdFDrVr�r�rUrdrfg�LX�z��?r�rBrgU&,t=�@r)r�)rr"r�rsrrrr�r,r r�rrr�r�r�r�r&r&r'�test_matrix_return_typersD



�









�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)Nrdrgryr�r3g���T"@rBrr�g(@rXr�rZrfg��W�?"@r�gї�ʄ�?�nofror�r)rr�rrrrr�rJr&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)rry)rgrfrdr3grj=Q0�?rBrg�B+pc�?g�������?g333333�?rdrUr�g�������?rfg�&��.d�?r�gܸՠ���?)rr�rrrrJr&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]}ttt||d�ttt||d�ttt||d�qLttjt|dd�ttjt|dd�ttt|dd�dS)Nr�r�r3rdrrfrgrhrBrr�test�rrgr)rdrf�rfrg)rrdrf)	rr�r"rr�rr�r�	AxisError)rCrKrr�r&r&r'�
test_bad_args�sz_TestNorm2D.test_bad_argsN)
rKrLrMr"rrrrrr$r&r&r&r'rjs3rc@r�)�	_TestNormNrr&r&r&r'r%�rr%c@s$eZdZdd�Zdd�Zdd�ZdS)�TestNorm_NonSystematiccCs*tjdtjd�}tt|dd�ddd�dS)N�
r3rgr�g�����L)@rfr�)r"r�
longdoubler-rr�r&r&r'�test_longdouble_norm�sz+TestNorm_NonSystematic.test_longdouble_normcCs,tjdgtjd�}tt|dd�ddd�dS)Ni�r3rgr�lryr�)r"r�int32r-rr�r&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�rfr3y@@ry�@rdg���V;'@rgr�r'r��	ry)	r"r��clongdoubler-rrrs�
complex128r)rCrwrr&r&r'�test_complex_high_ord�sz,TestNorm_NonSystematic.test_complex_high_ordN)rKrLrMr)r+r0r&r&r&r'r&�sr&c@�eZdZejZdZdS)�_TestNormDoubleBaser*N)rKrLrMr"rr�r�r&r&r&r'r2�r2c@r1)�_TestNormSingleBaser)N)rKrLrMr"rr�r�r&r&r&r'r4r3r4c@r1)�_TestNormInt64Baser*N)rKrLrMr"�int64r�r�r&r&r&r'r5r3r5c@r�)�TestNormDoubleNrr&r&r&r'r7rr7c@r�)�TestNormSingleNrr&r&r&r'r8rr8c@r�)�
TestNormInt64Nrr&r&r&r'r9rr9c@r�)�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)Nrhr|�r�r�rgr4r)rdrrrrd)rh)rgrhr)rrr"r5rr)rC�I�msr&r&r'�test_matrix_ranks
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)NrhTr8rdr4rr|r;rgg:�0�yE>g��|"�BE>)r:�tolg�;䡈�E>)rrr"r5rPr)rCr<r&r&r'�test_symmetric_rank3s
z"TestMatrixRank.test_symmetric_rankN)rKrLrMr>r@r&r&r&r'r:sr:cCs�tj�d�}td�D]B}|jdd�}|dd�df|dd�df|dd�df<tt|�d�|dd�d	f|dd�d
f|dd�df<tt|�d�q
dS)
Ni�3r�)�(r')�sizerdrfrr-rhryrgrb)r"r`�RandomStater��normalrr)�rng�i�Xr&r&r'�test_reduced_rankAs,,�rHc@sHeZdZejZdd�Zej�ddggd��dd��Z	dd	�Z
d
d�ZdS)
�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,r�rFr�qrrr!rrr�r:r"r5�triu)rCr.�a_type�a_dtyperzr�r��qr��q1�r1�r2r&r&r'�check_qrRs8

zTestQR.check_qrrzr�))rgrr!r_cCstt||�}t�||f�}|�|�tjj|dd�\}}t|jtj�t|jtj�t|j	||f�t|j	|f�dS)N�rawrK)
rFr"r�rVrrNrr,rr�)rCrzr�r�r.�h�taur&r&r'�
test_qr_emptyys

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)
Nrdrfrgrhryr)r3rWrKr"r,r�)	rr"rrrNrr,r�r�)rCr.rXrYr&r&r'�
test_mode_raw�s"zTestQR.test_mode_rawcCs�|�ddgddgg�}|�ddgddgddgg�}dD]}|�|�}|�|�}|�|�|�|�|�|j�qdD]$}dd|�|�}dd|�|�}|�|�|�|�|�|j�q:dS)	Nrdrfrgrhryr)�fd��?)rrsrVr�)rCr.r/r��m1�m2r&r&r'�test_mode_all_but_economic�s





�z!TestQR.test_mode_all_but_economicN)rKrLrMr"rrVr�r�r	rZr[r`r&r&r&r'rINs'
rIc@r�)�TestCholeskyc	Csgd�}tjtjtjtjf}t�||�D]p\}}tj�d�tjj	|�}t�
|tj�r5|dtjj	|�}tt
t|���}d|dd�<t�|�|���|�}tj||d�}tj�|�}t�||�|����}t|||�d|�d|�d|��d	|jd
t�|�jd�qdS)N)r�rM�rgrg)�2rc)rgr'r'rdr])r�r�r�r3� �
i�r)r��atol)r"rrrr/r�r�r`ra�randnr��complexfloatingr�r�r�r	r;r:r
r�choleskyrr��finfo�eps)	rC�shapes�dtypesr�r,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@r�)z/TestCholesky.test_0_size.<locals>.ArraySubclassNrr&r&r&r'r�rrrr3)rdrr)r"r#rrr�rrirr�rr,r rr!rrr&r&r'r�s

zTestCholesky.test_0_sizeN)rKrLrMrorr&r&r&r'ra�sracCs�tjdkrd}nd}tjtjfD]9}tjd|d�}|�|�}|�d���}t|j	jd�t
jt
jt
j
fD]}||�}t|||��t|||��q4qdS)N�little�<rHrhr3�S�=)�sys�	byteorderr"rrr5�newbyteorder�byteswaprr,rrrqrhr)�native�dttr��n_arr�sw_arr�routinerr&r&r'�test_byteorder_check�s

��r}cCslt�ddgddgg�}t�ddgddgg�}t�gd��ddd�}||d<||d<ttjjtjj|�dS)Nrdrfrgrh)rhrhrfrf.r_)r"rrrrrr)�
invertible�non_invertibler�r&r&r'� test_generalized_raise_multiloop�sr�cCsLd}zt��}Wnttfyt�d�Ynw|dkr�t�d�t�d�ddl}|�|j	d�zt
jj�
�WntyCYntyQt�tj�Ynwzt
�dgg�}t
jj�ddd|d||dd�	Wnty�}zdt|�vr}t�|�WYd}~nd}~wwt�tj�dSt��\}}t�|�|kr�t�d�dSdS)	N�zNot POSIX or fork failed.rrdr_rUzDORGQR parameter number 5zNumpy xerbla not linked in.)�os�fork�OSError�AttributeErrorr��skip�close�resource�	setrlimit�RLIMIT_COREr"r�lapack_lite�xerblar�r��_exit�	EX_CONFIGr�dorgqrr?�wait�WEXITSTATUS)�	XERBLA_OK�pidr�r.r��statusr&r&r'�test_xerbla_overridesF�

��
���r�cCsdddg}t�d�}|D]$}|jdd|d�}t�tjd|g�|jdd|d�}t�tjd|g�qdS)	NzPyQt5.QtWidgets�IPythonz�
    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�r�r�)�textwrap�dedentr�
subprocess�
check_callrt�
executable)�bad_libs�templater��coder&r&r'�test_sdot_bug_85772s

���r�c@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)rf�rfr)�r"r`rrr)rCrKr�Cr&r&r'�(test_basic_function_with_three_argumentsWs
 (z5TestMultiDot.test_basic_function_with_three_argumentscCsNtj�d�}tj�d�}tt||g�|�|��tt||g�t�||��dSr�r�)rCrKrr&r&r'�&test_basic_function_with_two_argumentsasz3TestMultiDot.test_basic_function_with_two_argumentscCs\tj�d�}tj�d�}tj�d�}tj�d�}tt||||g�|�|��|��|��dS)Nr�r��rfrdr�)rCrKrr��Dr&r&r'�8test_basic_function_with_dynamic_programing_optimizationis
,zETestMultiDot.test_basic_function_with_dynamic_programing_optimizationcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nrfr�r�rMr,�r"r`rrr�)rC�A1drr�r�r&r&r'�test_vector_as_first_argumentr�
z*TestMultiDot.test_vector_as_first_argumentcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nr�r�rf)r)r�)rCrKrr��D1dr&r&r'�test_vector_as_last_argument|r�z)TestMultiDot.test_vector_as_last_argumentcCsLtj�d�}tj�d�}tj�d�}tj�d�}tt||||g�jd�dS)Nrfr�r�r&r�)rCr�rr�r�r&r&r'�&test_vector_as_first_and_last_argument�r�z3TestMultiDot.test_vector_as_first_and_last_argumentc	Cs�tj�d�}tj�d�}tj�d�}t�d�}t|||g|d�}||us&J�t||�|��|��t|t�|t�||���dS)Nr�r��r$�r"r`rrrr)rCrKrr�r$�retr&r&r'�test_three_arguments_and_out�s
z)TestMultiDot.test_three_arguments_and_outcCsdtj�d�}tj�d�}t�d�}t||g|d�}||usJ�t||�|��t|t�||��dS)Nr�r�)r)r)r�r�)rCrKrr$r�r&r&r'�test_two_arguments_and_out�s
z'TestMultiDot.test_two_arguments_and_outcCsztj�d�}tj�d�}tj�d�}tj�d�}t�d�}t||||g|d�}||us-J�t||�|��|��|��dS)Nr�r�r�)r)rdr�r�)rCrKrr�r�r$r�r&r&r'�,test_dynamic_programing_optimization_and_out�s
 z9TestMultiDot.test_dynamic_programing_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�ry)ryr')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|)rrdrdrgrgrg)rrrfrgrgrg)rrrrgrgrg)rrrrrhry)rrrrrry)rrrrrrr3rdT)�return_costsr�)r"r`r�intrrrO)rC�arrays�
m_expected�
s_expectedr�rzr&r&r'�test_dynamic_programming_logic�s:





�
�
���z+TestMultiDot.test_dynamic_programming_logiccCs&tttg�ttttj�d�g�dS)Nrb)rr�rr"r`rIr&r&r'�test_too_few_input_arrays�sz&TestMultiDot.test_too_few_input_arraysN)rKrLrMr�r�r�r�r�r�r�r�r�r�r�r&r&r&r'r�Us
	




r�c@sveZdZej�de�d�dfe�d�dfg�dd��Zej�dd	d
g�dd��Z	ej�d
ddg�dd��Z
dd�ZdS)�
TestTensorinvzarr, ind)rhr)rbrfrf)rgrgrfrdcCs<tt��tj||d�Wd�dS1swYdS)N��ind)rrr�	tensorinv)rCr�r�r&r&r'�test_non_square_handling�s
"�z&TestTensorinv.test_non_square_handlingz
shape, ind)�rhr)rbrgrf)��rbrgrdcCsNt�d�}||_tj||d�}|j|d�|jd|�}|j}t||�dS)Nr��r.r�)r"r5r�rr�r)rCr�r�r.�ainvr�actualr&r&r'�test_tensorinv_shape�s
z"TestTensorinv.test_tensorinv_shaper�rr�cCsLt�d�}d|_tt��tj||d�Wd�dS1swYdS)Nr�r�r�)r"r5r�rr�rr�)rCr�r.r&r&r'�test_tensorinv_ind_limit�s


"�z&TestTensorinv.test_tensorinv_ind_limitcCsJt�d�}d|_tj|dd�}t�d�}tt�||d�tj�||��dS)Nr�r�rdr�)	r"r5r�rr�rPr�	tensordot�tensorsolve)rCr.r�r/r&r&r'�test_tensorinv_result�s


"z#TestTensorinv.test_tensorinv_resultN)rKrLrMr�r�r	r"rPr�r�r�r�r&r&r&r'r��s �
�
�
r�cCsTtjddgddggdd�}ttd��t�|�Wd�dS1s#wYdS)Nrdr�rfry�float16r3zunsupported in linalg)r"rrr�rri)r�r&r&r'�test_unsupported_commontype�s"�r�Fz*Numpy not compiled with 64-bit BLAS/LAPACKrVge�
B)�
free_bytescCsRd}tjd|gtjd�}tjddgtjd�}d|d<t�||�}t|dd�dS)N�rdr3)rr�)r"rrrPrr)r�r.r/r�r&r&r'�test_blas64_dotsr�)rXc
	Cs�tj}tjjj}d}d}|}tjddg|d�}tjdg|d�}tjdg|d�}|||||||dd�}t|dd�t|d|�t|d|�t|���}	t	d	|	koZd
k�dS�dS)Nlrdr3r�r�inforzr�r�l)
r"rrr��dgeqrfrrr��itemr)
r,�lapack_routinerzr��ldar.�workrY�results�lworkr&r&r'�!test_blas64_geqrf_lwork_smoketests
&r�)r)r*)|�__doc__r�rtr�r�r�r�r��numpyr"rrrrrrrr	r
rrr
r�numpy.linalgrrrrr�numpy.linalg.linalgr�
numpy.testingrrrrrrrrr�numpy.testing._private.utilsrr(r-r4r6r7rOr>rSr`rar�r�rbr�r�r�r�r�r�r�r�r�r�r�r�r�r�r
rrrr!r$r+r1r3r7r?r@rIrfrkrlrmrnr{r�r�r�r	r�r�r�r�r�r�r�rr%r&r2r4r5r7r8r9r:rHrIrar}r�r�r�r�r�r�r�rer�r�r&r&r&r'�<module>s(,
	�������
�
���#����������������
�
�
�
�
��9��������� 
0


:	
$.C�

*4V6;x$
d,1
")�
	�

https://t.me/RX1948 - 2025