ó
Ë½÷Xc           @` sˆ  d  d l  m Z m Z m Z d  d l m Z m 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 m Z m Z d  d l Z d  d l m Z m Z m Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d Z d Z d Z d Z  d Z! d Z" d Z# d Z$ d e f d „  ƒ  YZ% d Z& d Z' d Z( d Z) d Z* d e f d „  ƒ  YZ+ e, d k r„e ƒ  n  d S(   i    (   t   divisiont   print_functiont   absolute_import(   t   mkdtempt   mktempN(   t   arrayt	   transposet   pi(   t   TestCaset   run_module_suitet   assert_equalt   assert_array_equalt   assert_array_almost_equalt   assert_raises(   t   mminfot   mmreadt   mmwritet   TestMMIOArrayc           B` s³   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C` s+   t  ƒ  |  _ t j j |  j d ƒ |  _ d  S(   Ns   testfile.mtx(   R   t   tmpdirt   ost   patht   joint   fn(   t   self(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   setUp   s    c         C` s   t  j |  j ƒ d  S(   N(   t   shutilt   rmtreeR   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   tearDown   s    c         C` sF   t  |  j | ƒ t t |  j ƒ | ƒ t |  j ƒ } t | | ƒ d  S(   N(   R   R   R
   R   R   R   (   R   t   at   infot   b(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   check   s    c         C` sF   t  |  j | ƒ t t |  j ƒ | ƒ t |  j ƒ } t | | ƒ d  S(   N(   R   R   R
   R   R   (   R   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   check_exact   s    c         C` s&   |  j  d d g d d g g d ƒ d  S(	   Ni   i   i   i   R   t   integert   general(   i   i   i   s   arrays   integerR"   (   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_integer%   s    c         C` s;   t  d d g d d g g d t j ƒ} |  j | d ƒ d  S(   Ni   i   i   i   i   t   dtypeR   R!   R"   I   €    iÿÿÿI   €    iþÿÿI   €    iýÿÿI   €    iüÿÿ(   i   i   i   s   arrays   integers   general(   R   t   npt   int32R    (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_32bit_integer)   s    'c         C` sl   t  d d g d d g g d t j ƒ} t j d ƒ j d k  rX t t t |  j | ƒ n |  j	 | d ƒ d  S(   Ni   i   i    i?   i   R$   i    i   i   R   R!   R"   I   €    I       l            l   þÿÿÿ l            l   ÿÿÿÿ (   i   i   i   s   arrays   integers   general(
   R   R%   t   int64t   intpt   itemsizeR   t   OverflowErrorR   R   R    (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_64bit_integer-   s    'c         C` s&   |  j  d d g d d g g d ƒ d  S(	   Ni    i   i   i   R   R!   R"   (   i   i   i   s   arrays   integers   general(   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt"   test_simple_upper_triangle_integer4   s    c         C` s&   |  j  d d g d d g g d ƒ d  S(	   Ni    i   i   i   R   R!   R"   (   i   i   i   s   arrays   integers   general(   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt"   test_simple_lower_triangle_integer8   s    c         C` s,   |  j  d d d g d d d g g d
 ƒ d  S(   Ni   i   i   i   i   i   R   R!   R"   (   i   i   i   s   arrays   integers   general(   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_rectangular_integer<   s    !c         C` s/   |  j  d d g d d g d d g g d ƒ d  S(   Ni   i   g      @i   i   i   i   R   t   realR"   (   i   i   i   s   arrays   reals   general(   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_rectangular_float@   s    $c         C` s&   |  j  d d g d d g g d	 ƒ d  S(
   Ni   i   i   g      @i   R   R0   R"   (   i   i   i   s   arrays   reals   general(   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_floatD   s    c         C` s&   |  j  d d g d d g g d	 ƒ d  S(
   Ni   i   i   y              @i   R   t   complexR"   (   i   i   i   s   arrays   complexs   general(   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_complexH   s    c         C` s&   |  j  d d g d d g g d ƒ d  S(   Ni   i   i   R   R!   t	   symmetric(   i   i   i   s   arrays   integerR5   (   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_symmetric_integerL   s    c         C` s&   |  j  d d g d d g g d ƒ d  S(	   Ni   i   iþÿÿÿi   R   R!   s   skew-symmetric(   i   i   i   s   arrays   integers   skew-symmetric(   R    (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt"   test_simple_skew_symmetric_integerP   s    c         C` s/   |  j  t d d g d d g g d ƒ d	 ƒ d  S(
   Ni   i   g       Ài   t   fR   R0   s   skew-symmetric(   i   i   i   s   arrays   reals   skew-symmetric(   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt    test_simple_skew_symmetric_floatT   s    $c         C` s&   |  j  d d g d	 d g g d
 ƒ d  S(   Ni   i   y              @i   R   R3   t	   hermitiany       @      @y       @      À(   i   i   i   s   arrays   complexR:   (   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_hermitian_complexX   s    c         C` s<   d } t  j j | ƒ } | t | ƒ } |  j | d ƒ d  S(   Ni   i  R   R0   R5   (   i   i   (   i   i   i  s   arrays   reals	   symmetric(   R%   t   randomR   R   (   R   t   szR   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_random_symmetric_float\   s    c         C` s,   d } t  j j | ƒ } |  j | d ƒ d  S(	   Ni   i   i,  R   R0   R"   (   i   i   (   i   i   i,  s   arrays   reals   general(   R%   R<   R   (   R   R=   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_random_rectangular_floatb   s    (   t   __name__t
   __module__R   R   R   R    R#   R'   R,   R-   R.   R/   R1   R2   R4   R6   R7   R9   R;   R>   R?   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR      s&   																		t   TestMMIOSparseCSRc           B` s¼   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C` s+   t  ƒ  |  _ t j j |  j d ƒ |  _ d  S(   Ns   testfile.mtx(   R   R   R   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR   i   s    c         C` s   t  j |  j ƒ d  S(   N(   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR   m   s    c         C` sR   t  |  j | ƒ t t |  j ƒ | ƒ t |  j ƒ } t | j ƒ  | j ƒ  ƒ d  S(   N(   R   R   R
   R   R   R   t   todense(   R   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR   p   s    c         C` sR   t  |  j | ƒ t t |  j ƒ | ƒ t |  j ƒ } t | j ƒ  | j ƒ  ƒ d  S(   N(   R   R   R
   R   R   RC   (   R   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR    v   s    c         C` s2   |  j  t j j d d g d d g g ƒ d ƒ d  S(	   Ni   i   i   i   t
   coordinateR!   R"   (   i   i   i   RD   s   integers   general(   R    t   scipyt   sparset
   csr_matrix(   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR#   |   s    'c         C` sG   t  j j t d d g d d g g d t j ƒƒ } |  j | d ƒ d  S(   Ni   i   i   i   i   R$   RD   R!   R"   I   €    iÿÿÿI   €    i   €i  €I   €    iýÿÿI   €    iüÿÿ(   i   i   i   s
   coordinates   integers   general(   RE   RF   RG   R   R%   R&   R    (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR'   €   s    c         C` sx   t  j j t d d g d d g g d t j ƒƒ } t j d ƒ j d k  rd t t	 t
 |  j | ƒ n |  j | d ƒ d  S(   Ni   i    i   i?   R$   i    i   i   RD   R!   R"   I       I      I       I      l            lûÿÿÿ         lûÿÿÿþÿÿÿ l            l   þÿÿÿ (   i   i   i   s
   coordinates   integers   general(   RE   RF   RG   R   R%   R(   R)   R*   R   R+   R   R   R    (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR,   †   s    c         C` s2   |  j  t j j d d g d d g g ƒ d ƒ d  S(   Ni    i   i   RD   R!   R"   (   i   i   i   s
   coordinates   integers   general(   R    RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR-      s    'c         C` s2   |  j  t j j d d g d d g g ƒ d ƒ d  S(   Ni    i   i   RD   R!   R"   (   i   i   i   s
   coordinates   integers   general(   R    RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR.   “   s    'c         C` s8   |  j  t j j d d d g d d d g g ƒ d
 ƒ d  S(   Ni   i   i   i   i   i   RD   R!   R"   (   i   i   i   s
   coordinates   integers   general(   R    RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR/   —   s    -c         C` s;   |  j  t j j d d g d d g d d g g ƒ d ƒ d  S(   Ni   i   g      @i   i   i   i   RD   R0   R"   (   i   i   i   s
   coordinates   reals   general(   R   RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR1   ›   s    0c         C` s2   |  j  t j j d d g d d g g ƒ d	 ƒ d  S(
   Ni   i   i   g      @i   RD   R0   R"   (   i   i   i   s
   coordinates   reals   general(   R   RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR2   Ÿ   s    'c         C` s2   |  j  t j j d d g d d g g ƒ d	 ƒ d  S(
   Ni   i   i   y              @i   RD   R3   R"   (   i   i   i   s
   coordinates   complexs   general(   R   RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR4   £   s    'c         C` s2   |  j  t j j d d g d d g g ƒ d ƒ d  S(	   Ni   i   i   i   RD   R!   R5   (   i   i   i   s
   coordinates   integers	   symmetric(   R    RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR6   §   s    'c         C` s2   |  j  t j j d d g d d g g ƒ d	 ƒ d  S(
   Ni   i   iþÿÿÿi   i   RD   R!   s   skew-symmetric(   i   i   i   s
   coordinates   integers   skew-symmetric(   R    RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR7   «   s    'c         C` s;   |  j  t j j t d d g d d g g d ƒ ƒ d
 ƒ d  S(   Ni   i   g       Ài   R8   i   RD   R0   s   skew-symmetric(   i   i   i   s
   coordinates   reals   skew-symmetric(   R   RE   RF   RG   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR9   ¯   s    0c         C` s2   |  j  t j j d d	 g d
 d g g ƒ d ƒ d  S(   Ni   i   y              @i   i   RD   R3   R:   y       @      @y       @      À(   i   i   i   s
   coordinates   complexs	   hermitian(   R   RE   RF   RG   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR;   ³   s    'c         C` sN   d } t  j j | ƒ } | t | ƒ } t j j | ƒ } |  j | d ƒ d  S(   Ni   iÒ   RD   R0   R5   (   i   i   (   i   i   iÒ   s
   coordinates   reals	   symmetric(   R%   R<   R   RE   RF   RG   R   (   R   R=   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR>   ·   s
    c         C` s>   d } t  j j | ƒ } t j j | ƒ } |  j | d ƒ d  S(	   Ni   i   i,  RD   R0   R"   (   i   i   (   i   i   i,  s
   coordinates   reals   general(   R%   R<   RE   RF   RG   R   (   R   R=   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR?   ¾   s    c         C` s§   t  j j d d g d d g g ƒ } t j | j ƒ  ƒ } d | | j ƒ  d k <d } t |  j | d d	 ƒt t	 |  j ƒ | ƒ t
 |  j ƒ } t | | j ƒ  ƒ d  S(   Ni    g      ø?g      @g      @i   i   i   RD   t   patternR"   t   field(   i   i   i   s
   coordinates   patterns   general(   RE   RF   RG   R%   t
   zeros_likeRC   R   R   R
   R   R   R   (   R   R   t   pR   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_simple_patternÄ   s    $(   R@   RA   R   R   R   R    R#   R'   R,   R-   R.   R/   R1   R2   R4   R6   R7   R9   R;   R>   R?   RL   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyRB   h   s(   																				s]   %%MatrixMarket matrix array integer general
2  2
2147483647
2147483646
2147483647
2147483646
s]   %%MatrixMarket matrix coordinate integer symmetric
2  2  2
1  1  2147483647
2  2  2147483646
s…   %%MatrixMarket matrix array integer general
2  2
          2147483648
-9223372036854775806
         -2147483648
 9223372036854775807
s‡   %%MatrixMarket matrix coordinate integer general
2  2  3
1  1           2147483648
1  2  9223372036854775807
2  2  9223372036854775807
sŒ   %%MatrixMarket matrix coordinate integer symmetric
2  2  3
1  1            2147483648
1  2  -9223372036854775807
2  2   9223372036854775807
s‘   %%MatrixMarket matrix coordinate integer skew-symmetric
2  2  3
1  1            2147483648
1  2  -9223372036854775807
2  2   9223372036854775807
s   %%MatrixMarket matrix array integer general
2  2
         2147483648
9223372036854775807
         2147483648
9223372036854775808
sq   %%MatrixMarket matrix coordinate integer symmetric
2  2  2
1  1            2147483648
2  2  19223372036854775808
t   TestMMIOReadLargeIntegersc           B` sk   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   c         C` s+   t  ƒ  |  _ t j j |  j d ƒ |  _ d  S(   Ns   testfile.mtx(   R   R   R   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR     s    c         C` s   t  j |  j ƒ d  S(   N(   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR     s    c   	      C` s­   t  |  j d ƒ  } | j | ƒ Wd  QXt t |  j ƒ | ƒ | r\ t j d ƒ j d k  sb | rx t t	 t
 |  j ƒ n1 t
 |  j ƒ } | sœ | j ƒ  } n  t | | ƒ d  S(   Nt   wi    i   (   t   openR   t   writeR
   R   R%   R)   R*   R   R+   R   RC   (	   R   t   exampleR   R   t   denset   over32t   over64R8   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt
   check_read  s    $c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d	 t d
 t d t ƒd  S(   Ni   i   i   R$   i   R   R!   R"   RR   RS   RT   I   €    iÿÿÿI   €    iÿÿÿI   €    iþÿÿI   €    iþÿÿ(   i   i   i   s   arrays   integers   general(   R   R%   R(   RU   t   _32bit_integer_dense_examplet   Truet   False(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_32bit_integer_dense$  s    	c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d	 t d
 t d t ƒd  S(   Ni   i   i   i    R$   RD   R!   R5   RR   RS   RT   I   €    iÿÿÿI   €    iþÿÿ(   i   i   i   s
   coordinates   integers	   symmetric(   R   R%   R(   RU   t   _32bit_integer_sparse_exampleRX   (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_32bit_integer_sparse.  s    	c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d
 t d t d t ƒd  S(   Ni   i   i?   i   R$   i   R   R!   R"   RR   RS   RT   I   €    I   €    i   €l            lûÿÿÿ         lûÿÿÿþÿÿÿ l            l   ÿÿÿÿ (   i   i   i   s   arrays   integers   general(   R   R%   R(   RU   t   _64bit_integer_dense_exampleRW   RX   (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_64bit_integer_dense8  s    	c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d t d t d t ƒd  S(   Ni   i   i?   i   i    R$   i   RD   R!   R"   RR   RS   RT   I   €    l            l   ÿÿÿÿ l            l   ÿÿÿÿ (   i   i   i   s
   coordinates   integers   general(   R   R%   R(   RU   t%   _64bit_integer_sparse_general_exampleRX   RW   (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt&   test_read_64bit_integer_sparse_generalB  s    	c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d
 t d t d t ƒd  S(   Ni   i   i?   i   R$   i   RD   R!   R5   RR   RS   RT   I   €    l            lûÿÿÿ         lûÿÿÿÿÿÿÿ l            lûÿÿÿ         lûÿÿÿÿÿÿÿ l            l   ÿÿÿÿ (   i   i   i   s
   coordinates   integers	   symmetric(   R   R%   R(   RU   t'   _64bit_integer_sparse_symmetric_exampleRX   RW   (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt(   test_read_64bit_integer_sparse_symmetricL  s    	c      
   C` sP   t  d d g d d g g d t j ƒ} |  j t | d d
 t d t d t ƒd  S(   Ni   i   i?   i   R$   i   RD   R!   s   skew-symmetricRR   RS   RT   I   €    l            lûÿÿÿ         lûÿÿÿÿÿÿÿ l            l   ÿÿÿÿ l            l   ÿÿÿÿ (   i   i   i   s
   coordinates   integers   skew-symmetric(   R   R%   R(   RU   t"   _64bit_integer_sparse_skew_exampleRX   RW   (   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt#   test_read_64bit_integer_sparse_skewV  s    	c      
   C` s)   |  j  t d  d	 d t d t d t ƒd  S(
   Ni   i   R   R!   R"   RR   RS   RT   (   i   i   i   s   arrays   integers   general(   RU   t    _over64bit_integer_dense_examplet   NoneRW   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt!   test_read_over64bit_integer_dense`  s    	c      
   C` s)   |  j  t d  d d t d t d t ƒd  S(	   Ni   RD   R!   R5   RR   RS   RT   (   i   i   i   s
   coordinates   integers	   symmetric(   RU   t!   _over64bit_integer_sparse_exampleRe   RX   RW   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt"   test_read_over64bit_integer_sparseh  s    	(   R@   RA   R   R   RU   RY   R[   R]   R_   Ra   Rc   Rf   Rh   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyRM     s   				
	
	
	
	
	
	s&  %%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
s   %%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
sÍ   %%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
sÈ   %%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
s‘   %%MatrixMarket matrix coordinate pattern symmetric
  5  5  7
    1     1
    2     2
    4     2
    3     3
    4     4
    5     5
    5     4
t   TestMMIOCoordinatec           B` s   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C` s+   t  ƒ  |  _ t j j |  j d ƒ |  _ d  S(   Ns   testfile.mtx(   R   R   R   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR   Å  s    c         C` s   t  j |  j ƒ d  S(   N(   R   R   R   (   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyR   É  s    c         C` se   t  |  j d ƒ } | j | ƒ | j ƒ  t t |  j ƒ | ƒ t |  j ƒ j ƒ  } t | | ƒ d  S(   NRN   (	   RO   R   RP   t   closeR
   R   R   RC   R   (   R   RQ   R   R   R8   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyRU   Ì  s    
c      	   C` sw   d d d d d g d d d d d g d d d d d g d d d d d g d d d d d	 g g } |  j  t | d ƒ d  S(   Ni   i    i   g      %@g¸…ëQ¸Ž?g     Po@ièþÿÿg)\Âõ¨@@i   i   i   RD   R0   R"   (   i   i   i   s
   coordinates   reals   general(   RU   t   _general_example(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_generalÔ  s    c      	   C` sw   d d d d d g d d d d d g d d d d d g d d d d d g d d d d	 d
 g g } |  j  t | d ƒ d  S(   Ni   i    g      %@g     Po@y        ¸…ëQ86@g¸…ëQ¸Ž?ièþÿÿy        )\Âõ¨@Ày        )\Âõ¨@@i   i   i   RD   R3   R:   y     Po@¸…ëQ86Ày     Po@¸…ëQ86@(   i   i   i   s
   coordinates   complexs	   hermitian(   RU   t   _hermitian_example(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_hermitianÝ  s    c      	   C` sw   d d d d d g d d d d d g d d d d d g d d d d d g d d d d d g g } |  j  t | d ƒ d  S(   Ni   i    g      %@g     PoÀg¸…ëQ¸Ž?g     Po@ièþÿÿi   i   i   RD   R0   s   skew-symmetric(   i   i   i   s
   coordinates   reals   skew-symmetric(   RU   t   _skew_example(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_skewæ  s    c      	   C` sw   d d d d d g d d d d d g d d d d d g d d d d d g d d d d d g g } |  j  t | d ƒ d  S(   Ni   i    g      %@g     Po@g¸…ëQ¸Ž?ièþÿÿi   i   i   i   RD   R0   R5   (   i   i   i   s
   coordinates   reals	   symmetric(   RU   t   _symmetric_example(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_symmetricï  s    c      	   C` sw   d d d d d g d d d d d g d d d d d g d d d d d g d d d d d g g } |  j  t | d ƒ d  S(	   Ni   i    i   i   RD   RH   R5   (   i   i   i   s
   coordinates   patterns	   symmetric(   RU   t   _symmetric_pattern_example(   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_read_symmetric_patternø  s    c         C` sj   t  j j d ƒ } t |  j | ƒ t t |  j ƒ d ƒ | j ƒ  } t |  j ƒ j ƒ  } t	 | | ƒ d  S(   Ni
   i    RD   R0   R5   (   i
   i
   (   i
   i
   i    s
   coordinates   reals	   symmetric(
   RE   RF   t
   coo_matrixR   R   R
   R   RC   R   R   (   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_empty_write_read  s    c   
   	   C` s;  y d d  l  } Wn d  SXt d d d d d d d d g ƒ } t d d d d d d d d g ƒ } t d d d d	 d
 d d d g ƒ } t j j | | | f f d d ƒ} t |  j | ƒ d |  j } t |  j d ƒ 6 } | j | d ƒ } | j	 | j
 ƒ  ƒ | j ƒ  Wd  QXt | ƒ j ƒ  }	 t |	 | j ƒ  ƒ d  S(   Ni    i   i   i   i   g      ð?g      @g      %@g¸…ëQ¸Ž?g     Po@g     €qÀg)\Âõ¨@@g      (@t   shapei   s   %s.bz2t   rbt   wb(   i   i   (   t   bz2R   RE   RF   Ru   R   R   RO   t   BZ2FileRP   t   readRj   R   RC   R   (
   R   Rz   t   It   Jt   VR   t   fn_bzip2t   f_int   f_outR   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_bzip2_py3  s     $$$$c   
   	   C` s;  y d d  l  } Wn d  SXt d d d d d d d d g ƒ } t d d d d d d d d g ƒ } t d d d d	 d
 d d d g ƒ } t j j | | | f f d d ƒ} t |  j | ƒ d |  j } t |  j d ƒ 6 } | j | d ƒ } | j | j	 ƒ  ƒ | j
 ƒ  Wd  QXt | ƒ j ƒ  }	 t |	 | j ƒ  ƒ d  S(   Ni    i   i   i   i   g      ð?g      @g      %@g¸…ëQ¸Ž?g     Po@g     €qÀg)\Âõ¨@@g      (@Rw   i   s   %s.gzRx   Ry   (   i   i   (   t   gzipR   RE   RF   Ru   R   R   RO   RP   R|   Rj   R   RC   R   (
   R   R„   R}   R~   R   R   t   fn_gzipR   R‚   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_gzip_py3%  s     $$$$c      	   C` sè   t  d d d d d d d d g ƒ } t  d d d d d d d d g ƒ } t  d d d d	 d
 d d d g ƒ } t j j | | | f f d d ƒ} t |  j | ƒ t t |  j ƒ d ƒ | j ƒ  } t	 |  j ƒ j ƒ  } t
 | | ƒ d  S(   Ni    i   i   i   i   g      ð?g      @g      %@g¸…ëQ¸Ž?g     Po@g     €qÀg)\Âõ¨@@g      (@Rw   i   i   RD   R0   R"   (   i   i   (   i   i   i   s
   coordinates   reals   general(   R   RE   RF   Ru   R   R   R
   R   RC   R   R   (   R   R}   R~   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_real_write_read=  s    $$$$c      
   C` sè   t  d d d d d d d d g ƒ } t  d d d d d d d d g ƒ } t  d d d d d  d! d" d# g ƒ } t j j | | | f f d d$ ƒ} t |  j | ƒ t t |  j ƒ d% ƒ | j ƒ  } t	 |  j ƒ j ƒ  } t
 | | ƒ d  S(&   Ni    i   i   i   i   g      ð?y              @g      @y               @g      %@y        ÍÌÌÌÌÌì?g¸…ëQ¸Ž?y        š™™™™™Àg     Po@y                g     €qÀy              @g)\Âõ¨@@y        š™™™™™@g      (@y        š™™™™™é?Rw   i   i   RD   R3   R"   y      ð?      @y      @       @y      %@ÍÌÌÌÌÌì?y¸…ëQ¸Ž?š™™™™™Ày     Po@        y     €qÀ      @y)\Âõ¨@@š™™™™™@y      (@š™™™™™é?(   i   i   (   i   i   i   s
   coordinates   complexs   general(   R   RE   RF   Ru   R   R   R
   R   RC   R   R   (   R   R}   R~   R   R   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_complex_write_readL  s    $$$c   
   
   C` sn  g  } t  d d d d d d d d g ƒ } t  d d d d d d d d g ƒ } t  d d d d	 d
 d d d g ƒ } | j t j j | | | f f d d ƒƒ t  d d d d  d! d" d# d$ g ƒ } | j t j j | | | f f d d% ƒƒ x{ | D]s } | j ƒ  } x^ d d d g D]M } t d |  j ƒ } t | | j	 | ƒ ƒ t
 | ƒ j ƒ  }	 t |	 | ƒ qWqó Wd  S(&   Ni    i   i   i   i   g      ð?g      @g      %@g¸…ëQ¸Ž?g     Po@g     €qÀg)\Âõ¨@@g      (@Rw   i   y              @y               @y        ÍÌÌÌÌÌì?y        š™™™™™Ày                y              @y        š™™™™™@y        š™™™™™é?t   csrt   csct   coot   dir(   i   i   y      ð?      @y      @       @y      %@ÍÌÌÌÌÌì?y¸…ëQ¸Ž?š™™™™™Ày     Po@        y     €qÀ      @y)\Âõ¨@@š™™™™™@y      (@š™™™™™é?(   i   i   (   R   t   appendRE   RF   Ru   RC   R   R   R   t   asformatR   R   (
   R   t   matsR}   R~   R   t   matt   expectedt   fmtR   t   result(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_sparse_formats\  s    $$$++c         C` s  t  g g  t d d d ƒ D] } d | ^ q } t d d ƒ } x× | D]Ï } xÆ | D]¾ } d | d } t j j | | f ƒ } | | | d | d f <t |  j | d | ƒt j j |  j ƒ } t	 | j
 | d g ƒ t	 | j | d g ƒ t | j t d | | ƒ g ƒ qS WqF Wd  S(   Ni    iöÿÿÿiÿÿÿÿi
   i   t	   precisions   %%.%dg(   R   t   rangeRE   RF   t
   dok_matrixR   R   t   ioR   R   t   rowt   colR   t   datat   float(   R   t   it   test_valuest   test_precisionst   valueR•   t   nt   A(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   test_precisionr  s    0	(   R@   RA   R   R   RU   Rl   Rn   Rp   Rr   Rt   Rv   Rƒ   R†   R‡   Rˆ   R”   R£   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyRi   Ä  s   																			t   __main__(-   t
   __future__R    R   R   t   tempfileR   R   R   R   t   numpyR%   R   R   R   t   numpy.testingR   R	   R
   R   R   R   t   scipy.sparseRE   t   scipy.io.mmioR   R   R   R   RB   RV   RZ   R\   R^   R`   Rb   Rd   Rg   RM   Rk   Rm   Ro   Rq   Rs   Ri   R@   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/io/tests/test_mmio.pyt   <module>   s6   .Wn		Á