<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/988" rel="nofollow">http://projects.scipy.org/scipy/ticket/988</a> on 2009-08-17 by trac user chtito, assigned to unknown.</em></p>
<p dir="auto">Using a german locale and the gtk backend induces and error in mmwrite. This bug was already reported in <code class="notranslate">gh-1329</code> and the responsability of gtk was alluded to in <a href="http://projects.scipy.org/numpy/ticket/902#comment:1" rel="nofollow">http://projects.scipy.org/numpy/ticket/902#comment:1</a>.</p>
<p dir="auto">This bug has however never been fixed. It might be a bug of gtk only, but I submit it anyway here because it has devastating consequences when using the scipy.io package.</p>
<p dir="auto">Here is a test case:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#!python
import os
os.environ['LANG'] = 'de_DE.UTF-8'

import gtk._gtk

def test_locale():
    from numpy import array
    a = array([[1.,2.],[0.,4.5]])
    from scipy.sparse import coo_matrix
    asparse = coo_matrix(a)
    # figure out a temporary file name:
    from tempfile import NamedTemporaryFile as tempfile
    f = tempfile()
    name = f.name
    f.close()
    # mmwrite on that tmp file
    from scipy.io import mmread, mmwrite
    mmwrite(f.name, asparse)
    # read
    read = mmread(f.name)
    # compare
    print a
    print read.todense()
    from numpy.testing import assert_array_almost_equal
    assert_array_almost_equal(read.todense(), a)


test_locale()"><pre class="notranslate"><code class="notranslate">#!python
import os
os.environ['LANG'] = 'de_DE.UTF-8'

import gtk._gtk

def test_locale():
    from numpy import array
    a = array([[1.,2.],[0.,4.5]])
    from scipy.sparse import coo_matrix
    asparse = coo_matrix(a)
    # figure out a temporary file name:
    from tempfile import NamedTemporaryFile as tempfile
    f = tempfile()
    name = f.name
    f.close()
    # mmwrite on that tmp file
    from scipy.io import mmread, mmwrite
    mmwrite(f.name, asparse)
    # read
    read = mmread(f.name)
    # compare
    print a
    print read.todense()
    from numpy.testing import assert_array_almost_equal
    assert_array_almost_equal(read.todense(), a)


test_locale()
</code></pre></div>
<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/828" rel="nofollow">http://projects.scipy.org/scipy/ticket/828</a> on 2008-12-28 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nilswagner01/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nilswagner01">@nilswagner01</a>, assigned to unknown.</em></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; scipy.__version__
'0.7.0.dev5294'
&gt;&gt;&gt; numpy.__version__
'1.3.0.dev6221'





======================================================================
ERROR: test_complex_write_read (test_mmio.TestMMIOCoordinate)         
----------------------------------------------------------------------
Traceback (most recent call last):                                    
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/tests/test_mmio.py&quot;, line 290, in test_complex_write_read
    b = mmread(fn).todense()                                                                                                
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 52, in mmread                             
    return MMFile().read(source)                                                                                            
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 273, in read                              
    return self._parse_body(stream)                                                                                         
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 407, in _parse_body                       
    flat_data = flat_data.reshape(-1,4)                                                                                     
ValueError: total size of new array must be unchanged                                                                       

======================================================================
ERROR: read a hermitian matrix                                        
----------------------------------------------------------------------
Traceback (most recent call last):                                    
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/tests/test_mmio.py&quot;, line 213, in test_read_hermitian
    b = mmread(fn).todense()                                                                                            
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 52, in mmread                         
    return MMFile().read(source)                                                                                        
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 273, in read                          
    return self._parse_body(stream)                                                                                     
  File &quot;/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py&quot;, line 407, in _parse_body                   
    flat_data = flat_data.reshape(-1,4)                                                                                 
ValueError: total size of new array must be unchanged         "><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; scipy.__version__
'0.7.0.dev5294'
&gt;&gt;&gt; numpy.__version__
'1.3.0.dev6221'





======================================================================
ERROR: test_complex_write_read (test_mmio.TestMMIOCoordinate)         
----------------------------------------------------------------------
Traceback (most recent call last):                                    
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/tests/test_mmio.py", line 290, in test_complex_write_read
    b = mmread(fn).todense()                                                                                                
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 52, in mmread                             
    return MMFile().read(source)                                                                                            
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 273, in read                              
    return self._parse_body(stream)                                                                                         
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 407, in _parse_body                       
    flat_data = flat_data.reshape(-1,4)                                                                                     
ValueError: total size of new array must be unchanged                                                                       

======================================================================
ERROR: read a hermitian matrix                                        
----------------------------------------------------------------------
Traceback (most recent call last):                                    
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/tests/test_mmio.py", line 213, in test_read_hermitian
    b = mmread(fn).todense()                                                                                            
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 52, in mmread                         
    return MMFile().read(source)                                                                                        
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 273, in read                          
    return self._parse_body(stream)                                                                                     
  File "/home/nwagner/local/lib64/python2.6/site-packages/scipy/io/mmio.py", line 407, in _parse_body                   
    flat_data = flat_data.reshape(-1,4)                                                                                 
ValueError: total size of new array must be unchanged         
</code></pre></div>