Hi,

A similar issue appeared some time ago with other of the modules used in PyMca (the sps module) and the solution passed by the use of LC_ALL=C inside the module.

So, unless I find something else (like trying to do the forcing inside PyMca) I will follow the lines of the quick and dirty fix.

In principle, since the culprit is QApplication, I should be able to use QApplication setLocale to fix it:

"""
On Unix/Linux Qt is configured to use the system local settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.
"""

I will implement it and test it tomorrow but it seems to me the best solution.

Thanks for the feedback,

Armando


Quoting Teemu Ikonen <tpiko...@gmail.com>:

Hi,

Thanks for debugging this. I can reproduce the bug by starting pymca with

LANG=de_DE.UTF-8 pymca

Interestingly, instantiating QApplication class makes the scanf call
in the specfile module use the locale-based numeric format. See the
attached testcase.

The quick and dirty fix would be to add the line
export LC_NUMERIC=C
as a second or third line to /usr/bin/pymca

But, there is probably a smarter way to fix this.

Best,

Teemu

2010/11/5 PICCA Frédéric-Emmanuel
<frederic-emmanuel.pi...@synchrotron-soleil.fr>:
hello so I am investigating

if I put print ElementL1ShellValues in the LShell.py

here the output of the last lines

from PyMca import LShell

...
 [100.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [101.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [102.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [103.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [104.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [105.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [106.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [107.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [108.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216], [109.0, 2.5339999999999998, 17.536000000000001, 0.047, 0.59299999999999997, 0.216]]

with pymca

[100.0, 2.0, 17.0, 0.0, 0.0, 0.0], [101.0, 2.0, 17.0, 0.0, 0.0, 0.0], [102.0, 2.0, 17.0, 0.0, 0.0, 0.0], [103.0, 2.0, 17.0, 0.0, 0.0, 0.0], [104.0, 2.0, 17.0, 0.0, 0.0, 0.0], [105.0, 2.0, 17.0, 0.0, 0.0, 0.0], [106.0, 2.0, 17.0, 0.0, 0.0, 0.0], [107.0, 2.0, 17.0, 0.0, 0.0, 0.0], [108.0, 2.0, 17.0, 0.0, 0.0, 0.0], [109.0, 2.0, 17.0, 0.0, 0.0, 0.0]]

as you can see it seems that from pymca the imported values are rounded to int values.

and this is not true without.

so the problem comes from this code:

sf=specfile.Specfile(os.path.join(dirname, "LShellConstants.dat"))
ElementL1ShellConstants = sf[0].alllabels()
ElementL2ShellConstants = sf[1].alllabels()
ElementL3ShellConstants = sf[2].alllabels()
ElementL1ShellValues = Numeric.transpose(sf[0].data()).tolist()


sf[0].data() gives

[ 100.    2.   17.    0.    0.    0.]
 [ 101.    2.   17.    0.    0.    0.]
 [ 102.    2.   17.    0.    0.    0.]
 [ 103.    2.   17.    0.    0.    0.]
 [ 104.    2.   17.    0.    0.    0.]
 [ 105.    2.   17.    0.    0.    0.]
 [ 106.    2.   17.    0.    0.    0.]
 [ 107.    2.   17.    0.    0.    0.]
 [ 108.    2.   17.    0.    0.    0.]
 [ 109.    2.   17.    0.    0.    0.]]

so the problem is in the specfile module.
(c module it seems)

In fact if I start the program with
LANG=C pymca it works.

probably a ',' or '.' problem during double conversion.

See you

Frederic




-------- Message d'origine--------
De: debian-science-maintainers-bounces+picca=synchrotron-soleil...@lists.alioth.debian.org de la part de PICCA Frédéric-Emmanuel
Date: ven. 05/11/2010 19:39
À: Teemu Ikonen
Cc: 602...@bugs.debian.org
Objet : Bug#602471: RE : Bug#602471: pymca: package unusable

The data file is ok, and importing the offending module works with the
standard interpreter, so the bug is most likely somehow related to
your environment.

I reproduced this bug on two differents systems (unstable)

Or alternatively, something in my environment
prevents this bug from appearing.

Unless you or someone else can provide more information, it will be
difficult to fix this.

or maybe the modules loaded before LShell has some side effect on the
LSHell module

I will try to investigate.

See you

Frred



--
debian-science-maintainers mailing list
debian-science-maintain...@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/debian-science-maintainers








--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to