From: Michael D. <md...@st...> - 2009-01-05 15:23:15
|
This seems to be a bug (or at least inconsistent behavior) in numpy when the locale is set (which happens when gtk is imported -- replace 'import pylab' with 'import gtk' and you'll see the same behavior). We actually use a workaround for this in other parts of matplotlib, which is: for i in a: str(float(i)) By forcing the conversion to a Python float first, you can get around the localized number output. I'll follow up with this on the numpy bug tracker or mailing list, since this has been a long-standing niggle of mine as well. Cheers, Mike Lionel Roubeyrie wrote: > Hi all, > Trying to write to text files some plotted datas, we have a strange > behavour on masked arrays after importing pylab, with the dot decimal > separator replaced by a comma (but not all) : > ############################## > Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>>> import numpy as np >>>> a=np.ma.array([1., 1.01, 2.11, 3.61]) >>>> for i in a:str(i) >>>> > ... > '1.0' > '1.01' > '2.11' > '3.61' > >>>> import matplotlib >>>> for i in a:str(i) >>>> > ... > '1.0' > '1.01' > '2.11' > '3.61' > >>>> import pylab >>>> for i in a:str(i) >>>> > ... > '1.0' > '1,01' > '2,11' > '3,61' > >>>> np.__version__, matplotlib.__version__ >>>> > ('1.2.1', '0.98.3') > ############################# > > Any help welcomes! > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA |