jpivarski / pyminuit

Automatically exported from code.google.com/p/pyminuit
GNU General Public License v2.0
14 stars 3 forks source link

Is it really the case that each variable of FCN has to be a single character? #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. set up FCN to be a function of e.g. xa and xb
2. try migrad() on it
3. find a KeyError

e.g.
>>> import minuit
>>> def f( xa, xb ):
...     return ( xa**2 + xb**2 )
... 
>>> m = minuit.Minuit( f )
>>> m.values
{'xb': 0.0, 'xa': 0.0}
>>> m.migrad()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'Parameter "x" is missing from values.'

What is the expected output? What do you see instead?
expected: normal running (above example, that xa = 0.0, xb = 0.0). instead, 
KeyError. changing xa to a and xb to b brings back expected behavior.

What version of the product are you using? On what operating system?
PyMinuit 1.2.1, SEAL-MINUIT 1.7.9, Python 3.3.0, Mac OSX 10.6

Please provide any additional information below.
I can work around it, but really? I cannot use x1, x1, x3, ... ?

Original issue reported on code.google.com by lao...@gmail.com on 4 Jan 2013 at 6:28

GoogleCodeExporter commented 9 years ago
I ran into this today.

Attached is a patch that fixes the issue for Python 3.3+ only. It has to be 
changed to work on older Python versions.

The problem is that using PyUnicode_AS_DATA (aliased to PyString_AsString) 
returns UTF-32 encoding, which includes many null-bytes. Minuit the truncates 
the name at the first null-byte. The fix is to give a UTF-8 encoded string to 
minuit.

Original comment by ismo.toijala@gmail.com on 29 Apr 2013 at 5:37

Attachments:

GoogleCodeExporter commented 9 years ago
Ah. OK. Thank you! At least now I know why, though I have already set up an 
interface to map user-given strings to single-character names within my code...

Original comment by lao...@gmail.com on 30 Apr 2013 at 8:37

GoogleCodeExporter commented 9 years ago
I also got bitten by this, using Python 3.2 though.

Here is a modified patch that should work with all versions of Python 3, using 
ASCII (so no fancy symbols for parameter names).

Original comment by daniel.p...@gmail.com on 16 May 2013 at 12:19

Attachments:

GoogleCodeExporter commented 9 years ago
i'm having the same problem how to i install the patch?

Original comment by kpmooroo...@gmail.com on 20 Nov 2013 at 2:28