[sage-devel] Re: maxima_calculus.load("blah.mac") throws, load("blah.mac'") in sage --maxima works

2017-01-13 Thread Nils Bruin
On Friday, January 13, 2017 at 11:01:15 AM UTC-8, Dima Pasechnik wrote:
>
> There is also a problem parsing ''' (thanks, google-groups, for editing it 
> for us :-)) as ' " (or " ', depending on the context).
> At least it did hit me...
>

cut/paste works fine for me, so I think the only confusing thing is that 
google-groups uses a proportional font by default. It didn't change the 
actual characters.
 

> By the way, is there a way to assign bindings like
> maxima_calculus.sin() to Maxima functions from just loaded Maxima code on 
> the fly, 
> without going into trouble of installing a Maxima package, rebuilding 
> Sage's Maxima, etc?
>

That just works, even for functions that don't exist (yet).

sage: import sage.interfaces.maxima_lib
sage: M=sage.interfaces.maxima_lib.maxima
sage: M.g(x)

see maxima_calculus.__getattr__ for how.

-- 
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.


[sage-devel] Re: maxima_calculus.load("blah.mac") throws, load("blah.mac'") in sage --maxima works

2017-01-13 Thread Dima Pasechnik
There is also a problem parsing ''' (thanks, google-groups, for editing it 
for us :-)) as ' " (or " ', depending on the context).
At least it did hit me...

By the way, is there a way to assign bindings like
maxima_calculus.sin() to Maxima functions from just loaded Maxima code on 
the fly, 
without going into trouble of installing a Maxima package, rebuilding 
Sage's Maxima, etc?



On Friday, January 13, 2017 at 8:15:53 AM UTC, Nils Bruin wrote:
>
> On Thursday, January 12, 2017 at 7:35:03 PM UTC-8, Robert Dodier wrote:
>>
>> On 2017-01-12, Dima Pasechnik  wrote: 
>>
>> > maxima_calculus.load("blah.mac") throws a TypeError: 
>> > ECL says: THROW: The catch MACSYMA-QUIT is undefined. 
>>
>> I think the problem here is that
>
> maxima_calculus.load("/path/name/thats/not/valid/maxima/syntax")
>
> gets translated to executing in maxima:
>
> load(/path/name/thats/not/valid/maxima/syntax)
>
> so a parsing error occurs, which doesn't get caught properly.
>

-- 
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.


[sage-devel] Re: maxima_calculus.load("blah.mac") throws, load("blah.mac'") in sage --maxima works

2017-01-13 Thread Nils Bruin
On Thursday, January 12, 2017 at 7:35:03 PM UTC-8, Robert Dodier wrote:
>
> On 2017-01-12, Dima Pasechnik  wrote: 
>
> > maxima_calculus.load("blah.mac") throws a TypeError: 
> > ECL says: THROW: The catch MACSYMA-QUIT is undefined. 
>
> I think the problem here is that

maxima_calculus.load("/path/name/thats/not/valid/maxima/syntax")

gets translated to executing in maxima:

load(/path/name/thats/not/valid/maxima/syntax)

so a parsing error occurs, which doesn't get caught properly.

-- 
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.


[sage-devel] Re: maxima_calculus.load("blah.mac") throws, load("blah.mac'") in sage --maxima works

2017-01-12 Thread Robert Dodier
On 2017-01-12, Dima Pasechnik  wrote:

> maxima_calculus.load("blah.mac") throws a TypeError:
> ECL says: THROW: The catch MACSYMA-QUIT is undefined.

Well, there is more than one way to process an input file in Maxima, and
in one of those ways, the function reading the file throws MACSYMA-QUIT
and the caller is supposed to catch that to know the end of file was
reached. So it sounds as if the file was opened and the content was read
but the end of file wasn't handled correctly. Is there a way to see if
anything was actually processed? e.g. maybe look at values or function
definitions or print output.

> maxima.load("blah.mac") just hangs indefinitely.

A wild guess. Is it possible that it didn't switch back to reading from
the console after the file was processed? Completely guessing here.

best,

Robert Dodier

-- 
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.


[sage-devel] Re: maxima_calculus.load("blah.mac") throws, load("blah.mac'") in sage --maxima works

2017-01-12 Thread Nils Bruin
This works:

sage: maxima_calculus.load('to_poly_solve')
\"/usr/local/sage/sage-git/local/share/maxima/5.35.1/share/to_poly_solve/to_poly_solve.mac\"

whereas this does not:

sage: maxima_calculus.load('to_poly_solve.mac')
TypeError: ECL says: In function PATHNAME, the value of the only argument is
  ((MNCTIMES SIMP) $TO_POLY_SOLVE $MAC)
which is not of the expected type (OR FILE-STREAM STRING PATHNAME)

(clearly, the filename is parsed rather than taken as a string)

This does seem to work:

sage: maxima_calculus.load('"to_poly_solve.mac"')
\"/usr/local/sage/sage-git/local/share/maxima/5.35.1/share/to_poly_solve/to_poly_solve.mac\"

as does this:

sage: 
maxima_calculus.load('"/usr/local/sage/sage-git/local/share/maxima/5.35.1/share/to_poly_solve/to_poly_solve.mac"')
\"/usr/local/sage/sage-git/local/share/maxima/5.35.1/share/to_poly_solve/to_poly_solve.mac\"

so it looks like there's nothing particularly wrong with the load command 
once you let it deal with strings properly.

If you want to take it a little closer to the metal you can do

sage: maxima_calculus._eval_line('load("to_poly_solve.mac")')
'\\"/usr/local/sage/sage-git/local/share/maxima/5.35.1/share/to_poly_solve/to_poly_solve.mac\\"

which seems to work as well. 

Working with a nonexisting file gives a rather uninformative error message:

sage: maxima_calculus.load('"blah.mac"')
TypeError: ECL says: Error executing code in Maxima:

whereas maxima tells exactly what goes wrong. So the error message 
capturing technology can perhaps be improved.

-- 
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.