octave  implement handling of multiple return values of functions
On Mon, Mar 24, 2008 at 8:26 AM, Michael <michael.delamaza@gmail.com> wrote:
>
> What is the recommended way to handle Octave functions with multiple
> return values in Sage?
I wrote the Sage/Octave interface, but I didn't think of everything. In particular,
I completely forgot about multiple return values. The recommend way to handle
them would be to implement something similar to what the Magma interface
currently does, then use that. :)
> Like Magma, Octave functions can return multiple values. Working with
> such Magma functions is documented in the Sage documentation (http://
> modular.math.washington.edu/sage/doc/html/ref/node125.html), but I
> cannot find similar documentation for Octave.
>
> Here is how it works in Octave  foo is a function that returns two
> values:
>
> octave:4> function [a b] = foo() a=1; b=2; endfunction
> octave:5> foo()
> ans = 1
> octave:6> [c,d] = foo()
> c = 1
> d = 2
>
>
> This code transliterated into Sage is shown below. What is the
> correct way to do this?
>
> 
>  SAGE Version 2.10.3, Release Date: 20080311 
>  Type notebook() for the GUI, and license() for information. 
> 
>
> sage: octave.eval("function [a b] = foo() a=1; b=2; endfunction")
> ''
> sage: octave.foo()
> 1
> sage: [c, d] = octave.foo()
> 
> <type 'exceptions.NotImplementedError'> Traceback (most recent call
> last)
>
> /home/login/<ipython console> in <module>()
>
> /usr/local/sage/local/lib/python2.5/sitepackages/sage/interfaces/
> expect.py in __iter__(self)
> 1013
> 1014 def __iter__(self):
> > 1015 for i in range(1, len(self)+1):
> 1016 yield self[i]
> 1017
>
> /usr/local/sage/local/lib/python2.5/sitepackages/sage/interfaces/
> expect.py in __len__(self)
> 1017
> 1018 def __len__(self):
> > 1019 raise NotImplementedError
> 1020
> 1021 def __reduce__(self):
>
> <type 'exceptions.NotImplementedError'>:
> sage:
>
Change History (8)
Type: 
defect →
enhancement

Milestone: 
sage5.11 →
sage5.12

Milestone: 
sage6.1 →
sage6.2

Milestone: 
sage6.2 →
sage6.3

Milestone: 
sage6.3 →
sage6.4

Component: 
interfaces →
interfaces: optional

Keywords: 
octave added

Report Upstream: 
→ N/A

See also #19502 for a possibly related bug (or possibly not).