I am interested in comments and criticism concerning the following work in
progress:

https://pypi.python.org/pypi/sage_octave

Bill Page

---------- Forwarded message ----------
From: Bill Page <bill.p...@newsynthesis.org>
Date: 6 January 2016 at 00:54
Subject: Re: [smc] %octave mode in sage worksheets is flaky simply because
Sage's own octave.eval is flaky (#355)
To: sagemathinc/smc <
reply+004c2a40318c8c0b1fbe82885f3e4a89c6cb80196b0bea9792cf0000000112a3c55492a169ce076e1...@reply.github.com
>
Cc: sagemathinc/smc <s...@noreply.github.com>


William,

I know absolutely nothing about packaging in Python but I did find another
tutorial:

  http://python-packaging.readthedocs.org/en/latest/minimal.html

that got me, in only a few steps, to something that seems to work. See:

  http://github.com/billpage/sage-octave

I uploaded this to PyPI and can now run

  pip install sage-octave

This works on SMC and creates

  .local/lib/python2.7/site-packages/octave.py

which produces the expected results when I run Sage and do

  sage: from octave import octave

e.g. recovers syntax errors without losing synchronization.

~$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath Version 6.10, Release Date: 2015-12-18                    │
│ Enhanced for SageMathCloud.                                        │
└────────────────────────────────────────────────────────────────────┘
sage: from octave import octave
sage: octave("1+1")
 2
sage: octave("x-1=3")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-b14a09c062ad> in <module>()
----> 1 octave("x-1=3")

/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc
 in __call__(self, x, name)
    241
    242         if isinstance(x, six.string_types):
--> 243             return cls(self, x, name=name)
    244         try:
    245             return self._coerce_from_special_method(x)

/projects/4bc39013-7b65-4a65-9d3d-bec4a4ce4d5a/expect.pyc in __init__
(self, parent, value, is_name, name)
   1303         else:
   1304             try:
-> 1305                 self._name = parent._create(value, name=name)
   1306             # Convert ValueError and RuntimeError to TypeError for
   1307             # coercion to work properly.

/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc
 in _create(self, value, name)
    431     def _create(self, value, name=None):
    432         name = self._next_var_name() if name is None else name
--> 433         self.set(name, value)
    434         return name
    435

/projects/4bc39013-7b65-4a65-9d3d-bec4a4ce4d5a/.local/lib/python2.7/site-packages/octave.pyc
 in set(self, var, value)
    404         out = self.eval(cmd)
    405         if out.find("error") != -1 or out.find("Error") != -1:
--> 406             raise TypeError
("Error executing code in Octave\nCODE:\n\t%s\nOctave ERROR:\n\t%s"%(cmd,
 out))
    407
    408     def get(self, var):

TypeError: Error executing code in Octave
CODE:
        sage1=x-1=3;
Octave ERROR:
        parse error:

  invalid left hand side of assignment

>>> sage1=x-1=3;
             ^

sage: octave("1+1")
 2
sage:

--

This also works in a Sage SMC worksheet


https://cloud.sagemath.com/projects/4bc39013-7b65-4a65-9d3d-bec4a4ce4d5a/files/test%20octave.sagews

Is this more or less what you had in mind?

Bill Page.


On 5 January 2016 at 16:29, Bill Page <bill.p...@newsynthesis.org> wrote:

> Well, this sounds interesting but with only the referenced generic
> documentation and example, it still seems daunting when the intention is
> just to make a single python file easily available.  Would you happen to
> have a more specific example for something similar that "depends on sage"?
> If I could just copy it, substitute the file and a tweak a few
> configuration parameters I think I could manage that.
>
> On 5 January 2016 at 12:54, William Stein <notificati...@github.com>
> wrote:
>
>> Bill, you could make your octave interface into a Pip package (which you
>> say "this depends on sage", for now):
>>
>> http://python-packaging-user-guide.readthedocs.org/en/latest/distributing/
>>
>> Then I could just do "pip install sage-octave" (say), and it would get
>> installed. I would also make it so in a sage worksheet your package would
>> be imported and provide the %octave mode for worksheets by defaults.
>>
>> (All of Sage should be rewritten to be a bunch of pip packages (and
>> semantic versioning), which we assemble regularly together for testing. But
>> that's a battle for another lifetime.)
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/sagemathinc/smc/issues/355#issuecomment-169081026>.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to