Opened 14 years ago

Closed 14 years ago

#4330 closed defect (fixed)

[with patch, positive review] interfaces function_call(...) function is a total MESS

Reported by: William Stein Owned by: Mike Hansen
Priority: major Milestone: sage-3.2.1
Component: interfaces Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

I just noticed that the functional_call function in the interfaces directory (defined in various files) is a bug-ridden mess.

For example

sage: a = mathematica('N[BesselK[1+I, 2+ 3*I], 20]')
sage: a.Re()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/was/build/sage-3.1.3.alpha3/<ipython console> in <module>()

/home/was/build/sage-3.1.3.alpha3/local/lib/python2.5/site-packages/sage/interfaces/expect.pyc in __call__(self, *args, **kwds)
   1241
   1242     def __call__(self, *args, **kwds):
-> 1243         return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
   1244
   1245     def help(self):

TypeError: function_call() takes at most 3 arguments (4 given)
sage:

Also, I noticed that in expect.py the definition of function_call is:

def function_call(self, function, args=[], kwds={}):

This is the typical stupid Python newbiew mistake (of course I'm the newbie that is to blame here...), which leads to massive subtle bugs. Things are done right in function_call in r.py, and that pattern should be used everywhere else.

Attachments (1)

trac_4330.patch (17.3 KB) - added by Mike Hansen 14 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 14 years ago by Mike Hansen

Owner: changed from William Stein to Mike Hansen
Status: newassigned

comment:2 Changed 14 years ago by Mike Hansen

Summary: interfaces function_call(...) function is a total MESS[with patch, needs review] interfaces function_call(...) function is a total MESS

I also included a fix which makes the GAP interface way more usable. It makes the interface work when GAP functions don't return values so that you can do

sage: rws.MakeConfluent()

instead of

sage: gap.eval("MakeConfluent(%s)"%rws.name()) 

Changed 14 years ago by Mike Hansen

Attachment: trac_4330.patch added

comment:3 Changed 14 years ago by William Stein

Summary: [with patch, needs review] interfaces function_call(...) function is a total MESS[with patch, positive review] interfaces function_call(...) function is a total MESS

Positive review, though it would be nice to remove "import random" from gap.py and it would be good to add my example

sage: a = mathematica('N[BesselK[1+I, 2+ 3*I], 20]')
sage: a.Re()

as an optional doctest.

William

comment:4 Changed 14 years ago by Michael Abshoff

Resolution: fixed
Status: assignedclosed

Merged in Sage 3.2.1.alpha0

Note: See TracTickets for help on using tickets.