sagemath/sage

Upgrade giac to 1.5.0-87

mkoeppe opened this issue · 49 comments

www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/

(from #29521)

Previous updates:

#26315 Upgrade to Giac 1.5
#28101 update giac to 1.5.0-63

Depends on #29521
Depends on #29171

CC: @antonio-rojas @dimpase @frederichan-IMJPRG @sagetrac-parisse @slel @infinity0 @saraedum @tobihan @timokau @kiwifb @mwageringel

Component: packages: standard

Keywords: giac

Work Issues: merge #29171

Author: Matthias Koeppe

Branch/Commit: eb7995f

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/29552

Dependencies: #29521

comment:2

1.6.0 is out, causing a few test failures:

age -t --long /usr/lib/python3.8/site-packages/sage/calculus/calculus.py
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/calculus/calculus.py", line 1534, in sage.calculus.calculus.laplace
Failed example:
    laplace(heaviside(t-1), t, s, algorithm='giac')
Expected:
    e^(-s)/s
Got:
    0
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/calculus/calculus.py", line 1548, in sage.calculus.calculus.laplace
Failed example:
    laplace(5*cos(3*t-2)*heaviside(t-2), t, s, algorithm='giac')
Expected:
    5*(s*cos(4)*e^(-2*s) - 3*e^(-2*s)*sin(4))/(s^2 + 9)
Got:
    0
**********************************************************************
1 item had failures:
   2 of  40 in sage.calculus.calculus.laplace
    [418 tests, 2 failures, 9.18 s]
sage -t --long /usr/lib/python3.8/site-packages/sage/interfaces/giac.py
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/interfaces/giac.py", line 41, in sage.interfaces.giac
Failed example:
    giac.factor('x^5 - y^5')
Expected:
    (x-y)*(x^4+x^3*y+x^2*y^2+x*y^3+y^4)
Got:
    (x-y)*(x^2+(-sqrt(5)+1)/2*x*y+y^2)*(x^2+(sqrt(5)+1)/2*x*y+y^2)
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/interfaces/giac.py", line 83, in sage.interfaces.giac
Failed example:
    giac('factor(x^5-1)')
Expected:
    (x-1)*(x^4+x^3+x^2+x+1)
Got:
    (x-1)*(x^2+(-sqrt(5)+1)/2*x+1)*(x^2+(sqrt(5)+1)/2*x+1)
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/interfaces/giac.py", line 95, in sage.interfaces.giac
Failed example:
    giac('(x^5-1)').factor()
Expected:
    (x-1)*(x^4+x^3+x^2+x+1)
Got:
    (x-1)*(x^2+(-sqrt(5)+1)/2*x+1)*(x^2+(sqrt(5)+1)/2*x+1)
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/interfaces/giac.py", line 626, in sage.interfaces.giac.Giac.eval
Failed example:
    giac(s)
Expected:
    (x)->[x+1,x+2]
Got:
    (x)->{ 
      x+1;  
      x+2;  
    }
**********************************************************************
File "/usr/lib/python3.8/site-packages/sage/interfaces/giac.py", line 995, in sage.interfaces.giac.GiacElement._latex_
Failed example:
    print(latex(giac('(x^4 - y)/(y^2-3*x)')))
Expected:
    "\frac{(x^{4}-y)}{(y^{2}-3\cdot x)}"
Got:
    "\frac{x^{4}-y}{y^{2}-3 x}"
**********************************************************************
3 items had failures:
   3 of  24 in sage.interfaces.giac
   1 of   6 in sage.interfaces.giac.Giac.eval
   1 of   2 in sage.interfaces.giac.GiacElement._latex_
    [167 tests, 5 failures, 3.34 s]
----------------------------------------------------------------------
sage -t --long /usr/lib/python3.8/site-packages/sage/calculus/calculus.py  # 2 doctests failed
sage -t --long /usr/lib/python3.8/site-packages/sage/interfaces/giac.py  # 5 doctests failed
----------------------------------------------------------------------

The ones in interfaces/giac.py just need the tests updated, the calculus/calculus.py failures are an upstream issue

1>> laplace(Heaviside(x-1),x,s)
Warning: piecewise indefinite integration does not return a continuous antiderivative
0
// Time 0
comment:3

For 1.6 with laplace I have reported it upstream on giac's forum:
https://xcas.univ-grenoble-alpes.fr/forum/viewtopic.php?f=3&t=2531

but for the sqrt(5) appearing in the doctests of giac.py I suspect some default configuration that is not dependent of the version of giac. Could it be that the user .xcasrc is taken into account?

Then I think it would be more natural to force the configuration to not use sqrt before the computation with:

sage: giac.with_sqrt(0);
NB: this function returns the previous value of this setting so in a doctest it is better to not print the answer)

comment:4

Replying to @frederichan-IMJPRG:

but for the sqrt(5) appearing in the doctests of giac.py I suspect some default configuration that is not dependent of the version of giac. Could it be that the user .xcasrc is taken into account?

downgrading giac makes those tests pass again, so there's definitely some change in 1.6 involved.

comment:5

Yes, it's an improvement, done for geogebra. Forcing the sqrt mode of Xcas to false should fix sage regression test, as explained by Frederic.
Laplace bug is fixed in my source tree, I will make a new release probably next week.

diff desolve.cc desolve.cc~
117c117
<     if (lop(res,at_integrate).empty() && lop(res,at_piecewise).empty() && lop(res,at_sign).empty())
---
>     if (lop(res,at_integrate).empty())
comment:7

Incidentally, with giac 1.5.0-63 on manylinux-2010-standard (from #30195), I get (https://github.com/kliem/sage/runs/908011984)

In file included from misc.cc:9275:
misc.cc: In function 'std::string giac::fetch(const string&)':
misc.cc:9289:28: error: 'CURLOPT_ACCEPT_ENCODING' was not declared in this scope
     curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "deflate");
                            ^~~~~~~~~~~~~~~~~~~~~~~
misc.cc:9289:28: note: suggested alternative: 'CURLOPT_ENCODING'

It should be checked whether this goes away with the update

comment:8

Yes, I do remember a problem with curl in an earlier giac. I believe it is fixed in 1.5.0-87+.

comment:9

Should we continue waiting for another 1.6 patch release or upgrade to latest 1.5.x in the meantime?

comment:10

I would be OK to move to 1.5.0-87 already.

Author: Matthias Koeppe

Commit: d2324a6

New commits:

d2324a6build/pkgs/giac: Update to 1.5.0.87
comment:13

Attachment: giac-1.5.0.87.tar.bz2.gz

Builds OK on macOS

comment:15

Updating doctests is probably better done together with #29541

comment:16

By the way, it seems that we don't install giac correctly (before or after this update):

$ giac --help
// Maximum number of parallel threads 1
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Help file /Applications/usr/share/giac/doc/en/aide_cas not found
Added 0 synonyms
Help file /Applications/usr/share/giac/aide_cas not found
:1: syntax error  line 1 col 1 at -- in --help  

undef
// dclock2 0.00015
// Time 0
// Total time 0
comment:17

Replying to @kiwifb:

You'll need https://github.com/cschwan/sage-on-gentoo/blob/master/sci-mathematics/sage/files/giac-1.5.0.87.patch for sage's doctests.

Let's see...

diff --git a/sage/interfaces/giac.py b/sage/interfaces/giac.py
index 68c9527..3c5fd12 100644
--- a/sage/interfaces/giac.py
+++ b/sage/interfaces/giac.py
@@ -990,7 +990,7 @@ class GiacElement(ExpectElement):
         EXAMPLES::
 
             sage: print(latex(giac('(x^4 - y)/(y^2-3*x)')))
-            "\frac{(x^{4}-y)}{(y^{2}-3\cdot x)}"
+            "\frac{x^{4}-y}{y^{2}-3 x}"
 
         """
         return self.parent().eval('latex(%s)'%self.name())

Before or after, this doctest makes no sense.

The _latex_ method is broken -- it adds quotation marks

sage: g = giac('(x^4 - y)/(y^2-3*x)')
sage: g
(x^4-y)/(y^2-3*x)
sage: s = g._sage_()
sage: s
(x^4 - y)/(y^2 - 3*x)
sage: latex(s)
\frac{x^{4} - y}{y^{2} - 3 \, x}
sage: latex(g)
"\frac{(x^{4}-y)}{(y^{2}-3\cdot x)}"

Is anyone using this interface at all?

comment:19

Replying to @mkoeppe:

Replying to @kiwifb:

You'll need https://github.com/cschwan/sage-on-gentoo/blob/master/sci-mathematics/sage/files/giac-1.5.0.87.patch for sage's doctests.

Let's see...

diff --git a/sage/interfaces/giac.py b/sage/interfaces/giac.py
index 68c9527..3c5fd12 100644
--- a/sage/interfaces/giac.py
+++ b/sage/interfaces/giac.py
@@ -990,7 +990,7 @@ class GiacElement(ExpectElement):
         EXAMPLES::
 
             sage: print(latex(giac('(x^4 - y)/(y^2-3*x)')))
-            "\frac{(x^{4}-y)}{(y^{2}-3\cdot x)}"
+            "\frac{x^{4}-y}{y^{2}-3 x}"
 
         """
         return self.parent().eval('latex(%s)'%self.name())

Before or after, this doctest makes no sense.

The _latex_ method is broken -- it adds quotation marks

sage: g = giac('(x^4 - y)/(y^2-3*x)')
sage: g
(x^4-y)/(y^2-3*x)
sage: s = g._sage_()
sage: s
(x^4 - y)/(y^2 - 3*x)
sage: latex(s)
\frac{x^{4} - y}{y^{2} - 3 \, x}
sage: latex(g)
"\frac{(x^{4}-y)}{(y^{2}-3\cdot x)}"

Is anyone using this interface at all?

I don't know :) - the pexpect interface and the optional giacpy_sage package are the only way to interact with giac right now. I cannot find anything linked with libgiac in sagelib.
But the latex interface in particular? I don't know. The latex spat out for that doctest is different in the currently shipped giac, 1.5.0-63 and 1.5.0-87.

Changed commit from d2324a6 to 0971326

Branch pushed to git repo; I updated commit sha1. New commits:

0971326sage.interfaces.giac.GiacElement._latex_: Fix implementation and doctest, make doctest more flexible

Changed commit from 0971326 to 8bbd056

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

5239d30build/pkgs/giac: Update to 1.5.0.87
8bbd056sage.interfaces.giac.GiacElement._latex_: Fix implementation and doctest, make doctest more flexible

Changed reviewer from https://github.com/mkoeppe/sage/actions/runs/202114883 to github.com/mkoeppe/sage/actions/runs/203238491

Changed commit from 8bbd056 to c076383

Branch pushed to git repo; I updated commit sha1. New commits:

c076383src/sage/interfaces/giac.py: Make new latex doctest more flexible
comment:25

Tests at https://github.com/mkoeppe/sage/actions/runs/203238491:

Clean on ubuntu-trusty-standard (https://github.com/mkoeppe/sage/runs/969005090) and fedora-32-standard (https://github.com/mkoeppe/sage/runs/969005556) except for doctest fixed in c076383.

Changed reviewer from github.com/mkoeppe/sage/actions/runs/203238491 to github.com/mkoeppe/sage/actions/runs/203238491, ...

comment:27

Needs review

comment:28

there is a strange behavior in this version of giac (I have tested with 1.5.0.85, 1.5.0.87 and 1.6.0.7)that breaks giacpy_sage doctests. (cf your comment 25 in #29171)
indeed the c++ _size function applied to the empty list seq[] doesn't return 0 as with giac 1.5.0.63 and earlier version but it returns some configuration setting.

Example: in icas len(seq[]) gives 0 with 1.5.0.63 but it now gives
[["atom","cplx","idnt","frac","vector","symb","strng","other","total"],[2,0,0,0,3,0,0,0,240]] with 1.5.0.87

I have reported it there https://xcas.univ-grenoble-alpes.fr/forum/viewtopic.php?f=3&t=2534#p11776 to know if this modification will remain or is a bug to know if we patch giac or adapt giacpy.

comment:29

OK, I guess we should hold off with this update.

comment:30

So the answer was that it is a modification usefull for very low memory systems (calculators). Whether or not these extra lines will be put inside an #ifdef in later versions of giac is still in discussion.
I guess we can let it as is

Changed dependencies from #29521 to #29521, #29171

Work Issues: merge #29171

Changed commit from c076383 to eb7995f

Branch pushed to git repo; I updated commit sha1. New commits:

4805622build/pkgs/giac/spkg-src: Patch with giac-1.5.0.87-gsl_lapack.patch; remove old giac autotools patches
1cec2e7build/pkgs/giac/spkg-install.in: Remove --disable-lapack
eb7995fbuild/pkgs/giac/dependencies: Add curl, glpk

Changed reviewer from github.com/mkoeppe/sage/actions/runs/203238491, ... to github.com/mkoeppe/sage/actions/runs/211389096, github.com/mkoeppe/sage/actions/runs/211389095, ...

Changed keywords from none to giac

comment:39

Needs review!

comment:40
$ giac
// Maximum number of parallel threads 1
Help file /Applications/usr/share/giac/aide_cas not found
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Help file /Applications/usr/share/giac/doc/en/aide_cas not found
Added 0 synonyms
Welcome to giac readline interface
(c) 2001,2018 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> 

something with keywords ? (This is on macOS 10.15).

comment:41

but linking to openblas is fixed, good.

comment:42

Replying to @dimpase:

$ giac
// Maximum number of parallel threads 1
Help file /Applications/usr/share/giac/aide_cas not found
// Unable to find keyword file /Applications/usr/share/giac/doc/en/keywords
Help file /Applications/usr/share/giac/doc/en/aide_cas not found
Added 0 synonyms
Welcome to giac readline interface
(c) 2001,2018 B. Parisse & others
Homepage http://www-fourier.ujf-grenoble.fr/~parisse/giac.html
Released under the GPL license 3.0 or above
See http://www.gnu.org for license details
May contain BSD licensed software parts (lapack, atlas, tinymt)
-------------------------------------------------
Press CTRL and D simultaneously to finish session
Type ?commandname for help
0>> 

something with keywords ? (This is on macOS 10.15).

Frederic indicates that these messages are not error messages. See #29171 comment:47

comment:43

Moreover, for the keyword message, I have tried on linux with parisse's debian package.
with LANG=C I have also the same (0 synonyms added)
with LANG=en_US I have 26 synonyms added but all are GUI related (turtle mode).
so I don't think that it is a problem.
so this ticket looks good to me.
tested on fedora fc30.x86_64 (make test was OK)

comment:44

ok

Changed reviewer from github.com/mkoeppe/sage/actions/runs/211389096, github.com/mkoeppe/sage/actions/runs/211389095, ... to Dima Pasechnik