Opened 15 years ago

Last modified 7 years ago

#2696 new enhancement

octave -- implement handling of multiple return values of functions

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

Status badges

Description

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: 2008-03-11                      |
>  | 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/site-packages/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/site-packages/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)

comment:1 Changed 14 years ago by Alex Ghitza

Type: defectenhancement

comment:2 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:3 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:4 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:5 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:6 Changed 7 years ago by Jeroen Demeyer

Component: interfacesinterfaces: optional

comment:7 Changed 7 years ago by Frédéric Chapoton

Keywords: octave added
Report Upstream: N/A

comment:8 Changed 7 years ago by Karl-Dieter Crisman

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

Note: See TracTickets for help on using tickets.