o
    5Bil                     @   sL  d dl mZ d dlZd dlZ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mZmZmZ d dlZd dlmZ d dlZd dlZd dlm  mZ ddgZejdejjefd	d
dd ZG dd dZG dd deZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&G dd dZ'dZ(dZ)dZ*dZ+dZ,d Z-G d!d" d"Z.d#d$ Z/d%d& Z0d'd( Z1dS ))    )mkdtempN)array	transposepi)assert_equalassert_allcloseassert_array_equalassert_array_almost_equal)raises)integerint)unsigned-integeruintmoduleT)scopeparamsautousec                 C   s   | j ja| j ja| j jad S N)parammminfommreadmmwrite)request r   X/var/www/html/Trade-python/venv/lib/python3.10/site-packages/scipy/io/tests/test_mmio.pyimplementations   s   r   c                   @   s  e Zd Zdd Zdd Zdd Zdd Zej	d	e
d
d Zej	d	e
dd Zdd Zdd Zej	d	e
dd Zej	d	e
dd Zej	d	e
dd Zdd Zdd Zdd Zej	d	e
dd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0S )1TestMMIOArrayc                 C      t  | _tj| jd| _d S Nztestfile.mtxr   tmpdirospathjoinfnselfr   r   r   setup_method#      zTestMMIOArray.setup_methodc                 C      t | j d S r   shutilrmtreer    r%   r   r   r   teardown_method'      zTestMMIOArray.teardown_methodc                 C   s4   t | j| tt| j| t| j}t|| d S r   )r   r$   r   r   r   r	   r&   ainfobr   r   r   check*      
zTestMMIOArray.checkc                 C   s4   t | j| tt| j| t| j}t|| d S r   )r   r$   r   r   r   r/   r   r   r   check_exact0   r4   zTestMMIOArray.check_exacttypeval, dtypec              	   C   s0   |  tddgddgg|ddddd|df d S )N            dtyper   generalr5   r   r&   typevalr<   r   r   r   test_simple_integer6      z!TestMMIOArray.test_simple_integerc              	   C   s4   t ddgddgg|d}| |dddd|d	f d S )
Nr;   r8   r:   r   r=   )r   r5   )r&   r@   r<   r0   r   r   r   test_32bit_integer;   s   z TestMMIOArray.test_32bit_integerc                 C   s\   t ddgddggtjd}tdjdk r&ttjjjkr&t	t
t| j| d S | |d d S )	N                        r;   r      r8   r8   r:   r   r   r=   )r   npint64intpitemsizer   scipyio_mmioassert_raisesOverflowErrorr$   r5   r&   r0   r   r   r   test_64bit_integer@   s   z TestMMIOArray.test_64bit_integerc                 C   s*   t ddgddggtjd}| |d d S )NrH   rI           r;   )r8   r8   r:   r   r   r=   )r   rN   uint64r5   rW   r   r   r   test_64bit_unsigned_integerG   s   z)TestMMIOArray.test_64bit_unsigned_integerc              	   C   s0   |  tddgddgg|ddddd|df d S Nr   r7   r;   r8   r:   r   r=   r>   r?   r   r   r   "test_simple_upper_triangle_integerK   rB   z0TestMMIOArray.test_simple_upper_triangle_integerc              	   C   s0   |  tddgddgg|ddddd|df d S r]   r>   r?   r   r   r   "test_simple_lower_triangle_integerP   rB   z0TestMMIOArray.test_simple_lower_triangle_integerc              	   C   s0   |  tg dg dg|ddddd|df d S )	Nr7   r8   r9   r:         r;   r8   r9   rc   r   r=   r>   r?   r   r   r   test_simple_rectangular_integerU   rB   z-TestMMIOArray.test_simple_rectangular_integerc                 C   s"   |  ddgddgddggd d S )Nr7   r8         @r:   rb   rc   )r9   r8   rc   r   realr=   r3   r%   r   r   r   test_simple_rectangular_floatZ      z+TestMMIOArray.test_simple_rectangular_floatc                 C      |  ddgddggd d S )Nr7   r8   r9         @r8   r8   r:   r   rf   r=   rg   r%   r   r   r   test_simple_float^      zTestMMIOArray.test_simple_floatc                 C   rj   )Nr7   r8   r9                 @)r8   r8   r:   r   complexr=   rg   r%   r   r   r   test_simple_complexb   rn   z!TestMMIOArray.test_simple_complexc              	   C   s0   |  tddgddgg|ddddd|df d S )Nr7   r8   r:   r;   r   	symmetricr>   r?   r   r   r   test_simple_symmetric_integerf   rB   z+TestMMIOArray.test_simple_symmetric_integerc                 C   s   |  ddgddggd d S )Nr   r8   )r8   r8   r:   r   r   skew-symmetric)r5   r%   r   r   r   "test_simple_skew_symmetric_integerk   rn   z0TestMMIOArray.test_simple_skew_symmetric_integerc                 C   s"   |  tddgddggdd d S )Nr   r8          g        f)r8   r8   r:   r   rf   ru   )r3   r   r%   r   r   r    test_simple_skew_symmetric_floato   ri   z.TestMMIOArray.test_simple_skew_symmetric_floatc                 C   rj   )Nr7          @      @       @      r:   )r8   r8   r:   r   rp   	hermitianrg   r%   r   r   r   test_simple_hermitian_complexs   rn   z+TestMMIOArray.test_simple_hermitian_complexc                 C   s,   d}t j|}|t| }| |d d S )N   r   )r   r   i  r   rf   rr   )rN   randomr   r3   r&   szr0   r   r   r   test_random_symmetric_floatw      z)TestMMIOArray.test_random_symmetric_floatc                 C   s    d}t j|}| |d d S )Nr      )r   r   ,  r   rf   r=   )rN   r   r3   r   r   r   r   test_random_rectangular_float}   s   z+TestMMIOArray.test_random_rectangular_floatc                 C   Z   d}t |d}tjtdd tjt	| W d    d S 1 s&w   Y  d S )Nz            %%MatrixMarket matrix array real general
              3  3 999
            1.0
            2.0
            3.0
            4.0
            5.0
            6.0
            7.0
            8.0
            9.0
            asciiznot of length 2match
textwrapdedentencodepytestr
   
ValueErrorrR   rS   r   BytesIOr&   stextr   r   r   &test_bad_number_of_array_header_fields   s
   "z4TestMMIOArray.test_bad_number_of_array_header_fieldsc                 C   &   |  tddgddggtjdd d S )Nr7   r8   rt   c   r;   rM   )r5   r   rN   int32r%   r   r   r   #test_gh13634_non_skew_symmetric_int      z1TestMMIOArray.test_gh13634_non_skew_symmetric_intc                 C   r   )Nr7   r8   rt        X@r;   rl   )r3   r   rN   float32r%   r   r   r   %test_gh13634_non_skew_symmetric_float   r   z3TestMMIOArray.test_gh13634_non_skew_symmetric_floatN)__name__
__module____qualname__r'   r-   r3   r5   r   markparametrizeparametrize_argsrA   rG   rX   r\   r^   r_   rd   rh   rm   rq   rs   rv   ry   r}   r   r   r   r   r   r   r   r   r   r   "   s<    





r   c                   @   s  e Zd Zdd Zdd Zdd Zdd Zej	d	e
d
d Zdd Zdd Zdd Zdd Zej	d	e
dd Zej	d	e
dd Zej	d	e
dd Zdd Zdd Zdd Zej	d	e
d d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2S )3TestMMIOSparseCSRc                 C   r   r   r   r%   r   r   r   r'      r(   zTestMMIOSparseCSR.setup_methodc                 C   r)   r   r*   r%   r   r   r   r-      r.   z!TestMMIOSparseCSR.teardown_methodc                 C   s<   t | j| tt| j| t| j}t| |  d S r   )r   r$   r   r   r   r	   toarrayr/   r   r   r   r3         
zTestMMIOSparseCSR.checkc                 C   s<   t | j| tt| j| t| j}t| |  d S r   )r   r$   r   r   r   r   r/   r   r   r   r5      r   zTestMMIOSparseCSR.check_exactr6   c              	   C   s4   |  tjjddgddgg|ddddd|df d S )Nr7   r8   r9   r:   r;   
coordinater=   r5   rR   sparse
csr_matrixr?   r   r   r   rA         z%TestMMIOSparseCSR.test_simple_integerc                 C   2   t jtddgddggtjd}| |d d S )NrC   i  rE   rF   r;   r8   r8   r:   r   r   r=   )rR   r   r   r   rN   r   r5   rW   r   r   r   rG         z$TestMMIOSparseCSR.test_32bit_integerc                 C   sd   t jtddgddggtjd}tdjdk r*tt j	j
jkr*ttt| j| d S | |d d S )N        rJ   r;   r   rL   r   )rR   r   r   r   rN   rO   rP   rQ   r   rS   rT   rU   rV   r$   r5   rW   r   r   r   rX      s   z$TestMMIOSparseCSR.test_64bit_integerc                 C   r   )NrC   rD   rE   rF   r;   r8   r8   r:   r   r   r=   )rR   r   r   r   rN   uint32r5   rW   r   r   r   test_32bit_unsigned_integer   r   z-TestMMIOSparseCSR.test_32bit_unsigned_integerc                 C   s2   t jtddgddggtjd}| |d d S )Nr   rY   rZ   r;   r   )rR   r   r   r   rN   r[   r5   rW   r   r   r   r\      r   z-TestMMIOSparseCSR.test_64bit_unsigned_integerc              	   C   s4   |  tjjddgddgg|ddddd|df d S Nr   r7   r;   r8   r   r=   r   r?   r   r   r   r^      r   z4TestMMIOSparseCSR.test_simple_upper_triangle_integerc              	   C   s4   |  tjjddgddgg|ddddd|df d S r   r   r?   r   r   r   r_      r   z4TestMMIOSparseCSR.test_simple_lower_triangle_integerc              	   C   s4   |  tjjg dg dg|ddddd|df d S )	Nr`   ra   r;   r8   r9   rc   r   r=   r   r?   r   r   r   rd      r   z1TestMMIOSparseCSR.test_simple_rectangular_integerc                 C   s*   |  tjddgddgddggd d S )Nr7   r8   re   r:   rb   rc   )r9   r8   rc   r   rf   r=   r3   rR   r   r   r%   r   r   r   rh          z/TestMMIOSparseCSR.test_simple_rectangular_floatc                 C   $   |  tjddgddggd d S )Nr7   r8   r9   rk   r8   r8   r:   r   rf   r=   r   r%   r   r   r   rm         z#TestMMIOSparseCSR.test_simple_floatc                 C   r   )Nr7   r8   r9   ro   )r8   r8   r:   r   rp   r=   r   r%   r   r   r   rq      r   z%TestMMIOSparseCSR.test_simple_complexc              	   C   s4   |  tjjddgddgg|ddddd|df d S )Nr7   r8   r:   r;   r9   r   rr   r   r?   r   r   r   rs      r   z/TestMMIOSparseCSR.test_simple_symmetric_integerc                 C   s$   |  tjddgddggd d S )Nr   r8   rt   )r8   r8   r7   r   r   ru   r   r%   r   r   r   rv      r   z4TestMMIOSparseCSR.test_simple_skew_symmetric_integerc                 C   s*   |  tjtddgddggdd d S )Nr   r8   rw   rx   )r8   r8   r7   r   rf   ru   )r3   rR   r   r   r   r%   r   r   r   ry      r   z2TestMMIOSparseCSR.test_simple_skew_symmetric_floatc                 C   r   )Nr7   rz   r{   r:   )r8   r8   r9   r   rp   r|   r   r%   r   r   r   r}      r   z/TestMMIOSparseCSR.test_simple_hermitian_complexc                 C   s8   d}t j|}|t| }tj|}| |d d S )Nr~   )r   r      r   rf   rr   )rN   r   r   rR   r   r   r3   r   r   r   r   r      s
   z-TestMMIOSparseCSR.test_random_symmetric_floatc                 C   s,   d}t j|}tj|}| |d d S )Nr   )r   r   r   r   rf   r=   )rN   r   rR   r   r   r3   r   r   r   r   r     r   z/TestMMIOSparseCSR.test_random_rectangular_floatc                 C   sv   t jddgddgg}t| }d|| dk< d}t| j|dd tt	| j| t
| j}t||  d S )	Nr   g      ?g      @g      @r7   )r8   r8   r9   r   patternr=   r   )field)rR   r   r   rN   
zeros_liker   r   r$   r   r   r   r	   )r&   r0   pr1   r2   r   r   r   test_simple_pattern
  s   
z%TestMMIOSparseCSR.test_simple_patternc                 C   .   t jjddgddggtjd}| |d d S )Nr7   r8   rt   r   r;   r   )rR   r   r   rN   r   r5   rW   r   r   r   r        z5TestMMIOSparseCSR.test_gh13634_non_skew_symmetric_intc                 C   r   )Nr7   r8   rt   r   r;   r   )rR   r   r   rN   r   r3   rW   r   r   r   r     r   z7TestMMIOSparseCSR.test_gh13634_non_skew_symmetric_floatN)r   r   r   r'   r-   r3   r5   r   r   r   r   rA   rG   rX   r   r\   r^   r_   rd   rh   rm   rq   rs   rv   ry   r}   r   r   r   r   r   r   r   r   r   r      s<    
	




r   z]%%MatrixMarket matrix array integer general
2  2
2147483647
2147483646
2147483647
2147483646
z]%%MatrixMarket matrix coordinate integer symmetric
2  2  2
1  1  2147483647
2  2  2147483646
z%%MatrixMarket matrix array integer general
2  2
          2147483648
-9223372036854775806
         -2147483648
 9223372036854775807
z%%MatrixMarket matrix coordinate integer general
2  2  3
1  1           2147483648
1  2  9223372036854775807
2  2  9223372036854775807
z%%MatrixMarket matrix coordinate integer symmetric
2  2  3
1  1            2147483648
1  2  -9223372036854775807
2  2   9223372036854775807
z%%MatrixMarket matrix coordinate integer skew-symmetric
2  2  3
1  1            2147483648
1  2  -9223372036854775807
2  2   9223372036854775807
z%%MatrixMarket matrix array integer general
2  2
         2147483648
9223372036854775807
         2147483648
9223372036854775808
zq%%MatrixMarket matrix coordinate integer symmetric
2  2  2
1  1            2147483648
2  2  19223372036854775808
c                   @   sd   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd ZdS )TestMMIOReadLargeIntegersc                 C   r   r   r   r%   r   r   r   r'   `  r(   z&TestMMIOReadLargeIntegers.setup_methodc                 C   r)   r   r*   r%   r   r   r   r-   d  r.   z)TestMMIOReadLargeIntegers.teardown_methodc           	      C   s   t | jd}|| W d    n1 sw   Y  tt| j| |r4tdjdk r4tt	j
jjks6|r?ttt| j d S t| j}|sJ| }t|| d S )Nwr   rL   )openr$   writer   r   rN   rP   rQ   r   rR   rS   rT   rU   rV   r   r   )	r&   exampler0   r1   denseover32over64rx   r2   r   r   r   
check_readg  s   "
z$TestMMIOReadLargeIntegers.check_readc                 C   s4   t ddgddggtjd}| jt|ddddd d S )NrC   rD   r;   rM   TFr   r   r   )r   rN   rO   r   _32bit_integer_dense_examplerW   r   r   r   test_read_32bit_integer_denset     
z7TestMMIOReadLargeIntegers.test_read_32bit_integer_densec                 C   s4   t ddgddggtjd}| jt|ddddd d S )NrC   r   rD   r;   r8   r8   r8   r   r   rr   Fr   )r   rN   rO   r   _32bit_integer_sparse_examplerW   r   r   r   test_read_32bit_integer_sparse~  r   z8TestMMIOReadLargeIntegers.test_read_32bit_integer_sparsec                 C   s4   t ddgddggtjd}| jt|ddddd	 d S )
NrH   i   r   rK   r;   rM   TFr   )r   rN   rO   r   _64bit_integer_dense_examplerW   r   r   r   test_read_64bit_integer_dense  r   z7TestMMIOReadLargeIntegers.test_read_64bit_integer_densec                 C   s4   t ddgddggtjd}| jt|ddddd d S )	NrH   rK   r   r;   )r8   r8   r9   r   r   r=   FTr   )r   rN   rO   r   %_64bit_integer_sparse_general_examplerW   r   r   r   &test_read_64bit_integer_sparse_general  r   z@TestMMIOReadLargeIntegers.test_read_64bit_integer_sparse_generalc                 C   s4   t ddgddggtjd}| jt|ddddd d S )	NrH    rK   r;   )r8   r8   r9   r   r   rr   FTr   )r   rN   rO   r   '_64bit_integer_sparse_symmetric_examplerW   r   r   r   (test_read_64bit_integer_sparse_symmetric  r   zBTestMMIOReadLargeIntegers.test_read_64bit_integer_sparse_symmetricc                 C   s4   t ddgddggtjd}| jt|ddddd d S )	NrH   r   rK   r;   )r8   r8   r9   r   r   ru   FTr   )r   rN   rO   r   "_64bit_integer_sparse_skew_examplerW   r   r   r   #test_read_64bit_integer_sparse_skew  r   z=TestMMIOReadLargeIntegers.test_read_64bit_integer_sparse_skewc                 C   s   | j td ddddd d S )NrM   Tr   )r    _over64bit_integer_dense_exampler%   r   r   r   !test_read_over64bit_integer_dense     
z;TestMMIOReadLargeIntegers.test_read_over64bit_integer_densec                 C   s   | j td ddddd d S )Nr   FTr   )r   !_over64bit_integer_sparse_exampler%   r   r   r   "test_read_over64bit_integer_sparse  r   z<TestMMIOReadLargeIntegers.test_read_over64bit_integer_sparseN)r   r   r   r'   r-   r   r   r   r   r   r   r   r   r   r   r   r   r   r   _  s    





r   a&  %%MatrixMarket matrix coordinate real general
%=================================================================================
%
% This ASCII file represents a sparse MxN matrix with L
% nonzeros in the following Matrix Market format:
%
% +----------------------------------------------+
% |%%MatrixMarket matrix coordinate real general | <--- header line
% |%                                             | <--+
% |% comments                                    |    |-- 0 or more comment lines
% |%                                             | <--+
% |    M  N  L                                   | <--- rows, columns, entries
% |    I1  J1  A(I1, J1)                         | <--+
% |    I2  J2  A(I2, J2)                         |    |
% |    I3  J3  A(I3, J3)                         |    |-- L lines
% |        . . .                                 |    |
% |    IL JL  A(IL, JL)                          | <--+
% +----------------------------------------------+
%
% Indices are 1-based, i.e. A(1,1) is the first element.
%
%=================================================================================
  5  5  8
    1     1   1.000e+00
    2     2   1.050e+01
    3     3   1.500e-02
    1     4   6.000e+00
    4     2   2.505e+02
    4     4  -2.800e+02
    4     5   3.332e+01
    5     5   1.200e+01
a   %%MatrixMarket matrix coordinate complex hermitian
  5  5  7
    1     1     1.0      0
    2     2    10.5      0
    4     2   250.5     22.22
    3     3     1.5e-2   0
    4     4    -2.8e2    0
    5     5    12.       0
    5     4     0       33.32
z%%MatrixMarket matrix coordinate real skew-symmetric
  5  5  7
    1     1     1.0
    2     2    10.5
    4     2   250.5
    3     3     1.5e-2
    4     4    -2.8e2
    5     5    12.
    5     4     0
z%%MatrixMarket matrix coordinate real symmetric
  5  5  7
    1     1     1.0
    2     2    10.5
    4     2   250.5
    3     3     1.5e-2
    4     4    -2.8e2
    5     5    12.
    5     4     8
z%%MatrixMarket matrix coordinate pattern symmetric
  5  5  7
    1     1
    2     2
    4     2
    3     3
    4     4
    5     5
    5     4
a  %%MatrixMarket  MATRIX    Coordinate    Real General

   5  5         8

1 1  1.0
2 2       10.5
3 3             1.5e-2
4 4                     -2.8E2
5 5                              12.
     1      4      6
     4      2      250.5
     4      5      33.32

c                   @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#S )$TestMMIOCoordinatec                 C   r   r   r   r%   r   r   r   r'   '  r(   zTestMMIOCoordinate.setup_methodc                 C   r)   r   r*   r%   r   r   r   r-   +  r.   z"TestMMIOCoordinate.teardown_methodc                 C   sJ   t | jd}|| |  tt| j| t| j }t|| d S )Nr   )	r   r$   r   closer   r   r   r   r	   )r&   r   r0   r1   rx   r2   r   r   r   r   .  s   
zTestMMIOCoordinate.check_readc                 C   4   g dg dg dg dg dg}|  t|d d S N)r7   r   r   rc   r   )r         %@r   r   r   r   r   Q?r   r   )r        Po@r   )\@@r   r   r   r      rb   rb   rL   r   rf   r=   )r   _general_examplerW   r   r   r   test_read_general6     z$TestMMIOCoordinate.test_read_generalc                 C   r   )Nr7   r   r   r   r   )r   r   r   y     Po@Q86r   r   )r   y     Po@Q86@r   r   y       )\@)r   r   r   y        )\@@r   )rb   rb      r   rp   r|   )r   _hermitian_examplerW   r   r   r   test_read_hermitian?  r   z&TestMMIOCoordinate.test_read_hermitianc                 C   r   )Nr   )r   r   r   g     Por   r   )r   r   r   r   r   r   )rb   rb   r   r   rf   ru   )r   _skew_examplerW   r   r   r   test_read_skewH  r   z!TestMMIOCoordinate.test_read_skewc                 C   r   )Nr   )r   r   r   r   r   r   )r   r   r   r   rL   )r   r   r   rL   r   )rb   rb   r   r   rf   rr   )r   _symmetric_examplerW   r   r   r   test_read_symmetricQ  r   z&TestMMIOCoordinate.test_read_symmetricc                 C   r   )Nr   )r   r7   r   r7   r   )r   r   r7   r   r   )r   r7   r   r7   r7   )r   r   r   r7   r7   )rb   rb   r   r   r   rr   )r   _symmetric_pattern_examplerW   r   r   r   test_read_symmetric_patternZ  r   z.TestMMIOCoordinate.test_read_symmetric_patternc                 C   r   r   )r   _empty_lines_examplerW   r   r   r   test_read_empty_linesc  r   z(TestMMIOCoordinate.test_read_empty_linesc                 C   sL   t jd}t| j| tt| jd | }t| j }t	|| d S )N)
   r   )r   r   r   r   rf   rr   )
rR   r   
coo_matrixr   r$   r   r   r   r   r	   )r&   r2   r0   r   r   r   test_empty_write_readl  s   
z(TestMMIOCoordinate.test_empty_write_readc           
      C   s   zdd l }W n
 ty   Y d S w tg d}tg d}tg d}tjj|||ffdd}t| j| d| j }t| jd}|	|d	}|
|  |  W d    n1 s\w   Y  t| }	t|	|  d S )
Nr   r   r   r7   r8   r9   r9   r9   r:   r   r9   r7   r8   r7   r9   r:   r:   g      ?g      @r   r   r   g     qr   g      (@rb   rb   shapez%s.bz2rbwb)bz2ImportErrorr   rR   r   r   r   r$   r   BZ2Filer   readr   r   r   r	   )
r&   r	  IJVr2   fn_bzip2f_inf_outr0   r   r   r   test_bzip2_py3x  $   

z!TestMMIOCoordinate.test_bzip2_py3c           
      C   s   zdd l }W n
 ty   Y d S w tg d}tg d}tg d}tjj|||ffdd}t| j| d| j }t| jd}||d	}|	|
  |  W d    n1 s\w   Y  t| }	t|	|  d S )
Nr   r  r  r  r  r  z%s.gzr  r  )gzipr
  r   rR   r   r   r   r$   r   r   r  r   r   r   r	   )
r&   r  r  r  r  r2   fn_gzipr  r  r0   r   r   r   test_gzip_py3  r  z TestMMIOCoordinate.test_gzip_py3c                 C   |   t g d}t g d}t g d}tjj|||ffdd}t| j| tt| jd | }t	| j }t
|| d S )Nr  r  r  r  r  r   r   rR   r   r   r   r$   r   r   r   r   r	   r&   r  r  r  r2   r0   r   r   r   test_real_write_read  s   
z'TestMMIOCoordinate.test_real_write_readc                 C   r  )Nr  r  y      ?      @y      @       @y      %@?yQ?y     Po@        y     q      @y)\@@@y      (@?r  r  )rb   rb   rL   r   rp   r=   r  r  r   r   r   test_complex_write_read  s   
z*TestMMIOCoordinate.test_complex_write_readc                 C   s   |d }|   g }tg d}tg d}tg d}|tjj|||ffdd tg d}|tjj|||ffdd |D ]$}| }dD ]}	||	d	  }
t|
||	 t	|
 }t
|| qJqBd S )
Nsparse_formatsr  r  r  r  r  r  )csrcsccooz.mtx)mkdirr   appendrR   r   r   r   r   asformatr   r	   )r&   tmp_pathr    matsr  r  r  matexpectedfmtfnameresultr   r   r   test_sparse_formats  s$   z&TestMMIOCoordinate.test_sparse_formatsc                 C   s   t gdd tdddD  }tdd}|D ]M}|D ]H}d| d }tj||f}|||d |d f< t| j||d tj| j}t	|j
|d g t	|j|d g t|jtd	| | g qqd S )
Nc                 S   s   g | ]}d | qS )r   r   ).0ir   r   r   
<listcomp>  s    z5TestMMIOCoordinate.test_precision.<locals>.<listcomp>r   ir7   r   )	precisionz%%.%dg)r   rangerR   r   
dok_matrixr   r$   rS   r   r   rowcolr   datafloat)r&   test_valuestest_precisionsvaluer1  nAr   r   r   test_precision  s   
z!TestMMIOCoordinate.test_precisionc                 C   r   )Na              %%MatrixMarket matrix coordinate real general
              5  5  8 999
                1     1   1.000e+00
                2     2   1.050e+01
                3     3   1.500e-02
                1     4   6.000e+00
                4     2   2.505e+02
                4     4  -2.800e+02
                4     5   3.332e+01
                5     5   1.200e+01
            r   znot of length 3r   r   r   r   r   r   +test_bad_number_of_coordinate_header_fields  s
   "z>TestMMIOCoordinate.test_bad_number_of_coordinate_header_fieldsN)r   r   r   r'   r-   r   r   r   r   r   r   r   r   r  r  r  r  r,  r=  r>  r   r   r   r   r   &  s$    						r   c                   C   s   t td d S )Nzg%%MatrixMarket matrix coordinate complex symmetric
 1 1 1
1 1 -2.1846000000000e+02  0.0000000000000e+00)r   rS   StringIOr   r   r   r   test_gh11389  s   r@  c                 C   sP   g d}| d }t |d}|| W d    n1 sw   Y  t| d S )N)z/ %%MatrixMarket matrix coordinate real general
z5 5 3
z2 3 1.0
z3 4 2.0
z3 5 3.0
ztest.mtxr   )r   
writelinesr   )r%  lines	test_filerx   r   r   r   test_gh18123  s   rD  c                  C   s   zdd l } t| dstd W d S W n ty"   td Y d S w | jdd ttjd W d    n1 s:w   Y  | jddd	 ttjd W d    d S 1 sXw   Y  d S )
Nr   registerzthreadpoolctl too oldzno threadpoolctlr:   )limitsr8   rR   )rF  user_api)	threadpoolctlhasattrr   skipr
  threadpool_limitsr   fmmPARALLELISM)rH  r   r   r   test_threadpoolctl  s    


"rN  )2tempfiler   r!   rS   r+   r   numpyrN   r   r   r   numpy.testingr   r   r   r	   r   r
   rU   scipy.sparserR   scipy.io._mmioscipy.io._fast_matrix_market_fast_matrix_marketrL  r   fixturerT   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r@  rD  rN  r   r   r   r   <module>   sR    
	{ 			b" ]