Possible bug in Basic.__call__

0 views
Skip to first unread message

Ted Horst

unread,
Feb 11, 2009, 7:55:58 PM2/11/09
to sy...@googlegroups.com
I'm not sure if __call__ is supposed to do anything on an expression,
but the following doesn't seem useful:

>>> import sympy as sp
>>> x = sp.Symbol('x')
>>> e = x**2 -7
>>> e(4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.5/site-packages/sympy/core/basic.py", line
1945, in __call__
return Function(self[0])(*args)
NameError: global name 'Function' is not defined

Ted

Ondrej Certik

unread,
Feb 11, 2009, 8:11:12 PM2/11/09
to sy...@googlegroups.com

Thanks for bringing it. We have actually a long thread about it here:

http://groups.google.com/group/sympy-patches/browse_thread/thread/628ebc799ee57ec1/

If you'd like to help to get this fixed, it'd be really awesome. I
think Lance is not working on this anymore, so this issue is open for
anyone to fix. :)

Ondrej

Robert Kern

unread,
Feb 11, 2009, 8:14:01 PM2/11/09
to sy...@googlegroups.com

Well, you should at least raise NotImplementedError until then.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco

Ondrej Certik

unread,
Feb 12, 2009, 11:32:55 AM2/12/09
to sy...@googlegroups.com
>> If you'd like to help to get this fixed, it'd be really awesome. I
>> think Lance is not working on this anymore, so this issue is open for
>> anyone to fix. :)
>
> Well, you should at least raise NotImplementedError until then.

Right, let's fix it:

http://code.google.com/p/sympy/issues/detail?id=1292


Ondrej

Ted Horst

unread,
Feb 12, 2009, 10:13:03 PM2/12/09
to sy...@googlegroups.com
Well, if I understand correctly its pretty straightforward. Here is a
simple patch, the tests are just copied from the subs tests, which is
probably not quite right.

basiccall.patch

Ondrej Certik

unread,
Feb 13, 2009, 4:25:07 PM2/13/09
to sy...@googlegroups.com

Thanks a lot!

The patch looks good, all tests pass. It's +1 with me.

Brian, Lance and Riccardo, do you have any objection to it? We were
discussing this a lot in the thread I posted above, so I want to make
sure all is ok with this, before I push it in.

Ondrej

Riccardo Gori

unread,
Feb 14, 2009, 8:55:02 AM2/14/09
to sy...@googlegroups.com

Maybe it can use _subs_dict instead of subs, but I really don't care, we can
change that later if at all. Lets push it in!

+1

Riccardo


Ondrej Certik

unread,
Feb 14, 2009, 2:36:54 PM2/14/09
to sy...@googlegroups.com

Thanks for the comment. It's in. Welcome to SymPy Ted :)

http://git.sympy.org/?p=sympy.git;a=commitdiff;h=7e1258f35ee57cf00363fec2c3a307ff191eee9d

Ondrej

Reply all
Reply to author
Forward
0 new messages