Opened 11 years ago
Last modified 10 years ago
#7377 closed enhancement
Symbolic Ring to Maxima via EclObject — at Version 52
Reported by: | nbruin | Owned by: | nbruin |
---|---|---|---|
Priority: | major | Milestone: | sage-4.7.1 |
Component: | symbolics | Keywords: | |
Cc: | burcin, saliola, jpflori | Merged in: | |
Authors: | Nils Bruin, Jean-Pierre Flori | Reviewers: | Jean-Pierre Flori, François Bissey, Karl-Dieter Crisman |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description (last modified by )
With maxima-as-an-ecl-library and ecl accessible as a library, we can start interfacing with maxima via a binary library interface. This should be more efficient and more robust, because expressions can be transmitted in a much richer format than text and parsing does not have to recognise error messages and questions (since communication does not go via STDIN/STDOUT anymore)
This ticket is dependent on #10743.
Update: The interface now passes a lot more doctests. Most failures are due to
- small changes in floats, where they get transferred in binary form rather than via strings (simple to fix)
- ECL only returns RuntimeErrors?, since it can't see the difference. So doctests that test error reporting fail.
Serious work issues:
- How should derivatives, e.g.
D[0,1]f(x^2+y^2,x-y+3)
be translated to Maxima? - desolver interface is now broken
Apply trac_7377-abstract-maxima-rebased.patch, trac_7377-maximalib-rebased.patch, trac_7377-fastcalculus-p1.patch, (optional: trac_7377-better-ask-error.patch)
Change History (62)
Changed 11 years ago by
comment:1 Changed 11 years ago by
- Owner changed from burcin to nbruin
comment:2 in reply to: ↑ description Changed 11 years ago by
I think the following email might be of interest to other people wanting to hack maxima:
Since there is already a decent string parser for taking Sage stuff to Maxima and (especially) getting back Sage stuff from Maxima, would there be a way to modify the above - or ecl_eval - to give back the Maxima expression directly? Perhaps this is already in the lib/ecl.pyx file, though I didn't see it on the first reading.
lib/ecl.pyx has nothing to do with maxima-specific stuff. That is all in sagemax.py. It is actually a little bit important to keep that distinction. Maxima is not the only lisp program we might want to interface with.
There is max_read(S) = cadadr(EclObject("#$%s"%S))
, which *reads* the string
S as a maxima expression and returns its parsed result.
So meval(max_read(S))
would do the trick. I do not know what routines maxima
has to convert expressions to a string. If I wanted to know, I would find it
out by looking at something like
max_read("maxima-command-to-print-to-string(x)")
and see what token the maxima reader puts in. I imagine you get something like
<ECL: ((MAX-PRINT-STRING) x)>
back, So do:
maxprint:=EclObject("MAX-PRINT-STRING") #do this once globally meval(EclObject([[maxprint], maxexpression])).python()
Indeed:
sage: max_read("string(x)") <ECL: (($STRING) $X)> sage: meval(max_read("string(x)")) <ECL: "x"> sage: meval(max_read("string(x)")).python() '"x"' sage: meval(max_read("string(x)")).python()[1:-1] 'x'
So
sage: maxprint=EclObject("$STRING") sage: def max_to_string(s): ....: return meval(EclObject([[maxprint],s])).python()[1:-1]
would give you a string representation. Be aware that #$...$ suffers from performance loss, so if you repeatedly use it, your timings will go south quickly. See Dodier's comments on this a while ago. Apparently you could patch Maxima to lose the performance-losing routine (at the expense of losing the wonderful linear-search history the maxima parser offers now).
Sage command -> calls Maxima command -> Maxima command evaluated, but in the ECL library version, not the pexpect version -> Maxima output (a string) converted back using the stuff in Sage
Yes, that would be an approach virtually orthogonal to the one taken in sagemax.py.
> sage: str(ecl_eval("#$load(to_poly_solver)$")) > append: argument must be a non-atomic expression; found false > -- an error. To debug this try debugmode(true);
To illustrate the inner workings:
sage: from sagemax import * sage: e=max_read('load("to_poly_solver")') sage: e <ECL: (($LOAD) "to_poly_solver")> sage: meval(e) append: argument must be a non-atomic expression; found false -- an error. To debug this try debugmode(true); sage: meval(max_read("append(a,b)")) append: argument must be a non-atomic expression; found a -- an error. To debug this try debugmode(true);
So my guess is that "load" is trying to append to an improperly initialized maxima list. I guess that means that in the current setting, our maxima environment hasn't properly been set up yet. That is no surprise. It is actually surprising that so much of maxima works without any initialization at all.
Changed 11 years ago by
comment:3 Changed 11 years ago by
- Report Upstream set to N/A
Finally success! Recipe for getting calculus use maxima in ecl library mode do the following
- apply the patch from #6781
- apply Robert's 7377-abstract-maxima.patch
- apply maxlib.patch
The calculus doctests currently fail because maxima asking questions does not get handled yet.
comment:4 Changed 11 years ago by
Updated maxlib.patch. Changes made:
- Code catches (throw 'macsyma-quit) and tries to recognise errors (often successful)
- suppress questions and throw errors instead
- suppress ";;; load ..." lines and load warnings
- set environment appropriately for calculus instance
There is a nasty problem that "forget(facts())" gets executed by sage, but throws errors. These get caught by the classic interface, but mess up the printing.
Doctesting calculus/calculus.py leads to 10 failures. All have to do with either forget() acting up or the fact that "maxima asks a question" gets reported differently by the two interfaces.
(the uploaded code has some diagnostic output in maxima_eval
to try to debug the "forget" issues. The "ask" errors should just consist of updating the doctest.
Go at it!
comment:5 Changed 11 years ago by
Another update:
- change to symbolic/assumptions.py to not try: ... error: pass (gentler removal of assumptions makes the interface behave a bit better)
- monkey patch maxima to throw error on divergent integral instead of *printing* "Principal Value" and giving an answer.
(maxima does behave as documented, so it is a matter of taste to change maxima's behaviour)
- slightly more pretty/informative error messages
Doctests failures on calculus.py are only 5 and are restricted to whitespace and differently formatted error messages (in other words, for real use, the two interfaces shouldn't be distinguishable anymore).
comment:6 Changed 11 years ago by
- Cc burcin added
comment:7 Changed 11 years ago by
Very sadly I do not have time right now to look at this properly, but if it behaves as advertised, the layout is very understandable and I think might even improve the previous interface in terms of future customization.
Do you think you can post some sample timings, just for information? After all, one (not the only) reason for this would be to significantly speed up repeated use of Maxima for certain applications.
Thanks to nbruin and robertwb for working so hard on this!
comment:8 Changed 11 years ago by
The latest patch must be applied after abstract-maxima
and maxlib
. It adds routines sr_to_max
and max_to_sr
that try to translate between maxima's internal datastructure and SR while avoiding string transformations as much as possible. It falls back to the old interface to establish many of its symbol and operator translations, but takes note of them and uses a dictionary directly the next time around. It also avoids the overhead of binding expressions to maxima variables.
to go back and forth, maxima_lib.MaximaElement()
as a new function {ecl()} which passes back the underlying EclObject?. Conversely, maxima_lib.maxima
accepts EclObjects? and returns a corresponding expect interface object.
This patch also rewrite calculus integral, limit and sum to directly pass back and forth to maxima. There is a lot of overhead in SR itself, so speed gains are not that big. New times are:
sage: timeit("integral(cos(x),x)") 625 loops, best of 3: 1.1 ms per loop sage: timeit("integral(cos(x^2),x)") 5 loops, best of 3: 31.2 ms per loop
where old were
sage: timeit("integral(cos(x),x)") 25 loops, best of 3: 8.08 ms per loop sage: timeit("integral(cos(x^2),x)") 5 loops, best of 3: 37 ms per loop
It is easy to swap the old and new interfaces: simply comment/uncomment the appropriate lines in calculus.py
to define the appropriate calculus.maxima
There are 7 doctest failures in calculus.py
. All of them are whitespace, errors and changed precision in floats:
the binary interface passes double
s directly, so there are no digits rounded. This affects some doctests. In other words, as far is calculus.py
is concerned the two interfaces are functionally equivalent.
comment:9 Changed 11 years ago by
- Cc saliola added
comment:10 Changed 10 years ago by
- Cc jpflori added
comment:11 follow-up: ↓ 12 Changed 10 years ago by
Does this need any rebasing? I am willing to give it a spin in sage-on-gentoo to see if there are any obvious problems on linux.
comment:12 in reply to: ↑ 11 Changed 10 years ago by
- Status changed from new to needs_work
Replying to fbissey:
Does this need any rebasing?
Unfortunately, it does. Since Robert split off the Maxima pexpect interface, there were a few minor changes to sage/interfaces/maxima.py
. His patch needs to be rebased.
AFAIR, the only reason that held this ticket back was a mix-up in the updates to the ecl/maxima packages. The version that properly built maxima as a library got lost since there were several new packages at the same time. I don't know if that problem is fixed in the latest release.
comment:13 Changed 10 years ago by
Note that there's a ticket to update both Maxima and ECL open just now. See #10187
At this point in time, it does not have positive review, but I think it is pretty close to getting it. The packages work together, but there's a doctest failure which needs to be resolved. As far as I can see, its just that Maxima is outputing results in a different form (yet again).
I would suggest you use the packages at #10187 and make this dependent on that, which I think will be merged in the next alpha.
comment:14 Changed 10 years ago by
I tried to update the patches so that they apply on Sage 4.6.1 with Maxima 5.22.1, some things moved since the last patches were produced, but there was nothing too terrible. I'll up them right now.
However, there is now a problem when loading Maxima as a library. Maybe some changes in the spkg (in init-cl.lisp where set-pathnames is defined ?) are responsible for this. Without that line, there is a problem later.
/home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py in <module>() 487 ecl_eval("(defvar *MAXIMA-LANG-SUBDIR* NIL)") 488 ecl_eval("(set-locale-subdir)") --> 489 ecl_eval("(set-pathnames)") 490 ecl_eval("(defun add-lineinfo (x) x)") 491 ecl_eval("""(defun retrieve (msg flag &aux (print? nil))(error (concatenate 'string "Maxima asks:" (meval (list '($string) msg)))))""") /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5616)() /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5570)() /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_safe_eval (sage/libs/ecl.c:2403)() RuntimeError: ECL says: In function PATHNAME, the value of the only argument is NIL which is not of the expected type (OR FILE-STREAM STRING PATHNAME) Error importing ipy_profile_sage - perhaps you should run %upgrade? WARNING: Loading of ipy_profile_sage failed.
I don't know anything about Lisp, ECL and Maxima, so I was not able to fix that in the little time I tried.
As far as the patches as concerned, I feel that more work is needed. Deleting duplicate examples and methods, moving the library interface to libs directory, not sure where maxima abstract should go (if it is kept, should something be done like MaximaLib/Maxima? as for Pari/GP ? no idea if those two "interfaces" share something...), getting rid of the inheritance on Expect in Maxima_lib and Maxima_abstract.
I'm ready to have a look at all of this, if someone helps me launching Maxima as library with latest versions of everything.
comment:15 Changed 10 years ago by
What happens if you just remove that line? I just noticed a typo - marking makes you terrible at that kind of things :) "We begin here by initializing maxima in library more"
^{ }
comment:16 Changed 10 years ago by
It fails later, here is the piece of code involved:
/home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py in __init__(self, script_subdirectory, logfile, server, init_code) 586 ecl_eval("(setf *standard-output* *dev-null*)") 587 for l in init_code: --> 588 ecl_eval("#$%s$"%l) 589 ecl_eval("(setf *standard-output* original-standard-output)") 590 /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5616)() /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5570)() /home/jp/boulot/sage/sage-current/local/lib/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_safe_eval (sage/libs/ecl.c:2403)() RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined. Error importing ipy_profile_sage - perhaps you should run %upgrade? WARNING: Loading of ipy_profile_sage failed.
Tried to google that, but couldn't find anything meaningful to me.
comment:17 Changed 10 years ago by
me neither :(
comment:18 Changed 10 years ago by
I don't know what happened but I rebuilt ecl and maxima while trying to add debug information and everything is fine now. I surely did something wrong at some point...
There are some problems left with what I uploaded earlier in sage.symbolic.integration.external I'll upload fixed version of the patches soon.
comment:19 Changed 10 years ago by
Ok I will give it a spin in sage-on-gentoo.
comment:20 follow-up: ↓ 21 Changed 10 years ago by
I tried the patch against 4.6.2.alpha2 and it builds but it doesn't run properly here:
/usr/lib64/python2.6/site-packages/sage/calculus/calculus.py in <module>() 375 definite_integral 376 import sage.symbolic.pynac --> 377 import sage.interfaces.maxima_lib 378 379 """ /usr/lib64/python2.6/site-packages/sage/interfaces/maxima_lib.py in <module>() 482 from sage.libs.ecl import * 483 ecl_eval("(setf *load-verbose* NIL)") --> 484 ecl_eval("(require 'maxima)") 485 ecl_eval("(in-package :maxima)") 486 ecl_eval("(setq $nolabels t))") /usr/lib64/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5617)() 992 993 --> 994 995 996 /usr/lib64/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_eval (sage/libs/ecl.c:5571)() 1007 1008 -> 1009 1010 1011 /usr/lib64/python2.6/site-packages/sage/libs/ecl.so in sage.libs.ecl.ecl_safe_eval (sage/libs/ecl.c:2404)() 184 185 --> 186 187 188 RuntimeError: ECL says: Module error: Don't know how to REQUIRE MAXIMA. Error importing ipy_profile_sage - perhaps you should run %upgrade? WARNING: Loading of ipy_profile_sage failed.
I am currently also running ecl-11.1.1 which is a source of trouble but I don't think it is responsible here.
comment:21 in reply to: ↑ 20 Changed 10 years ago by
RuntimeError?: ECL says: Module error: Don't know how to REQUIRE MAXIMA. Error importing ipy_profile_sage - perhaps you should run %upgrade? WARNING: Loading of ipy_profile_sage failed.
My first guess is that maxima.fas is not available to your newly built ecl-11.1.1.
Note that in 4.6.1, building maxima produces this library:
$SAGE_ROOT/local/lib/ecl-10.4.1/maxima.fas
so once you upgrade ecl, you need to rebuild maxima as well. Did you do that?
comment:22 Changed 10 years ago by
I downgraded to ecl-10.4.1 and rebuilt maxima and sage but I don't seem to have maxima.fas, I have a number of other fas but not maxima.fas. It was done on sage-on-gentoo, so it is possible that this particular file wasn't installed for a reason or another. I will check what the maxima spkg do.
comment:23 Changed 10 years ago by
OK pity it is not build in maxima by default, works for me now. Not sure how i will sell that one to the maintainer of maxima in Gentoo. Even if I have a good relationship with him.
comment:24 follow-up: ↓ 25 Changed 10 years ago by
I just upgraded to 4.6.2.aplha2 (hoping I won't have to rebuild from scratch for next upgrade...) and everything went fine, it gives me better timings than with the Pexpect interface. Before patches:
Loading Sage library. Current Mercurial branch is: jp sage: timeit("integral(cos(x^2),x)") 5 loops, best of 3: 96.6 ms per loop sage: Exiting Sage (CPU time 0m1.02s, Wall time 0m8.17s). Exiting spawned Maxima process.
After:
Loading Sage library. Current Mercurial branch is: jp sage: timeit("integral(cos(x^2),x)") 5 loops, best of 3: 62.8 ms per loop sage: Exiting Sage (CPU time 0m1.56s, Wall time 3m5.27s).
However those are much more than what was posted above.
Glad to hear it also ran on Sage on Gentoo.
I think some refactoring still has to be done for the new classes. The abstract class is a good idea to transparently switch interface but I think it would be cleaner if it did not inherit from Expect class (and so "Maxima as a lib" does not too). I'll try to work on this this weekend.
It should be also be decided, which interface is used for what, especially since we can only have one "Maxima as a lib" running. Should that Maxima as lib be used for calculus and be given a direct access (maybe as "maximalib" variable as "maxima" gives access to a copy of Maxima in Sage, even if currently the "maxima" variable points to a different instance of Maxima than the one used by calculus).
comment:25 in reply to: ↑ 24 Changed 10 years ago by
Replying to jpflori:
Hi Jean-Pierre,
It's great you're taking on this project! It has the potential of being a lot of fun. I won't be working on it, so I'm very happy to see someone else interested in taking it on. I'll give you some background on the points you raise, so that you can take more informed design decisions.
I think some refactoring still has to be done for the new classes. The abstract class is a good idea to transparently switch interface but I think it would be cleaner if it did not inherit from Expect class (and so "Maxima as a lib" does not too). I'll try to work on this this weekend.
The *only* reason to organize the maxima interfaces as they are now is because Robert remarked that whatever was needed to communicate with maxlib at a string-level was going to have a lot of overlap with the present maxima interface. Hence, he abstracted out the common stuff and I modified the concrete maxlib interface to talk to ecllib instead of a separate process. This was experimental and at the time I had no idea how much was necessary, so I changed as little as possible: The original interface inherited from expect, so the new one did too, just overriding whatever methods needed overriding. So yes, there will be a lot of lint and extraneous stuff in there. What you're looking at is a first hack.
It should be also be decided, which interface is used for what, especially since we can only have one "Maxima as a lib" running. Should that Maxima as lib be used for calculus and be given a direct access (maybe as "maximalib" variable as "maxima" gives access to a copy of Maxima in Sage, even if currently the "maxima" variable points to a different instance of Maxima than the one used by calculus).
The largest benefit is to be gained when the communication can avoid string parsing altogether. (ecllib at the moment converts Integers to ecl bignums via strings, which is silly: They are both implemented as gmp/mpir integers! The only reason is that I never succeeded in importing the gmp/mpir headers in a usable way in ecl.pyx, to copy over the integer. ECL largely avoids gmp's registered memory manager, so some care must be taken to transfer the integer to properly allocated memory.) The routines sr_to_max and max_to_sr (in the fastcalculus patch) implement this strategy. If you want to have this benefit, the maxlib instance *has* to be the "calculus" instance. Note that the default "maxima" instance is already distinct from the "calculus" instance:
sage: integrate(cos(x),x); sage: maxima(x); sage: Exiting Sage (CPU time 0m0.12s, Wall time 0m16.73s). Exiting spawned Maxima process. Exiting spawned Maxima process.
(note the two maxima spawns)
Once the design has stabilized, it would be possible to make max_to_sr and sr_to_max more intelligent. For instance, SR variables would not need to be translated to maxima identifiers with the same name. This currently leads to problems, because this conversion collapses namespaces:
sage: cosvar=SR.var("cos") sage: cos(cosvar) cos(cos) sage: integrate(cos(cosvar),cosvar) integrate(cos(cos), cos) sage: cosvar=SR.var("sage_cos") sage: integrate(cos(cosvar),cosvar) sin(sage_cos)
as you see, the print name of the SR.var matters!
Let me know if you have further questions. I might be able to help with information.
comment:26 Changed 10 years ago by
Thanks so much, Nils and JP, for resurrecting this. JP, I stand ready to test anything you feel is ready to look at. If you know little about ECL, I know even less, so I can't do more than that, but this would be a great start to improving some of Sage's interface. It's true that the timing on average doesn't improve so greatly (yet), but the point is that not having to start Maxima up when you want to do an integral means more immediate gratification for the user. (Assuming immediate gratification is a good thing.)
comment:27 follow-up: ↓ 28 Changed 10 years ago by
Ok so it runs but in its present state it breaks quite a lot of doctests for me. Unless you can point out something else I would need to do. example 1
sage -t -force_lib "devel/sage/sage/symbolic/function_factory.py" ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 174: sage: g Expected: b*D[0](cr)(a) Got: b*del(a) ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 184: sage: g.substitute_function(cr, cos) Expected: -b*sin(a) Got: b*del(a) ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 187: sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x)) Expected: -(sin(a) - cos(a))*b Got: b*del(a) ********************************************************************** 1 items had failures: 3 of 58 in __main__.example_6
example 2
sage -t -force_lib "devel/sage/sage/interfaces/maxima.py" ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 426: sage: t.limit(Ax=0, dir='+') Exception raised: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_0[93]>", line 1, in <module> t.limit(Ax=Integer(0), dir='+')###line 426: sage: t.limit(Ax=0, dir='+') File "expression.pyx", line 8202, in sage.symbolic.expression.Expression.limit (sage/symbolic/expression.cpp:31252) File "/usr/lib/python2.6/site-packages/sage/calculus/calculus.py", line 1122, in limit return l.sage() File "element.pyx", line 327, in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2715) File "parent.pyx", line 277, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2841) File "parent.pyx", line 175, in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2636) AttributeError: 'sage.rings.integer.Integer' object has no attribute 'sage' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 894: sage: f(3.2) Expected: -.05837414342758009 Got: -.058374143427580086 ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 1006: sage: maxima.version() Expected: '5.22.1' Got: '5.23.2' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 1087: sage: maxima_version() Expected: '5.22.1' Got: '5.23.2' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 608: sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) Expected: Traceback (most recent call last): ... TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(a>0)' before integral or limit evaluation, for example): Is a positive or negative? Got: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_6[3]>", line 1, in <module> integrate(Integer(1)/(x**Integer(3) *(a+b*x)**(Integer(1)/Integer(3))),x)###line 608: sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) File "/usr/lib/python2.6/site-packages/sage/misc/functional.py", line 718, in integral return x.integral(*args, **kwds) File "expression.pyx", line 8153, in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:30871) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 601, in integrate return indefinite_integral(expression, v) File "function.pyx", line 419, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4486) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 85, in _eval_ res = integrator(f, x) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/external.py", line 19, in maxima_integrator result = maxima.sr_integral(expression,v) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 983, in sr_integral raise error RuntimeError: ECL says: Maxima asks:?mtext("Is ",a," positive or negative?") ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 618: sage: integral(x^n,x) Expected: Traceback (most recent call last): ... TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(n+1>0)' before integral or limit evaluation, for example): Is n+1 zero or nonzero? Got: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_6[7]>", line 1, in <module> integral(x**n,x)###line 618: sage: integral(x^n,x) File "/usr/lib/python2.6/site-packages/sage/misc/functional.py", line 718, in integral return x.integral(*args, **kwds) File "expression.pyx", line 8153, in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:30871) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 601, in integrate return indefinite_integral(expression, v) File "function.pyx", line 419, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4486) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 85, in _eval_ res = integrator(f, x) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/external.py", line 19, in maxima_integrator result = maxima.sr_integral(expression,v) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 983, in sr_integral raise error RuntimeError: ECL says: Maxima asks:?mtext("Is ",n+1," zero or nonzero?") ********************************************************************** 5 items had failures: 1 of 95 in __main__.example_0 1 of 16 in __main__.example_13 1 of 3 in __main__.example_17 1 of 4 in __main__.example_21 2 of 11 in __main__.example_6 ***Test Failed*** 6 failures. For whitespace errors, see the file /home/francois/.sage/tmp/.doctest_maxima.py
and there are more. Tests are still running on this slow machine.
comment:28 in reply to: ↑ 27 Changed 10 years ago by
- Reviewers set to Jean-Pierre Flori, Francois Bissey, Karl-Dieter Crisan
sage -t -force_lib "devel/sage/sage/symbolic/function_factory.py" ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 174: sage: g Expected: b*D[0](cr)(a) Got: b*del(a) ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 184: sage: g.substitute_function(cr, cos) Expected: -b*sin(a) Got: b*del(a) ********************************************************************** File "/usr/share/sage/devel/sage/sage/symbolic/function_factory.py", line 187: sage: g.substitute_function(cr, (sin(x) + cos(x)).function(x)) Expected: -(sin(a) - cos(a))*b Got: b*del(a) **********************************************************************
Hmm, that is very interesting. I am not quite sure what this del
thing is, but I remember seeing something about it on the Maxima list...
File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 426:
sage: t.limit(Ax=0, dir='+')
return l.sage()
File "element.pyx", line 327, in sage.structure.element.Element.getattr (sage/structure/element.c:2715) File "parent.pyx", line 277, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2841) File "parent.pyx", line 175, in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2636)
AttributeError?: 'sage.rings.integer.Integer' object has no attribute 'sage'
This must be us using Sage Integers somehow at the library level where before they were coming back from Maxima?
File "/usr/share/sage/devel/sage/sage/interfaces/maxima.py", line 608:
sage: integrate(1/(x^{3 *(a+b*x)}(1/3)),x)
Expected:
Traceback (most recent call last): ... TypeError?: Computation failed since Maxima requested additional constraints (try the command 'assume(a>0)' before integral or limit evaluation, for example): Is a positive or negative?
Notice we expect a TypeError?.
RuntimeError?: ECL says: Maxima asks:?mtext("Is ",a," positive or negative?")
Now we just get a different error. I assume that the new code interface has something about ECL asking. We would want to make sure that this still is turned into the helpful type of message we have here, but that should be easy (if tedious) to make work.
Thank you for beginning this testing!
comment:29 Changed 10 years ago by
- Reviewers changed from Jean-Pierre Flori, Francois Bissey, Karl-Dieter Crisan to Jean-Pierre Flori, Francois Bissey, Karl-Dieter Crisman
I don't have the cedille, pardon me :(
comment:30 Changed 10 years ago by
- Reviewers changed from Jean-Pierre Flori, Francois Bissey, Karl-Dieter Crisman to Jean-Pierre Flori, François Bissey, Karl-Dieter Crisman
I have a cedilla thanks to the international setting on my desktop.
More seriously, it should be pointed out that this is done with ecl-11.1.1 and it may have an influence. I have a faster machine at work and I'll test ecl-10.4.1 on Monday.
comment:31 Changed 10 years ago by
Ok so I have a lot of failures that I attribute to maxima-lib, I am making a list for quick reference. I have another sage-on-gentoo report on there being a lot failure with it and this time with ecl-10.4.1.
sage -t -force_lib "devel/sage/sage/functions/special.py" # Time out
sage -t -force_lib "devel/sage/sage/functions/piecewise.py"
sage -t -force_lib "devel/sage/sage/functions/min_max.py"
sage -t -force_lib "devel/sage/sage/functions/orthogonal_polys.py"
sage -t -force_lib "devel/sage/sage/interfaces/maxima_lib.py"
sage -t -force_lib "devel/sage/sage/interfaces/maxima_abstract.py"
sage -t -force_lib "devel/sage/sage/interfaces/maxima.py"
sage -t -force_lib "devel/sage/sage/symbolic/function_factory.py"
sage -t -force_lib "devel/sage/sage/symbolic/integration/integral.py" # Time out
sage -t -force_lib "devel/sage/sage/symbolic/integration/external.py"
sage -t -force_lib "devel/sage/sage/symbolic/relation.py" # Time out
sage -t -force_lib "devel/sage/sage/symbolic/assumptions.py" # Time out
sage -t -force_lib "devel/sage/sage/symbolic/power_helper.pyx"
sage -t -force_lib "devel/sage/sage/symbolic/expression_conversions.py"
sage -t -force_lib "devel/sage/sage/symbolic/ring.pyx"
sage -t -force_lib "devel/sage/sage/symbolic/expression.pyx" # Time out
sage -t -force_lib "devel/sage/sage/rings/number_field/number_field_element_quadratic.pyx"
sage -t -force_lib "devel/sage/sage/rings/number_field/number_field_element.pyx"
sage -t -force_lib "devel/sage/sage/structure/sage_object.pyx"
sage -t -force_lib "devel/sage/sage/misc/functional.py"
sage -t -force_lib "devel/sage/sage/modules/free_module_element.pyx"
sage -t -force_lib "devel/sage/sage/modular/modform/ambient_R.py"
sage -t -force_lib "devel/sage/sage/calculus/desolvers.py"
sage -t -force_lib "devel/sage/sage/calculus/calculus.py"
sage -t -force_lib "devel/sage/sage/calculus/tests.py"
sage -t -force_lib "devel/sage/sage/calculus/functional.py"
sage -t -force_lib "devel/sage/sage/calculus/interpolators.pyx"
sage -t -force_lib "devel/sage/sage/calculus/wester.py"
Some are probably due to ecl-11.1.1 so it should shrink, but it will take a bit of time since ecl, maxima and sage have to be rebuild.
comment:32 follow-ups: ↓ 34 ↓ 36 Changed 10 years ago by
ecl-10.4.1, maxima-5.23.2:
sage -t --verbose -force_lib "devel/sage/sage/functions/special.py" times out because it stops:
Trying: elliptic_e(arccoth(Integer(1)), x**Integer(2)*e)###line 535:_sage_ >>> elliptic_e(arccoth(1), x^2*e) Expecting: elliptic_e(arccoth(1), x^2*e) The number 1 isn't in the domain of acoth -- an error. To debug this try: debugmode(true); Error in format: Unknown format directive. The number ~:M isn't in the domain of ~A ^ while processing indirect format string: ~? ^ No restarts available. Broken at LAMBDA. MAXIMA>>
comment:33 Changed 10 years ago by
Interesting one, notice that it still wants maxima-5.19.1
sage -t -force_lib "devel/sage/sage/interfaces/maxima_lib.py" ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima_lib.py", line 426: sage: t.limit(Ax=0,dir='above') Exception raised: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_0[93]>", line 1, in <module> t.limit(Ax=Integer(0),dir='above')###line 426: sage: t.limit(Ax=0,dir='above') File "expression.pyx", line 8202, in sage.symbolic.expression.Expression.limit (sage/symbolic/expression.cpp:31252) File "/usr/lib/python2.6/site-packages/sage/calculus/calculus.py", line 1122, in limit return l.sage() File "element.pyx", line 327, in sage.structure.element.Element.__getattr__ (sage/structure/element.c:2715) File "parent.pyx", line 277, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:2841) File "parent.pyx", line 175, in sage.structure.parent.raise_attribute_error (sage/structure/parent.c:2636) AttributeError: 'sage.rings.integer.Integer' object has no attribute 'sage' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima_lib.py", line 966: sage: maxima.version() Expected: '5.19.1' Got: '5.23.2' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima_lib.py", line 1076: sage: maxima_version() Expected: '5.19.1' Got: '5.23.2' ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima_lib.py", line 639: sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) Expected: Traceback (most recent call last): ... TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(a>0)' before integral or limit evaluation, for example): Is a positive or negative? Got: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_8[3]>", line 1, in <module> integrate(Integer(1)/(x**Integer(3) *(a+b*x)**(Integer(1)/Integer(3))),x)###line 639: sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x) File "/usr/lib/python2.6/site-packages/sage/misc/functional.py", line 718, in integral return x.integral(*args, **kwds) File "expression.pyx", line 8153, in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:30871) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 601, in integrate return indefinite_integral(expression, v) File "function.pyx", line 419, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4486) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 85, in _eval_ res = integrator(f, x) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/external.py", line 19, in maxima_integrator result = maxima.sr_integral(expression,v) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 983, in sr_integral raise error RuntimeError: ECL says: Maxima asks:?mtext("Is ",a," positive or negative?") ********************************************************************** File "/usr/share/sage/devel/sage/sage/interfaces/maxima_lib.py", line 649: sage: integral(x^n,x) Expected: Traceback (most recent call last): ... TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(n+1>0)' before integral or limit evaluation, for example): Is n+1 zero or nonzero? Got: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_8[7]>", line 1, in <module> integral(x**n,x)###line 649: sage: integral(x^n,x) File "/usr/lib/python2.6/site-packages/sage/misc/functional.py", line 718, in integral return x.integral(*args, **kwds) File "expression.pyx", line 8153, in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:30871) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 601, in integrate return indefinite_integral(expression, v) File "function.pyx", line 419, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4486) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 85, in _eval_ res = integrator(f, x) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/external.py", line 19, in maxima_integrator result = maxima.sr_integral(expression,v) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 983, in sr_integral raise error RuntimeError: ECL says: Maxima asks:?mtext("Is ",n+1," zero or nonzero?") ********************************************************************** 4 items had failures: 1 of 95 in __main__.example_0 1 of 3 in __main__.example_18 1 of 4 in __main__.example_23 2 of 11 in __main__.example_8 ***Test Failed*** 5 failures. For whitespace errors, see the file /home/francois/.sage/tmp/.doctest_maxima_lib.py [17.3 s] ---------------------------------------------------------------------- The following tests failed: sage -t -force_lib "devel/sage/sage/interfaces/maxima_lib.py" Total time for all tests: 17.3 seconds
sage -t -force_lib "devel/sage/sage/symbolic/integration/integral.py times out because:
Trying: integrate(sin(x)*cos(Integer(10)*x)*log(x), x)###line 462:_sage_ >>> integrate(sin(x)*cos(10*x)*log(x), x) Expecting: 1/198*(11*cos(9*x) - 9*cos(11*x))*log(x) + 1/44*Ei(-11*I*x) - 1/36*Ei(-9*I*x) - 1/36*Ei(9*I*x) + 1/44*Ei(11*I*x) Wrong number of arguments to gamma_incomplete -- an error. To debug this try: debugmode(true); Error in format: Unknown format directive. Wrong number of arguments to ~:@M ^ while processing indirect format string: ~? ^ No restarts available. Broken at LAMBDA.
sage -t -force_lib "devel/sage/sage/symbolic/relation.py" times out because of this:
Trying: solve([sqrt(x) + sqrt(y) == Integer(5), x + y == Integer(10)], x, y)###line 492:_sage_ >>> solve([sqrt(x) + sqrt(y) == 5, x + y == 10], x, y) Expecting: [[x == -5/2*I*sqrt(5) + 5, y == 5/2*I*sqrt(5) + 5], [x == 5/2*I*sqrt(5) + 5, y == -5/2*I*sqrt(5) + 5]] assoc: every list element must be an expression with two arguments; found: [sage147] #0: simp_%solve(e=sage135,v=sage146,extraargs=[sage147]) -- an error. To debug this try: debugmode(true); Error in format: Unknown format directive. assoc: every list element must be an expression with two arguments; found: ~:M ^ while processing indirect format string: ~? ^ No restarts available.
sage -t -force_lib "devel/sage/sage/symbolic/assumptions.py":
Trying: decl2.assume()###line 89:_sage_ >>> decl2.assume() Expecting: Traceback (most recent call last): ... ValueError: Assumption is inconsistent declare: inconsistent declaration declare(x,odd) -- an error. To debug this try: debugmode(true); Error in format: Unknown format directive. declare: inconsistent declaration ~:M ^ while processing indirect format string: ~? ^ No restarts available.
sage -t -force_lib "devel/sage/sage/symbolic/expression.pyx":
Trying: solve(acot(x),x)###line 7453:_sage_ >>> solve(acot(x),x) Expecting: [] The number 0 isn't in the domain of cot -- an error. To debug this try: debugmode(true); Error in format: Unknown format directive. The number ~:M isn't in the domain of ~A ^ while processing indirect format string: ~? ^ No restarts available.
sage -t -force_lib "devel/sage/sage/structure/sage_object.pyx" is interesting:
File "/usr/share/sage/devel/sage/sage/structure/sage_object.pyx", line 1053: sage: print "x"; sage.structure.sage_object.unpickle_all() Expected: x... Successfully unpickled ... objects. Failed to unpickle 0 objects. Got: x doctest:1: DeprecationWarning: Your word object is saved in an old file format since FiniteWord_over_OrderedAlphabet is deprecated and will be deleted in a future version of Sage (you can use FiniteWord_list instead). You can re-save your word by typing "word.save(filename)" to ensure that it will load in future versions of Sage. doctest:1: DeprecationWarning: Your word object is saved in an old file format since AbstractWord is deprecated and will be deleted in a future version of Sage (you can use FiniteWord_list instead). You can re-save your word by typing "word.save(filename)" to ensure that it will load in future versions of Sage. doctest:1: DeprecationWarning: Your word object is saved in an old file format since Word_over_Alphabet is deprecated and will be deleted in a future version of Sage (you can use FiniteWord_list instead). You can re-save your word by typing "word.save(filename)" to ensure that it will load in future versions of Sage. doctest:1: DeprecationWarning: Your word object is saved in an old file format since Word_over_OrderedAlphabet is deprecated and will be deleted in a future version of Sage (you can use FiniteWord_list instead). You can re-save your word by typing "word.save(filename)" to ensure that it will load in future versions of Sage. doctest:1: DeprecationWarning: ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead * unpickle failure: load('/home/francois/.sage/temp/vrooom/13483/dir_2/pickle_jar/_class__sage_interfaces_maxima_MaximaFunction__.sobj') Failed: _class__sage_interfaces_maxima_MaximaFunction__.sobj Successfully unpickled 585 objects. Failed to unpickle 1 objects.
sage -t -force_lib "devel/sage/sage/modules/free_module_element.pyx" now pass, so probably ecl-11.1.1 related.
sage -t -force_lib "devel/sage/sage/calculus/tests.py" (extracts):
File "/usr/share/sage/devel/sage/sage/calculus/tests.py", line 107: sage: integrate(log(1-x^2)/x, x) Exception raised: Traceback (most recent call last): File "/usr/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/usr/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/usr/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_0[41]>", line 1, in <module> integrate(log(Integer(1)-x**Integer(2))/x, x)###line 107: sage: integrate(log(1-x^2)/x, x) File "/usr/lib/python2.6/site-packages/sage/misc/functional.py", line 718, in integral return x.integral(*args, **kwds) File "expression.pyx", line 8153, in sage.symbolic.expression.Expression.integral (sage/symbolic/expression.cpp:30871) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 601, in integrate return indefinite_integral(expression, v) File "function.pyx", line 419, in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4486) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/integral.py", line 85, in _eval_ res = integrator(f, x) File "/usr/lib/python2.6/site-packages/sage/symbolic/integration/external.py", line 19, in maxima_integrator result = maxima.sr_integral(expression,v) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 977, in sr_integral return max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args]))) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 1228, in max_to_sr args.append(max_to_sr(car(max_args))) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 1228, in max_to_sr args.append(max_to_sr(car(max_args))) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 1228, in max_to_sr args.append(max_to_sr(car(max_args))) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_lib.py", line 1221, in max_to_sr sage_expr=SR(maxima(expr)) File "parent.pyx", line 915, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6668) File "coerce_maps.pyx", line 156, in sage.structure.coerce_maps.NamedConvertMap._call_ (sage/structure/coerce_maps.c:4045) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_abstract.py", line 1373, in _symbolic_ return R(self._sage_()) File "/usr/lib/python2.6/site-packages/sage/interfaces/maxima_abstract.py", line 1354, in _sage_ maxima=self.parent()) File "/usr/lib/python2.6/site-packages/sage/calculus/calculus.py", line 1646, in symbolic_expression_from_maxima_string raise TypeError, "unable to make sense of Maxima expression '%s' in Sage"%s TypeError: unable to make sense of Maxima expression 'li[2]' in Sage
File "/usr/share/sage/devel/sage/sage/calculus/tests.py", line 151: sage: integrate(ceil(x^2 + floor(x)), x, 0, 5) # todo: Mathematica can do this Expected: integrate(ceil(x^2) + floor(x), x, 0, 5) Got: 155/3 ********************************************************************** File "/usr/share/sage/devel/sage/sage/calculus/tests.py", line 189: sage: integrate(sin(x), x, a, b) Expected: cos(a) - cos(b) Got: ceil(cos(a))
sage -t -force_lib "devel/sage/sage/calculus/interpolators.pyx" is actually unrelated to maxima I think.
comment:34 in reply to: ↑ 32 Changed 10 years ago by
Replying to fbissey:
ecl-10.4.1, maxima-5.23.2:
sage -t --verbose -force_lib "devel/sage/sage/functions/special.py" times out because it stops:Trying: elliptic_e(arccoth(Integer(1)), x**Integer(2)*e)###line 535:_sage_ >>> elliptic_e(arccoth(1), x^2*e) Expecting: elliptic_e(arccoth(1), x^2*e) The number 1 isn't in the domain of acoth
Hmm, this must have to do with 5.23.2, because "Here arccoth doesn't have 1 in its domain, so we just hold the expression:" in the past. So Maxima must have improved something here.
sage: integrate(ceil(x^2 + floor(x)), x, 0, 5) # todo: Mathematica can do this Expected: integrate(ceil(x^2) + floor(x), x, 0, 5) Got: 155/3
If this is right, that's good. No idea what's going on with the next one.
In general, I'm seeing a lot of stuff that's related to having the newer Maxima. I think that we should either upgrade Maxima first, and take care of things related to better error handling/functionality in Maxima, and then address this ticket separately, OR do this first with our current Maxima and then upgrade Maxima. My preference would be to upgrade Maxima first, assuming one can do that relatively easily (would ECL also have to be upgraded? It's annoying that one has to do them simultaneously at times, at least with some of my slower test machines.).
comment:35 Changed 10 years ago by
I will do another run of tests with maxima-5.22.1 later. It is not too hard to go from one version of maxima to another. At least you don't have to rebuild anything else.
But it definitely looks like upgrading maxima would be a good thing, we'll have to make a ticket about it.
comment:36 in reply to: ↑ 32 Changed 10 years ago by
Something blows up rather badly here. The MAXIMA>>
prompt indicates that you're dropped into to ECL debugger [the default behaviour of LISPs is to drop you into a debugger when an uncaught condition arises]. Ecllib tries to avoid this by executing any LISP code inside the LISP equivalent of try/except (being HANDLER-CASE). You can get tracebacks and code to see what is happening from the debugger (try ":h" to get help about the ECL debugger)
---------------------------------------------------------------------- | Sage Version 4.6.1, Release Date: 2011-01-11 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- Loading Sage library. Current Mercurial branch is: dev sage: elliptic_e(arccoth(1), x^2*e) The number 1 isn't in the domain of acoth -- an error. To debug this try: debugmode(true);
This is Maxima printing something on the STDOUT. We should be catching this before it gets printed! In other words, find which routine in maxima prints this and monkey-patch it to raise an error *before* printing this. Apparently, maxima does raise an error after printing this, which normally gets caught on maxima's top level. But since we decapitated maxima, we're getting that now, and that is where the next thing goes wrong:
Error in format: Unknown format directive. The number ~:M isn't in the domain of ~A ^ while processing indirect format string: ~? ^ No restarts available. Broken at LAMBDA. MAXIMA>> :b Backtrace: > LAMBDA > print-object > common-lisp-user::sage-safe-apply MAXIMA>> :le (LAMBDA (CONDITION STREAM) (FORMAT STREAM "~?" (SIMPLE-CONDITION-FORMAT-CONTROL CONDITION) (SIMPLE-CONDITION-FORMAT-ARGUMENTS CONDITION)))
so a FORMAT statement is failing here. Apparently "Condition" objects (roughly "exception" objects in python) can have a format string and items hanging off them. FORMAT is LISPs "printf", but with a much more baroque set of options. FORMAT format specifiers have been rumoured to be Turing complete. Let's look at the parameters:
MAXIMA>> (SIMPLE-CONDITION-FORMAT-CONTROL CONDITION) "The number ~:M isn't in the domain of ~A" MAXIMA>> (SIMPLE-CONDITION-FORMAT-ARGUMENTS CONDITION) NIL
So the "~:M" is probably a Maxima extension to format which is not accessible at the point where we are trying it. The fact that there are no arguments also indicates that Maxima might be forming a condition object that is not fit for general consumption.
Let's see where this error really arose by stepping further up in the backtrace:
MAXIMA>> :p Broken at PRINT-OBJECT. MAXIMA>> :le (SI:LAMBDA-BLOCK PRINT-OBJECT (SI::X STREAM) (DECLARE (TYPE SIMPLE-CONDITION SI::X) (SI::NO-CHECK-TYPE SI::X)) (IF *PRINT-ESCAPE* (CALL-NEXT-METHOD) ((LAMBDA (CONDITION STREAM) (FORMAT STREAM "~?" (SIMPLE-CONDITION-FORMAT-CONTROL CONDITION) (SIMPLE-CONDITION-FORMAT-ARGUMENTS CONDITION))) SI::X STREAM))) {{{ So this is LISP trying to print a CONDITION object. Apparently, Maxima has created a CONDITION object that doesn't allow this method to work. This could be a bug in ECL or it could be Maxima being non-compliant. }}} MAXIMA>> :p Broken at COMMON-LISP-USER::SAGE-SAFE-APPLY. MAXIMA>> :le (SI:LAMBDA-BLOCK COMMON-LISP-USER::SAGE-SAFE-APPLY (COMMON-LISP-USER::FUNC COMMON-LISP-USER::ARGS) (DECLARE (SI::C-GLOBAL)) (HANDLER-CASE (VALUES (APPLY COMMON-LISP-USER::FUNC COMMON-LISP-USER::ARGS)) (SERIOUS-CONDITION (COMMON-LISP-USER::CND) (VALUES NIL (PRINC-TO-STRING COMMON-LISP-USER::CND))))) MAXIMA>> COMMON-LISP-USER::FUNC MAXIMA-EVAL MAXIMA>> COMMON-LISP-USER::ARGS ((MEVAL* '((MSETQ) $SAGE1 (($ELLIPTIC_E) ((%ACOTH) 1) ((MTIMES) ((MEXPT) $X 2) ((%EXP) 1))))))
Finally we're at the ecllib level. SAGE-SAFE-APPLY is the way ecllib tries to execute LISP code As you can see, the arguments here indicate that this is the original call we started with, translated to maxima (well, the underlying LISP representation of maxima). We know this raised an error, which gets processed by the HANDLER-CASE/SERIOUS-CONDITION. The PRINC-TO-STRING tries to make a string rendition of the CONDITION object, which fails for the reasons we have seen above.
So, the most direct way to solve the problem is to monkey-patch Maxima to raise an acceptable error *instead* of printing a message and sending a CONDITION object that crashes PRINC (which should be a near-universal printing routine). This should be relatively straightforward, because that Maxima routine already produces an acceptable string. Simply produce that string but instead of printing it, do an (ERROR string) or whatever is acceptable (the way "retrieve" gets monkey-patched in maximalib is already an example of that).
It does make me a bit pessimistic, though: Maxima improves some of its error reporting and in the process immediately blows up our error catching! This looks like something that is going to happen every time Maxima changes something. It's bad enough when dealing with the pexpect interface, but in this case we're basically using an unsupported and undocumented API! I know Robert Dodier is definitely sympathetic to making Maxima usable as a library, so perhaps if we can get reasonable functionality, he might be willing to take into account the required hooks when changing Maxima.
comment:37 in reply to: ↑ description Changed 10 years ago by
I have looked a little into the error reporting and it looks like maxima was not creating the error that crashed ecllib's error string creation routine -- instead it was maxima-eval, the maxima "top level" replacement we run to catch and interpret maxima's error reporting. Maxima's error reporting hasn't changed since 1985. It just happened that this was the first time we stumbled into an error message that was not properly handled. The new patch "errorcatching.patch" (to be applied after all the "rebased" patches) fixes this.
We now get:
sage: arccoth(1).simplify() -- an error. To debug this try: debugmode(true); (result= MAXIMA-ERROR) ($error= ((MLIST) The number ~:M isn't in the domain of ~A 1 ACOTH)) TypeError: ECL says: The number 1 isn't in the domain of acoth sage: elliptic_e(arccoth(1), x^2*e) (result= (MAXIMA_EVAL . /usr/local/sage/4.6/local/share/maxima/5.22.1/share/orthopoly/orthopoly.lisp)) ($error= ((MLIST) The number ~:M isn't in the domain of ~A 1 ACOTH)) (result= (MAXIMA_EVAL)) ($error= ((MLIST) The number ~:M isn't in the domain of ~A 1 ACOTH)) -- an error. To debug this try: debugmode(true); (result= MAXIMA-ERROR) ($error= ((MLIST) The number ~:M isn't in the domain of ~A 1 ACOTH)) elliptic_e(arccoth(1), x^2*e)
So we see a bunch of things:
- printing the error has now been turned off, but a quick glance at the code shows that the message
-- an error. To debug this try: debugmode(true);
cannot be turned off. I regard that a bug in Maxima and we can consider reporting that. We could also just monkeypatch MERROR. - the error now gets properly reported
- there is a lot of junk diagnostic output generated by my fixed routine. Feel free to comment that back out.
- the actual simplification of elliptic_e (whatever is tried there) apparently is wrapped in a try/except and the error reported by ecl is nicely hidden and the result is left unchanged.
This should be closer to how sage handled this first.
comment:38 in reply to: ↑ description Changed 10 years ago by
The following doctest from calculus.py now goes wrong:
limit(-e^(x^2)*erf(x) + e^(x^2), x=oo)
Which stumbles at calculus.calculus.limit at these lines:
1122 return l.sage() 1123 return ex.parent()(l)
Two return statements??? A little hg -blame
points to #7661. Indeed, commenting out line 1122 fixes a lot of the limit problems. However, Burcin put in that line for a reason, I assume, so I'm hesitant to just commit a reversal.
Note that the issue of #7661 is exactly due to a namespace collapse from SR -> Maxima; something this interface could eventually solve much more elegantly, by just mapping (at no cost) SR.var('x') to the maxima identifier "sage_SR_var_x".
comment:39 follow-up: ↓ 40 Changed 10 years ago by
two return statements is indeed strange. Is the second return ever reached? Could it be a left over forgotten there? Looking at the code I am not sure what ex.parent()(l) is supposed to be. I haven't had time to test the errorcatching patch but will try ASAP. One of my testing friend noted that maxima as a lib and ecl compiled with thread support are not compatible (ever seen a SIGPWR?). I am mentioning that, in case it becomes the default in ecl in the future.
comment:40 in reply to: ↑ 39 ; follow-up: ↓ 43 Changed 10 years ago by
two return statements is indeed strange. Is the second return ever reached?
No, it isn't. However, Burcin apparently thought that l.sage()
would give better results. I'm actually thankful that he left in the original return statement because that served as a nice flag that something had changed there.
Could it be a left over forgotten there? Looking at the code I am not sure what ex.parent()(l) is supposed to be.
It is "Coerce l into the parent of ex", the original input parameter, i.e., coerce l into the Symbolic Ring. In the new code, "sr_limit" produces something that is hopefully *coercible* into the SymbolicRing? -- it probably isn't a maxima object at all anymore. I think in all cases it's better to coerce into SR instead of calling l.sage(): On maxima objects it should be about the same and if limit produces something that cannot be represented in the SymbolicRing? we should get an error. I'll ping him about it.
One of my testing friend noted that maxima as a lib and ecl compiled with thread support are not compatible (ever seen a SIGPWR?). I am mentioning that, in case it becomes the default in ecl in the future.
Good to know! A little googling found http://www.hpl.hp.com/personal/Hans_Boehm/gc/debugging.html It's the garbage collector that uses SIGXCPU and SIGPWR to synchronise cross-thread garbage collection. So if we want ecllib+threads we need to adjust the sage signal handler to properly handle those. BoehmGC is made for integration into C programs, so this may be doable.
comment:41 Changed 10 years ago by
Re-running sage -testall with maxima-lib enabled, ecl-10.4.1 maxima-5.22.1, sage-4.6.2_alpha3. Most of the time out have disappeared expect for three which at first sight are unrelated, but don't fail without maxima-lib
sage -t -force_lib devel/sage/sage/misc/randstate.pyx sage -t -force_lib devel/sage/sage/interfaces/psage.py sage -t -force_lib devel/sage/sage/interfaces/sage0.py
From the first one:
Trying: subsage = Sage()###line 134:_sage_ >>> subsage = Sage() Expecting nothing ok Trying: s = ZZ(subsage('initial_seed()'))###line 135:_sage_ >>> s = ZZ(subsage('initial_seed()')) Expecting nothing
And it hangs there.
I also have SIGFPE in the following
sage -t -force_lib "devel/sage/sage/functions/other.py" * sage -t -force_lib devel/sage/sage/functions/log.py * sage -t -force_lib devel/sage/sage/symbolic/constants.py sage -t -force_lib devel/sage/sage/symbolic/pynac.pyx sage -t -force_lib devel/sage/sage/rings/complex_number.pyx sage -t -force_lib devel/sage/sage/rings/real_double.pyx sage -t -force_lib devel/sage/sage/rings/real_mpfr.pyx sage -t -force_lib devel/sage/sage/libs/mpmath/utils.pyx sage -t -force_lib devel/sage/sage/libs/mpmath/ext_libmp.pyx sage -t -force_lib devel/sage/sage/libs/mpmath/ext_impl.pyx sage -t -force_lib devel/sage/sage/libs/mpmath/ext_main.pyx sage -t -force_lib devel/sage/sage/calculus/calculus.py * sage -t -force_lib devel/sage/sage/structure/element.pyx sage -t -force_lib devel/sage/sage/schemes/elliptic_curves/ell_point.py sage -t -force_lib devel/sage/sage/schemes/elliptic_curves/ell_generic.py *
The stars indicate where I also had some verbose out from maxima, usually ending with
($error= ((MLIST SIMP) No error.))
And there is quite few more. I am doing another run with the little correction in calculus.py to see if that solve some of them.
comment:42 Changed 10 years ago by
scrap the three time out. They still happen without maxima-lib I was mistaken.
comment:43 in reply to: ↑ 40 ; follow-up: ↓ 44 Changed 10 years ago by
Thank you all for working on this again. I hope this will also solve some of the long standing issues we had with the maxima interface, like setting domains for variables #6862, or recognizing special symbols #6882.
Replying to nbruin:
two return statements is indeed strange. Is the second return ever reached?
No, it isn't. However, Burcin apparently thought that
l.sage()
would give better results. I'm actually thankful that he left in the original return statement because that served as a nice flag that something had changed there.
It was clearly a mistake on my part to leave the second return statement. I'm glad it ended up being useful though.
I don't have much time these days to investigate this. So it would be great if someone can update me on the progress. Especially, when rebasing Robert's patch to split off the maxima interface, did you merge in the changes that were made to sage/interfaces/maxima.py in the meantime?
Could it be a left over forgotten there? Looking at the code I am not sure what ex.parent()(l) is supposed to be.
It is "Coerce l into the parent of ex", the original input parameter, i.e., coerce l into the Symbolic Ring. In the new code, "sr_limit" produces something that is hopefully *coercible* into the SymbolicRing? -- it probably isn't a maxima object at all anymore. I think in all cases it's better to coerce into SR instead of calling l.sage(): On maxima objects it should be about the same and if limit produces something that cannot be represented in the SymbolicRing? we should get an error. I'll ping him about it.
The operation we are using is conversion, not coercion. IMHO, the code for converting maxima objects (of any kind, pexpect or library) to Sage symbolics objects should be within the maxima objects. Most of this functionality is in sage/calculus/calculus.py at the moment, I would like to see that moved to sage/interfaces/maxima.py or it's variants.
Adding a .sage() method to maxima interface objects was a step in this direction. This method knows which lookup tables to use to convert functions, etc. from maxima back to Sage. The code for this function is simply
def _sage_(self): import sage.calculus.calculus as calculus return calculus.symbolic_expression_from_maxima_string(self.name(), maxima=self.parent())
around line 1775 of sage/interfaces/maxima.py. I would expect this to work for the library interface to maxima as well, since AFAIK, this is also string based ATM.
I am not quite sure what a conversion to the symbolic ring does for maxima interface objects. I don't expect it to have special behavior if the input is a maxima interface object. It would make sense, if it called the .sage() or ._sage_() methods of the argument though.
Sorry I can't be more helpful.
comment:44 in reply to: ↑ 43 Changed 10 years ago by
Thank you, Burcin. That is very useful information indeed.
I don't have much time these days to investigate this. So it would be great if someone can update me on the progress. Especially, when rebasing Robert's patch to split off the maxima interface, did you merge in the changes that were made to sage/interfaces/maxima.py in the meantime?
I'll leave that to JP
The operation we are using is conversion, not coercion. IMHO, the code for converting maxima objects (of any kind, pexpect or library) to Sage symbolics objects should be within the maxima objects. Most of this functionality is in sage/calculus/calculus.py at the moment, I would like to see that moved to sage/interfaces/maxima.py or it's variants.
OK, conversion indeed. Good to know there is a philosophy behind the change
Adding a .sage() method to maxima interface objects was a step in this direction. This method knows which lookup tables to use to convert functions, etc. from maxima back to Sage.
Ultimately, this model might fit better with maximalib, but currently it means some refactoring of what we already had (or just go back to the SR coercion)
around line 1775 of sage/interfaces/maxima.py. I would expect this to work for the library interface to maxima as well, since AFAIK, this is also string based ATM.
With the fastcalculus patch it is not, though. In principle one could try to polish the abstract_maxima and maxima_lib patches so that they give a drop-in string-based library interface to maxima, but I never really went that far. That would be (probably boring but) very well-defined project and might speed up adoption.
What happens with the current set of patches:
- a maxima_lib interface is made available that in principle should be a drop-in replacement for maxima (except that only one instance can exist)
- this interface adds some extra methods to get "under the hood" of objects:
(1) There is an .ecl() method that returns the underlying EclObject? (i.e., direct access to the LISP object implementing the maxima object)
(2) the maxima() method also accepts EclObjects? and returns the appropriate wrapper, so maxima(M.ecl()) and maxima(eclobject).ecl() are supposed to be the identity (In a strong sense: The python wrapped might change Id but the ecl object not) where defined.
(3) sr_to_max(), a method to translate an SR object into an EclObject? ready for wrapping in maxima.
(4) max_to_sr(), a method to translate an EclObject? representing a maxima expression to something in or coercible to SR. Note that maxima expressions can be lists, which should be translated into a python list of SR elements, so the mapping cannot be perfectly into SR.
(5) methods sr_limit, sr_sum, sr_integrate which expect arguments living in SR and return something convertible to SR
The idea is that (3) and (4) offer a way to go back and forth between SR and maxima without using strings. maxima(E) and maxima(sr_to_max(E)) should have the same result. Similarly, SR(M) and SR(max_to_sr(M.ecl())) should have the similar result. Under the hood, sr_to_max and max_to_sr keep mappings between SR symbols and their EclObject? counterparts. They build up these mappings via the string-based interface, but avoid strings once they know the mappings.
The methods in (5) were an attempt to make "compute limit/sum/integral via maxima" dependent on which maxima interface was in use. The old maxima-interface got stubs that just returned the result of calling the appropriate maxima expression, which returns a maxima expression, which is coercible into SR again.
The maxima-lib implementation uses sr_to_max and max_to_sr as much as possible and returns the result of a max_to_sr, so that should be coercible into SR as well.
Doing it this way (at the time) was the smallest change and left as much as possible in the calculus.limit routine. The general setup fits will in Burcin's philosophy, but is presently broken because the result of a max_to_sr likely doesn't have a .sage() method. An alternative would be to push the actual conversion of the answer to SR into the sr_limit routine as well. But then one would have to tell sr_limit into which SR the answer has to be pushed. (I guess expr.parent())
I think the _proper_ way to do all these computations is to construct a dummy_limit or a dummy_integral in SR first ("inert" limit and "inert" integral being the less opinionated synonyms), convert that to maxima (via sr_to_max or string-based), call the appropriate simplification on it there (note that sr_to_max will absolutely not do any simplification. It's just mapping over expression trees) and then pull the answer back via max_to_sr or string based.
To come up with a truly robust design for this (the present was just a first hack and proof-of-concept), people who know a lot about SR and the general calculus architecture need to be involved. I've tried to show with various examples on this ticket that you don't need to understand much of lisp to make sense of what happens in maxima. The sage side of this is really much more complicated than the maxima side. The ECL objects representing maxima expressions look messy and have a lot of parentheses, but have a very straightforward structure.
Finally for (4): I know maxima functions like li[n] and psi[n] are not translated yet, because recognising them means looking a bit deeper in the maxima constructs. This is straightforward to do. There may be more of these constructs. Whoever wrote the string-based converter probably knows them already, because there they need special treatment too.
comment:45 follow-up: ↓ 46 Changed 10 years ago by
- Description modified (diff)
comment:46 in reply to: ↑ 45 Changed 10 years ago by
doctesting on 4.6.1 yields failures in only 12 files, and most of these are just changed formatting of output, numerical noise because floats are now binarily copied rather than transcribed via decimal string representations, and because some errors get reported differently. (For ECL everything is a RuntimeError?, for instance).
List here:
devel/sage/sage/symbolic/assumptions.py
: "Assumption
is inconsistent" errors get reported differently
devel/sage/sage/symbolic/function_factory.py
: Serious issues with
translating FDerivative constructs (it doesn't work at the moment)
devel/sage/sage/symbolic/expression.pyx
: A strange
issue with (x*log(9)).simplify_log('all')
. Oddly,
(x*log(3/7)).simplify_log('all')
does behave correctly.
devel/sage/sage/symbolic/integration/integral.py
:
"Maxima asks a question" errors get reported differently, float issues
devel/sage/sage/interfaces/maxima.py
: "Maxima asks
a question" errors get reported differently. These doctests are wrong, because they test the maxima_lib interface via calculus, not a real maxima interface.
devel/sage/sage/interfaces/maxima_abstract.py
:
These doctests were never adapted
devel/sage/sage/calculus/calculus.py
: Whitespace
and nintegral reports failure differently.
devel/sage/sage/calculus/wester.py
: Looks like
correct answer, but differently collected.
devel/sage/sage/calculus/tests.py
: Odd errors. They seem to depend on
context. Perhaps assumptions that aren't properly forgotten or max_to_sr cache that gets spoilt?
devel/sage/sage/calculus/desolvers.py
: lots of
problems. The desolve interface probably needs treatment like the to_poly_solve routine.
devel/sage/sage/calculus/functional.py
: "Maxima
asks a question" gets reported differently
devel/sage/sage/symbolic/assumptions.py
:
Inconsistent assumptions get reported differently.
Most of these are a matter of changing the doctests to the generated answer, but a few serious issues remain.
comment:47 Changed 10 years ago by
David Kirkby and I have started to look at up updating ecl to 11.1.1 in #10766. From my own experiments some of this patch set will need rebasing if it goes in.
I will certainly test your new patch.
comment:48 Changed 10 years ago by
the lisp function retrieve
in maxima is responsible for asking questions, so we just monkey-patch it to throw an error with an informative message instead. The patch trac_7377-better-ask-error.patch improves the readability of this message by executing exactly the original code in retrieve, but wrapped in a (with-output-to-string (*standard-output*) ...)
. The method is generally applicable and may be useful in adapting other printing bits.
Oddly enough, this patch does not invalidate any additional doctests, but:
sage -t "devel/sage-devel/sage/interfaces/maxima_lib.py" ********************************************************************** Error: TAB character found.
so perhaps maxima inserts a TAB in the error message. Are TABs not allowed in doctest output?
(it looks like one gets produced and matched by a "..." in the doctest template). A sage -t --verbose
shows that no individual test fails.
comment:49 Changed 10 years ago by
I accidentally introduced a TAB by mistake in a doctest the other and it was flagged so I'd say it is not allowed. Good news, bad news time. David Kirkby and I are updating ecl to 11.1.1 and maxima to 5.23.2 in #10766 (ecl) and #10773 (maxima).
The bad news is that the current patches in this ticket will need rebasing again because of the patches I had to apply for ecl-11.1.1. Actually I wouldn't mind some input on #10766 as it seem to resurrect #6189.
comment:50 Changed 10 years ago by
I forgot I already posted about ecl. Anyway, Nils could you put in the description the list of patches to apply and in which order if it is relevant?
I mean, is the error_catching.patch still necessary with the 2 new patches?
comment:51 Changed 10 years ago by
Never mind. I'll just go to bed.
comment:52 Changed 10 years ago by
- Description modified (diff)
example package for how to accomplish said interface