Skip to content

Commit ab8ee47

Browse files
author
Release Manager
committed
gh-40736: Clean up symbolic min max doctests Add one `# long time` to fix some CI warnings, and move `# needs sage.symbolic` to the top level. URL: #40736 Reported by: Michael Orlitzky Reviewer(s): Frédéric Chapoton
2 parents 79623d0 + 70842af commit ab8ee47

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

src/sage/functions/min_max.py

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs sage.symbolic
12
r"""
23
Symbolic minimum and maximum
34
@@ -7,16 +8,15 @@
78
89
Here you can see some differences::
910
10-
sage: max(x, x^2) # needs sage.symbolic
11+
sage: max(x, x^2)
1112
x
12-
sage: max_symbolic(x, x^2) # needs sage.symbolic
13+
sage: max_symbolic(x, x^2)
1314
max(x, x^2)
14-
sage: f(x) = max_symbolic(x, x^2); f(1/2) # needs sage.symbolic
15+
sage: f(x) = max_symbolic(x, x^2); f(1/2)
1516
1/2
1617
1718
This works as expected for more than two entries::
1819
19-
sage: # needs sage.symbolic
2020
sage: max(3, 5, x)
2121
5
2222
sage: min(3, 5, x)
@@ -48,7 +48,6 @@ def eval_helper(self, this_f, builtin_f, initial_val, args):
4848
"""
4949
EXAMPLES::
5050
51-
sage: # needs sage.symbolic
5251
sage: max_symbolic(3, 5, x) # indirect doctest
5352
max(x, 5)
5453
sage: max_symbolic([5.0r]) # indirect doctest
@@ -93,20 +92,20 @@ def __call__(self, *args, **kwds):
9392
"""
9493
EXAMPLES::
9594
96-
sage: max_symbolic(3, 5, x) # needs sage.symbolic
95+
sage: max_symbolic(3, 5, x)
9796
max(x, 5)
98-
sage: max_symbolic(3, 5, x, hold=True) # needs sage.symbolic
97+
sage: max_symbolic(3, 5, x, hold=True)
9998
max(3, 5, x)
100-
sage: max_symbolic([3, 5, x]) # needs sage.symbolic
99+
sage: max_symbolic([3, 5, x])
101100
max(x, 5)
102101
103102
::
104103
105-
sage: min_symbolic(3, 5, x) # needs sage.symbolic
104+
sage: min_symbolic(3, 5, x)
106105
min(x, 3)
107-
sage: min_symbolic(3, 5, x, hold=True) # needs sage.symbolic
106+
sage: min_symbolic(3, 5, x, hold=True)
108107
min(3, 5, x)
109-
sage: min_symbolic([3, 5, x]) # needs sage.symbolic
108+
sage: min_symbolic([3, 5, x])
110109
min(x, 3)
111110
112111
TESTS:
@@ -120,7 +119,6 @@ def __call__(self, *args, **kwds):
120119
121120
Check if a single argument which is not iterable works::
122121
123-
sage: # needs sage.symbolic
124122
sage: max_symbolic(None)
125123
Traceback (most recent call last):
126124
...
@@ -161,13 +159,13 @@ def __init__(self):
161159
r"""
162160
Symbolic `\max` function.
163161
164-
The Python builtin :func:`max` function does not work as expected when symbolic
165-
expressions are given as arguments. This function delays evaluation
166-
until all symbolic arguments are substituted with values.
162+
The Python builtin :func:`max` function does not work as
163+
expected when symbolic expressions are given as
164+
arguments. This function delays evaluation until all symbolic
165+
arguments are substituted with values.
167166
168167
EXAMPLES::
169168
170-
sage: # needs sage.symbolic
171169
sage: max_symbolic(3, x)
172170
max(3, x)
173171
sage: max_symbolic(3, x).subs(x=5)
@@ -179,11 +177,11 @@ def __init__(self):
179177
180178
TESTS::
181179
182-
sage: loads(dumps(max_symbolic(x, 5))) # needs sage.symbolic
180+
sage: loads(dumps(max_symbolic(x, 5)))
183181
max(x, 5)
184-
sage: latex(max_symbolic(x, 5)) # needs sage.symbolic
182+
sage: latex(max_symbolic(x, 5))
185183
\max\left(x, 5\right)
186-
sage: max_symbolic(x, 5)._sympy_() # needs sympy sage.symbolic
184+
sage: max_symbolic(x, 5)._sympy_() # needs sympy
187185
Max(5, x)
188186
"""
189187
BuiltinFunction.__init__(self, 'max', nargs=0, latex_name=r"\max",
@@ -193,7 +191,6 @@ def _eval_(self, *args):
193191
"""
194192
EXAMPLES::
195193
196-
sage: # needs sage.symbolic
197194
sage: t = max_symbolic(x, 5); t
198195
max(x, 5)
199196
sage: t.subs(x=3) # indirect doctest
@@ -222,7 +219,6 @@ def _evalf_(self, *args, **kwds):
222219
"""
223220
EXAMPLES::
224221
225-
sage: # needs sage.symbolic
226222
sage: t = max_symbolic(sin(x), cos(x))
227223
sage: t.subs(x=1).n(200)
228224
0.84147098480789650665250232163029899962256306079837106567275
@@ -239,10 +235,11 @@ def _evalf_(self, *args, **kwds):
239235
We can usually integrate these expressions, but can't
240236
guarantee a symbolic answer in closed form::
241237
242-
sage: f = max_symbolic(sin(x), cos(x)) # needs sage.symbolic
243-
sage: r = integral(f, x, 0, 1) # needs sage.symbolic
238+
sage: # long time
239+
sage: f = max_symbolic(sin(x), cos(x))
240+
sage: r = integral(f, x, 0, 1)
244241
...
245-
sage: r.n() # abs tol 1e-8 # needs sage.symbolic
242+
sage: r.n() # abs tol 1e-8
246243
0.873911256504955
247244
"""
248245
return max_symbolic(args)
@@ -262,7 +259,6 @@ def __init__(self):
262259
263260
EXAMPLES::
264261
265-
sage: # needs sage.symbolic
266262
sage: min_symbolic(3, x)
267263
min(3, x)
268264
sage: min_symbolic(3, x).subs(x=5)
@@ -274,11 +270,11 @@ def __init__(self):
274270
275271
TESTS::
276272
277-
sage: loads(dumps(min_symbolic(x, 5))) # needs sage.symbolic
273+
sage: loads(dumps(min_symbolic(x, 5)))
278274
min(x, 5)
279-
sage: latex(min_symbolic(x, 5)) # needs sage.symbolic
275+
sage: latex(min_symbolic(x, 5))
280276
\min\left(x, 5\right)
281-
sage: min_symbolic(x, 5)._sympy_() # needs sympy sage.symbolic
277+
sage: min_symbolic(x, 5)._sympy_() # needs sympy
282278
Min(5, x)
283279
"""
284280
BuiltinFunction.__init__(self, 'min', nargs=0, latex_name=r"\min",
@@ -288,7 +284,6 @@ def _eval_(self, *args):
288284
"""
289285
EXAMPLES::
290286
291-
sage: # needs sage.symbolic
292287
sage: t = min_symbolic(x, 5); t
293288
min(x, 5)
294289
sage: t.subs(x=3) # indirect doctest
@@ -317,7 +312,6 @@ def _evalf_(self, *args, **kwds):
317312
"""
318313
EXAMPLES::
319314
320-
sage: # needs sage.symbolic
321315
sage: t = min_symbolic(sin(x), cos(x))
322316
sage: t.subs(x=1).n(200)
323317
0.54030230586813971740093660744297660373231042061792222767010

0 commit comments

Comments
 (0)