Issue1198
Created on 2008-12-10.05:16:10 by pjenvey, last changed 2009-03-27.19:03:58 by pjenvey.
File name |
Uploaded |
Description |
Edit |
Remove |
faux_float.patch
|
zyasoft,
2009-03-23.12:11:22
|
|
|
|
msg3901 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-12-10.05:16:09 |
|
Java integration's py2float doesn't consider __float__ for conversion.
This is an issue with other conversions (py2int, etc) and likely affects
more than the math module
Jython 2.5b0+ (trunk:5722:5725M, Dec 9 2008, 16:06:58)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> class F(object):
... def __float__(self):
... return 1.6
...
>>> import math
>>> math.cos(F())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cos(): 1st arg can't be coerced to double
Python 2.5.2 (r252:60911, Apr 22 2008, 12:00:45)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class F(object):
... def __float__(self):
... return 1.6
...
>>> import math
>>> math.cos(F())
-0.029199522301288815
|
msg3902 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2008-12-10.05:25:16 |
|
This is breaking a couple SymPy tests:
_______________ sympy/utilities/tests/test_lambdify.py:test_trig
_______________
File "/home/ondra/repos/sympy/sympy/utilities/tests/
test_lambdify.py",
line 150, in test_trig
d = f(pi)
File "<string>", line 1, in <lambda>
TypeError: cos(): 1st arg can't be coerced to double
_________________________________________________________
|
msg4335 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-03-22.20:49:52 |
|
This needs to be done in PyObject#__tojava__, since that's what
ReflectedArgs#matches calls. I have a preliminary patch.
|
msg4336 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2009-03-22.21:22:04 |
|
Originally I was thinking we'd use the Py.py2int/float methods to do it
as that's where the current conversions generally happen. Looking at
them again, though, they are pretty lame:
public static int py2int(PyObject o, String msg) {
if (o instanceof PyInteger) {
return ((PyInteger) o).getValue();
}
Object obj = o.__tojava__(Integer.TYPE);
PyInteger.__tojava__ would already do this for us
|
msg4339 (view) |
Author: Jim Baker (zyasoft) |
Date: 2009-03-23.12:11:22 |
|
I have attached a patch, including a minimal test (based on the bug
report). We may want to reconsider how it uses AttributeError, but any
such alternative would presumably require a larger change.
|
msg4360 (view) |
Author: Philip Jenvey (pjenvey) |
Date: 2009-03-27.19:03:58 |
|
applied in r6109. we should support faux-ints too but it breaks stuff (see
the comment in PyObject.__tojava__)
|
|
Date |
User |
Action |
Args |
2009-03-27 19:03:58 | pjenvey | set | status: open -> closed resolution: accepted -> fixed messages:
+ msg4360 |
2009-03-24 15:15:07 | marcdownie | set | nosy:
+ marcdownie |
2009-03-23 12:11:23 | zyasoft | set | keywords:
+ patch files:
+ faux_float.patch messages:
+ msg4339 |
2009-03-22 21:22:04 | pjenvey | set | messages:
+ msg4336 |
2009-03-22 20:49:53 | zyasoft | set | assignee: zyasoft resolution: accepted messages:
+ msg4335 nosy:
+ zyasoft |
2009-03-14 02:42:40 | fwierzbicki | set | priority: high |
2008-12-10 05:25:18 | pjenvey | set | messages:
+ msg3902 |
2008-12-10 05:16:10 | pjenvey | create | |
|