Skip to content

Commit e70d9fe

Browse files
author
Release Manager
committed
gh-38770: Add "needs" tags for giac and libgiac Part of #38668. If it's going to be possible to disable giac, we need to guard all of the tests that use it with either `# needs giac` or `# needs sage.libs.giac`. I think I've gotten them all. A crude way to test: 1. `git rm -r src/sage/libs/giac` and rebuild to disable sage.libs.giac 2. build sage, and then delete the giac executable to disable the pexpect interface If you do these one at a time, it should ensure that the correct tags are used. (Typically, if giac is missing, neither sage.libs.giac nor the giac executable will be present, making it very easy to mix up the tags.) For bonus points you can undelete `src/sage/libs/giac` after building but before testing to make sure the "needs" tags in those files are accurate. ### Dependencies: * #38756 * #38686 (not strictly required, but it adds a few "needs sage.libs.giac" tags of its own) URL: #38770 Reported by: Michael Orlitzky Reviewer(s): Tobias Diez
2 parents 2be2d84 + 5127fd2 commit e70d9fe

19 files changed

+130
-68
lines changed

src/doc/en/prep/Calculus.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,9 @@ help it look nicer in the browser?
316316
- 1/10*(sqrt(5) - 3)*log(2*x^2 + x*(sqrt(5) - 1) + 2)/(sqrt(5) - 1)
317317
+ 1/5*log(x + 1)
318318

319-
Some integrals are a little tricky, of course. Sage tries hard to integrate using Maxima, Giac and Sympy::
319+
Some integrals are a little tricky, of course. Sage tries hard to integrate using Maxima, Sympy, and (optionally, if installed) Giac. The following can only be integrated by Giac::
320320

321+
sage: # needs sage.libs.giac
321322
sage: integral(1/(1+x^10),x)
322323
...1/20*(sqrt(5) + 1)*arctan((4*x + sqrt(-2*sqrt(5) + 10))/(sqrt(5) + 1))
323324
+ 1/20*(sqrt(5) + 1)*arctan((4*x - sqrt(-2*sqrt(5) + 10))/(sqrt(5) + 1))

src/sage/calculus/calculus.py

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@
385385
2*pi
386386
387387
Ensure that :issue:`25626` is fixed. As the form of the answer is dependent of
388-
the giac version, we simplify it (see :issue:`34037`). ::
388+
the giac version, we simplify it (see :issue:`34037`)::
389389
390390
sage: t = SR.var('t')
391391
sage: integrate(exp(t)/(t + 1)^2, t, algorithm='giac').full_simplify()
@@ -568,6 +568,7 @@ def symbolic_sum(expression, v, a, b, algorithm='maxima', hold=False):
568568
569569
An example of this summation with Giac::
570570
571+
sage: # needs giac
571572
sage: symbolic_sum(1/(1+k^2), k, -oo, oo, algorithm='giac').factor()
572573
pi*(e^(2*pi) + 1)/((e^pi + 1)*(e^pi - 1))
573574
@@ -843,7 +844,7 @@ def symbolic_product(expression, v, a, b, algorithm='maxima', hold=False):
843844
844845
- ``'maxima'`` -- use Maxima (the default)
845846
846-
- ``'giac'`` -- use Giac
847+
- ``'giac'`` -- use Giac (optional)
847848
848849
- ``'sympy'`` -- use SymPy
849850
@@ -1296,7 +1297,7 @@ def limit(ex, dir=None, taylor=False, algorithm='maxima', **argv):
12961297
12971298
With the standard package Giac::
12981299
1299-
sage: from sage.libs.giac.giac import libgiac # random
1300+
sage: # needs sage.libs.giac
13001301
sage: (exp(-x)/(2+sin(x))).limit(x=oo, algorithm='giac')
13011302
0
13021303
sage: limit(e^(-1/x), x=0, dir='right', algorithm='giac')
@@ -1564,7 +1565,7 @@ def laplace(ex, t, s, algorithm='maxima'):
15641565
15651566
- ``'sympy'`` -- use SymPy
15661567
1567-
- ``'giac'`` -- use Giac
1568+
- ``'giac'`` -- use Giac (optional)
15681569
15691570
.. NOTE::
15701571
@@ -1668,7 +1669,7 @@ def laplace(ex, t, s, algorithm='maxima'):
16681669
(0, True)
16691670
sage: F # random - sympy <1.9 includes undefined heaviside(0) in answer
16701671
1
1671-
sage: laplace(dirac_delta(t), t, s, algorithm='giac')
1672+
sage: laplace(dirac_delta(t), t, s, algorithm='giac') # needs giac
16721673
1
16731674
16741675
Heaviside step function can be handled with different interfaces.
@@ -1677,8 +1678,9 @@ def laplace(ex, t, s, algorithm='maxima'):
16771678
sage: laplace(heaviside(t-1), t, s)
16781679
e^(-s)/s
16791680
1680-
Try with giac::
1681+
Try with giac, if it is installed::
16811682
1683+
sage: # needs giac
16821684
sage: laplace(heaviside(t-1), t, s, algorithm='giac')
16831685
e^(-s)/s
16841686
@@ -1691,6 +1693,7 @@ def laplace(ex, t, s, algorithm='maxima'):
16911693
16921694
Testing Giac::
16931695
1696+
sage: # needs giac
16941697
sage: var('t, s')
16951698
(t, s)
16961699
sage: laplace(5*cos(3*t-2)*heaviside(t-2), t, s, algorithm='giac')
@@ -1699,13 +1702,14 @@ def laplace(ex, t, s, algorithm='maxima'):
16991702
Check unevaluated expression from Giac (it is locale-dependent, see
17001703
:issue:`22833`)::
17011704
1702-
sage: var('n')
1703-
n
1705+
sage: # needs giac
1706+
sage: n = SR.var('n')
17041707
sage: laplace(t^n, t, s, algorithm='giac')
17051708
laplace(t^n, t, s)
17061709
17071710
Testing SymPy::
17081711
1712+
sage: n = SR.var('n')
17091713
sage: F, a, cond = laplace(t^n, t, s, algorithm='sympy')
17101714
sage: a, cond
17111715
(0, re(n) > -1)
@@ -1806,7 +1810,7 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
18061810
18071811
- ``'sympy'`` -- use SymPy
18081812
1809-
- ``'giac'`` -- use Giac
1813+
- ``'giac'`` -- use Giac (optional)
18101814
18111815
.. SEEALSO::
18121816
@@ -1843,11 +1847,13 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
18431847
18441848
The same instance with Giac::
18451849
1850+
sage: # needs giac
18461851
sage: inverse_laplace(1/s^2*exp(-s), s, t, algorithm='giac')
18471852
(t - 1)*heaviside(t - 1)
18481853
18491854
Transform a rational expression::
18501855
1856+
sage: # needs giac
18511857
sage: inverse_laplace((2*s^2*exp(-2*s) - exp(-s))/(s^3+1), s, t,
18521858
....: algorithm='giac')
18531859
-1/3*(sqrt(3)*e^(1/2*t - 1/2)*sin(1/2*sqrt(3)*(t - 1))
@@ -1864,7 +1870,7 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
18641870
dirac_delta(t)
18651871
sage: inverse_laplace(1, s, t, algorithm='sympy')
18661872
dirac_delta(t)
1867-
sage: inverse_laplace(1, s, t, algorithm='giac')
1873+
sage: inverse_laplace(1, s, t, algorithm='giac') # needs giac
18681874
dirac_delta(t)
18691875
18701876
TESTS:
@@ -1878,6 +1884,7 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
18781884
18791885
Testing Giac::
18801886
1887+
sage: # needs giac
18811888
sage: inverse_laplace(exp(-s)/s, s, t, algorithm='giac')
18821889
heaviside(t - 1)
18831890
@@ -1888,12 +1895,14 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
18881895
18891896
Testing unevaluated expression from Giac::
18901897
1891-
sage: n = var('n')
1898+
sage: # needs giac
1899+
sage: n = SR.var('n')
18921900
sage: inverse_laplace(1/s^n, s, t, algorithm='giac')
18931901
ilt(1/(s^n), t, s)
18941902
18951903
Try with Maxima::
18961904
1905+
sage: n = SR.var('n')
18971906
sage: inverse_laplace(1/s^n, s, t, algorithm='maxima')
18981907
ilt(1/(s^n), s, t)
18991908
@@ -1909,6 +1918,7 @@ def inverse_laplace(ex, s, t, algorithm='maxima'):
19091918
19101919
Testing the same with Giac::
19111920
1921+
sage: # needs giac
19121922
sage: inverse_laplace(cos(s), s, t, algorithm='giac')
19131923
ilt(cos(s), t, s)
19141924
"""
@@ -2472,13 +2482,18 @@ def _find_var(name, interface=None):
24722482
24732483
EXAMPLES::
24742484
2475-
sage: y = var('y')
2485+
sage: y = SR.var('y')
24762486
sage: sage.calculus.calculus._find_var('y')
24772487
y
24782488
sage: sage.calculus.calculus._find_var('I')
24792489
I
24802490
sage: sage.calculus.calculus._find_var(repr(maxima(y)), interface='maxima')
24812491
y
2492+
2493+
::
2494+
2495+
sage: # needs giac
2496+
sage: y = SR.var('y')
24822497
sage: sage.calculus.calculus._find_var(repr(giac(y)), interface='giac')
24832498
y
24842499
"""
@@ -2585,6 +2600,7 @@ def symbolic_expression_from_string(s, syms=None, accept_sequence=False, *, pars
25852600
25862601
The Giac interface uses a different parser (:issue:`30133`)::
25872602
2603+
sage: # needs giac
25882604
sage: from sage.calculus.calculus import SR_parser_giac
25892605
sage: symbolic_expression_from_string(repr(giac(SR.var('e'))), parser=SR_parser_giac)
25902606
e

src/sage/calculus/functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def simplify(f, algorithm='maxima', **kwds):
5353
sage: ex = 1/2*I*x + 1/2*I*sqrt(x^2 - 1) + 1/2/(I*x + I*sqrt(x^2 - 1))
5454
sage: simplify(ex)
5555
1/2*I*x + 1/2*I*sqrt(x^2 - 1) + 1/(2*I*x + 2*I*sqrt(x^2 - 1))
56-
sage: simplify(ex, algorithm='giac')
56+
sage: simplify(ex, algorithm='giac') # needs giac
5757
I*sqrt(x^2 - 1)
5858
"""
5959
try:

src/sage/functions/exp_integral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def __init__(self):
800800
Si(x)
801801
sage: sin_integral(x)._fricas_init_()
802802
'Si(x)'
803-
sage: sin_integral(x)._giac_() # needs sage.libs.giac
803+
sage: sin_integral(x)._giac_() # needs giac
804804
Si(sageVARx)
805805
"""
806806
BuiltinFunction.__init__(self, "sin_integral", nargs=1,
@@ -975,7 +975,7 @@ def __init__(self):
975975
Ci(x)
976976
sage: cos_integral(x)._fricas_init_()
977977
'Ci(x)'
978-
sage: cos_integral(x)._giac_() # needs sage.libs.giac
978+
sage: cos_integral(x)._giac_() # needs giac
979979
Ci(sageVARx)
980980
"""
981981
BuiltinFunction.__init__(self, "cos_integral", nargs=1,

src/sage/functions/generalized.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def __init__(self):
253253
H\left(x\right)
254254
sage: heaviside(x)._sympy_() # needs sympy
255255
Heaviside(x)
256-
sage: heaviside(x)._giac_() # needs sage.libs.giac
256+
sage: heaviside(x)._giac_() # needs giac
257257
Heaviside(sageVARx)
258258
sage: h(x) = heaviside(x)
259259
sage: h(pi).numerical_approx()
@@ -413,7 +413,7 @@ class FunctionSignum(BuiltinFunction):
413413
sign(x)
414414
sage: sgn(x)._fricas_init_() # needs sage.symbolic
415415
'(x+->abs(x)/x)(x)'
416-
sage: sgn(x)._giac_() # needs sage.libs.giac sage.symbolic
416+
sage: sgn(x)._giac_() # needs giac sage.symbolic
417417
sign(sageVARx)
418418
419419
Test for :issue:`31085`::

src/sage/functions/other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ def __init__(self):
18601860
sage: isinstance(r.operator(), # known bug # needs sympy
18611861
....: sage.functions.other.Function_prod)
18621862
True
1863-
sage: giac(sprod(m, m, 1, n)).sage()
1863+
sage: giac(sprod(m, m, 1, n)).sage() # needs giac
18641864
factorial(n)
18651865
"""
18661866
BuiltinFunction.__init__(self, "product", nargs=4,

src/sage/functions/piecewise.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,16 +1470,18 @@ def _giac_init_(self, parameters, variable):
14701470
14711471
EXAMPLES::
14721472
1473+
sage: # needs giac
14731474
sage: ex = piecewise([((0, 1), pi), ([1, 2], x)])
1474-
sage: f = ex._giac_(); f # needs sage.libs.giac
1475+
sage: f = ex._giac_(); f
14751476
piecewise(((sageVARx>0) and (1>sageVARx)),pi,((sageVARx>=1) and (2>=sageVARx)),sageVARx)
1476-
sage: f.diff(x) # needs sage.libs.giac
1477+
sage: f.diff(x)
14771478
piecewise(((sageVARx>0) and (1>sageVARx)),0,((sageVARx>=1) and (2>=sageVARx)),1)
14781479
1479-
sage: ex = piecewise([((-100, -2), 1/x), ((1, +oo), cos(x))]) # needs sage.libs.giac
1480-
sage: g = ex._giac_(); g # needs sage.libs.giac
1480+
sage: # needs giac
1481+
sage: ex = piecewise([((-100, -2), 1/x), ((1, +oo), cos(x))])
1482+
sage: g = ex._giac_(); g
14811483
piecewise(((sageVARx>-100) and ((-2)>sageVARx)),1/sageVARx,sageVARx>1,cos(sageVARx))
1482-
sage: g.diff(x) # needs sage.libs.giac
1484+
sage: g.diff(x)
14831485
piecewise(((sageVARx>-100) and ((-2)>sageVARx)),-1/sageVARx^2,sageVARx>1,-sin(sageVARx))
14841486
14851487
TESTS::

src/sage/interfaces/giac.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs giac
12
r"""
23
Pexpect Interface to Giac
34

src/sage/interfaces/interface.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def __call__(self, x, name=None):
275275
276276
Check conversion of Booleans (:issue:`28705`)::
277277
278-
sage: giac(True)
278+
sage: giac(True) # needs giac
279279
true
280280
sage: maxima(True)
281281
true
@@ -343,7 +343,7 @@ def _coerce_impl(self, x, use_special=True):
343343
344344
Check that python type ``complex`` can be converted (:issue:`31775`)::
345345
346-
sage: giac(complex(I))**2 # should not return `j^2`
346+
sage: giac(complex(I))**2 # should not return `j^2` # needs giac
347347
-1
348348
"""
349349
if isinstance(x, bool):
@@ -1196,12 +1196,12 @@ def _repr_(self):
11961196
sage: gap(2)
11971197
2
11981198
sage: x = var('x')
1199-
sage: giac(x)
1199+
sage: giac(x) # needs giac
12001200
sageVARx
1201-
sage: giac(5)
1201+
sage: giac(5) # needs giac
12021202
5
12031203
sage: M = matrix(QQ,2,range(4))
1204-
sage: giac(M)
1204+
sage: giac(M) # needs giac
12051205
[[0,1],[2,3]]
12061206
sage: x = var('x') # optional - maple
12071207
sage: maple(x) # optional - maple
@@ -1341,7 +1341,7 @@ def __bool__(self):
13411341
By default this returns ``True`` for elements that are considered to be
13421342
not ``False`` by the interface (:issue:`28705`)::
13431343
1344-
sage: bool(giac('"a"'))
1344+
sage: bool(giac('"a"')) # needs giac
13451345
True
13461346
"""
13471347
P = self._check_valid()

src/sage/libs/giac/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.libs.giac
12
"""
23
Wrappers for Giac functions
34

src/sage/libs/giac/giac.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.libs.giac
12
# distutils: libraries = giac
23
# distutils: language = c++
34
# distutils: extra_compile_args = -std=c++11

src/sage/matrix/matrix1.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ cdef class Matrix(Matrix0):
216216
EXAMPLES::
217217
218218
sage: M = matrix(ZZ, 2, range(4))
219-
sage: giac(M) # needs sage.libs.giac
219+
sage: giac(M) # needs giac
220220
[[0,1],[2,3]]
221221
222222
sage: M = matrix(QQ, 3, [1,2,3, 4/3,5/3,6/4, 7,8,9])
223-
sage: giac(M) # needs sage.libs.giac
223+
sage: giac(M) # needs giac
224224
[[1,2,3],[4/3,5/3,3/2],[7,8,9]]
225225
226226
sage: P.<x> = ZZ[]
227227
sage: M = matrix(P, 2, [-9*x^2-2*x+2, x-1, x^2+8*x, -3*x^2+5])
228-
sage: giac(M) # needs sage.libs.giac
228+
sage: giac(M) # needs giac
229229
[[-9*sageVARx^2-2*sageVARx+2,sageVARx-1],[sageVARx^2+8*sageVARx,-3*sageVARx^2+5]]
230230
231231
sage: y = var('y') # needs sage.symbolic
232232
sage: M = matrix(SR, 2, [y+sin(y), y - 4, 1/y, dilog(y)]) # needs sage.symbolic
233-
sage: giac(M).det().sage() # needs sage.libs.giac sage.symbolic
233+
sage: giac(M).det().sage() # needs giac sage.symbolic
234234
(y^2*dilog(y) + y*dilog(y)*sin(y) - y + 4)/y
235235
"""
236236
s = ','.join('[' + ','.join(cf._giac_init_() for cf in row) + ']'

src/sage/modules/free_module_element.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,20 +1007,20 @@ cdef class FreeModuleElement(Vector): # abstract base class
10071007
EXAMPLES::
10081008
10091009
sage: v = vector(ZZ, 4, range(4))
1010-
sage: giac(v) + v # needs sage.libs.giac
1010+
sage: giac(v) + v # needs giac
10111011
[0,2,4,6]
10121012
10131013
::
10141014
10151015
sage: v = vector(QQ, 3, [2/3, 0, 5/4])
1016-
sage: giac(v) # needs sage.libs.giac
1016+
sage: giac(v) # needs giac
10171017
[2/3,0,5/4]
10181018
10191019
::
10201020
10211021
sage: P.<x> = ZZ[]
10221022
sage: v = vector(P, 3, [x^2 + 2, 2*x + 1, -2*x^2 + 4*x])
1023-
sage: giac(v) # needs sage.libs.giac
1023+
sage: giac(v) # needs giac
10241024
[sageVARx^2+2,2*sageVARx+1,-2*sageVARx^2+4*sageVARx]
10251025
"""
10261026
return self.list()

src/sage/rings/polynomial/multi_polynomial.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ cdef class MPolynomial(CommutativePolynomial):
11141114
11151115
TESTS::
11161116
1117-
sage: # needs sage.libs.giac
1117+
sage: # needs giac
11181118
sage: R.<x,y,z> = GF(101)['e,i'][]
11191119
sage: f = R('e*i') * x + y^2
11201120
sage: f._giac_init_()

0 commit comments

Comments
 (0)