Skip to content

Commit d150b9a

Browse files
author
Release Manager
committed
gh-36037: `sage.typeset`: Update `# needs` <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> <!-- Why is this change required? What problem does it solve? --> - Cherry-picked from #35095 - Part of #29705 <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36037 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents b268272 + ac69da3 commit d150b9a

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/sage/typeset/ascii_art.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
n *log(x)
2727
---------
2828
pi
29-
sage: ascii_art(list(Partitions(6)))
29+
sage: ascii_art(list(Partitions(6))) # needs sage.combinat sage.libs.flint
3030
[ * ]
3131
[ ** * ]
3232
[ *** ** * * ]
@@ -232,21 +232,21 @@ def ascii_art(*obj, **kwds):
232232
We can specify a separator object::
233233
234234
sage: ident = lambda n: identity_matrix(ZZ, n)
235-
sage: ascii_art(ident(1), ident(2), ident(3), sep=' : ')
235+
sage: ascii_art(ident(1), ident(2), ident(3), sep=' : ') # needs sage.modules
236236
[1 0 0]
237237
[1 0] [0 1 0]
238238
[1] : [0 1] : [0 0 1]
239239
240240
We can specify the baseline::
241241
242-
sage: ascii_art(ident(2), baseline=-1) + ascii_art(ident(3))
242+
sage: ascii_art(ident(2), baseline=-1) + ascii_art(ident(3)) # needs sage.modules
243243
[1 0][1 0 0]
244244
[0 1][0 1 0]
245245
[0 0 1]
246246
247247
We can determine the baseline of the separator::
248248
249-
sage: ascii_art(ident(1), ident(2), ident(3), sep=' -- ', sep_baseline=-1)
249+
sage: ascii_art(ident(1), ident(2), ident(3), sep=' -- ', sep_baseline=-1) # needs sage.modules
250250
[1 0 0]
251251
-- [1 0] -- [0 1 0]
252252
[1] [0 1] [0 0 1]
@@ -255,7 +255,7 @@ def ascii_art(*obj, **kwds):
255255
an ascii art separator::
256256
257257
sage: sep_line = ascii_art('\n'.join(' | ' for _ in range(6)), baseline=6)
258-
sage: ascii_art(*Partitions(6), separator=sep_line, sep_baseline=0)
258+
sage: ascii_art(*Partitions(6), separator=sep_line, sep_baseline=0) # needs sage.combinat sage.libs.flint
259259
| | | | | | | | | | *
260260
| | | | | | | | | ** | *
261261
| | | | | | *** | | ** | * | *

src/sage/typeset/character_art.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ def __format__(self, fmt):
161161
162162
EXAMPLES::
163163
164-
sage: M = matrix([[1,2],[3,4]])
165-
sage: format(ascii_art(M))
164+
sage: M = matrix([[1,2],[3,4]]) # needs sage.modules
165+
sage: format(ascii_art(M)) # needs sage.modules
166166
'[1 2]\n[3 4]'
167-
sage: format(unicode_art(M))
167+
sage: format(unicode_art(M)) # needs sage.modules
168168
'\u239b1 2\u239e\n\u239d3 4\u23a0'
169169
"""
170170
return format(self._string_type(self), fmt)

src/sage/typeset/character_art_factory.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ def build(self, obj, baseline=None):
8484
8585
EXAMPLES::
8686
87-
sage: result = ascii_art(integral(exp(x+x^2)/(x+1), x))
87+
sage: result = ascii_art(integral(exp(x+x^2)/(x+1), x)) # needs sage.symbolic
8888
...
89-
sage: result
89+
sage: result # needs sage.symbolic
9090
/
9191
|
9292
| 2
@@ -99,14 +99,14 @@ def build(self, obj, baseline=None):
9999
100100
TESTS::
101101
102-
sage: n = var('n')
103-
sage: ascii_art(sum(binomial(2 * n, n + 1) * x^n, n, 0, oo))
102+
sage: n = var('n') # needs sage.symbolic
103+
sage: ascii_art(sum(binomial(2 * n, n + 1) * x^n, n, 0, oo)) # needs sage.symbolic
104104
/ _________ \
105105
-\2*x + \/ 1 - 4*x - 1/
106106
-------------------------
107107
_________
108108
2*x*\/ 1 - 4*x
109-
sage: ascii_art(list(DyckWords(3)))
109+
sage: ascii_art(list(DyckWords(3))) # needs sage.combinat
110110
[ /\ ]
111111
[ /\ /\ /\/\ / \ ]
112112
[ /\/\/\, /\/ \, / \/\, / \, / \ ]
@@ -161,10 +161,10 @@ def build_from_magic_method(self, obj, baseline=None):
161161
EXAMPLES::
162162
163163
sage: from sage.typeset.ascii_art import _ascii_art_factory as factory
164-
sage: out = factory.build_from_magic_method(identity_matrix(2)); out
164+
sage: out = factory.build_from_magic_method(identity_matrix(2)); out # needs sage.modules
165165
[1 0]
166166
[0 1]
167-
sage: type(out)
167+
sage: type(out) # needs sage.modules
168168
<class 'sage.typeset.ascii_art.AsciiArt'>
169169
"""
170170
magic_method = getattr(obj, self.magic_method_name)
@@ -243,12 +243,12 @@ def build_container(self, content, left_border, right_border, baseline=0):
243243
244244
TESTS::
245245
246-
sage: l = ascii_art(list(DyckWords(3))) # indirect doctest
247-
sage: l
246+
sage: l = ascii_art(list(DyckWords(3))) # indirect doctest # needs sage.combinat
247+
sage: l # needs sage.combinat
248248
[ /\ ]
249249
[ /\ /\ /\/\ / \ ]
250250
[ /\/\/\, /\/ \, / \/\, / \, / \ ]
251-
sage: l._breakpoints
251+
sage: l._breakpoints # needs sage.combinat
252252
[9, 17, 25, 33]
253253
254254
Check that zero-height strings are handled (:trac:`28527`)::
@@ -289,7 +289,7 @@ def build_set(self, s, baseline=0):
289289
iteration over sets is non-deterministic so too is the results of this
290290
test::
291291
292-
sage: ascii_art(set(DyckWords(3))) # indirect doctest random
292+
sage: ascii_art(set(DyckWords(3))) # indirect doctest random # needs sage.combinat
293293
{ /\ }
294294
{ /\ /\/\ /\ / \ }
295295
{ / \/\, / \, /\/\/\, /\/ \, / \ }
@@ -298,7 +298,7 @@ def build_set(self, s, baseline=0):
298298
a set, but still obtain the same output formatting::
299299
300300
sage: from sage.typeset.ascii_art import _ascii_art_factory as factory
301-
sage: factory.build_set(sorted(set(DyckWords(3))))
301+
sage: factory.build_set(sorted(set(DyckWords(3)))) # needs sage.combinat
302302
{ /\ }
303303
{ /\ /\ /\/\ / \ }
304304
{ /\/\/\, /\/ \, / \/\, / \, / \ }
@@ -315,6 +315,7 @@ def build_dict(self, d, baseline=0):
315315
316316
TESTS::
317317
318+
sage: # needs sage.combinat
318319
sage: from collections import OrderedDict
319320
sage: d = OrderedDict(enumerate(DyckWords(3)))
320321
sage: art = ascii_art(d) # indirect doctest
@@ -357,18 +358,18 @@ def build_list(self, l, baseline=0):
357358
358359
TESTS::
359360
360-
sage: l = ascii_art(list(DyckWords(3))) # indirect doctest
361-
sage: l
361+
sage: l = ascii_art(list(DyckWords(3))) # indirect doctest # needs sage.combinat
362+
sage: l # needs sage.combinat
362363
[ /\ ]
363364
[ /\ /\ /\/\ / \ ]
364365
[ /\/\/\, /\/ \, / \/\, / \, / \ ]
365-
sage: l._breakpoints
366+
sage: l._breakpoints # needs sage.combinat
366367
[9, 17, 25, 33]
367368
368369
The breakpoints of the object are used as breakpoints::
369370
370-
sage: l = ascii_art([DyckWords(2).list(), DyckWords(2).list()])
371-
sage: l._breakpoints
371+
sage: l = ascii_art([DyckWords(2).list(), DyckWords(2).list()]) # needs sage.combinat
372+
sage: l._breakpoints # needs sage.combinat
372373
[(2, [7]), 17, (18, [7])]
373374
374375
The parentheses only stretch as high as the content (:trac:`28527`)::
@@ -399,7 +400,7 @@ def build_tuple(self, t, baseline=0):
399400
400401
TESTS::
401402
402-
sage: ascii_art(tuple(DyckWords(3))) # indirect doctest
403+
sage: ascii_art(tuple(DyckWords(3))) # indirect doctest # needs sage.combinat
403404
( /\ )
404405
( /\ /\ /\/\ / \ )
405406
( /\/\/\, /\/ \, / \/\, / \, / \ )
@@ -440,8 +441,8 @@ def concatenate(self, iterable, separator, empty=None, baseline=0,
440441
441442
EXAMPLES::
442443
443-
sage: i2 = identity_matrix(2)
444-
sage: ascii_art(i2, i2, i2, sep=ascii_art(1/x))
444+
sage: i2 = identity_matrix(2) # needs sage.modules
445+
sage: ascii_art(i2, i2, i2, sep=ascii_art(1/x)) # needs sage.modules sage.symbolic
445446
1 1
446447
[1 0]-[1 0]-[1 0]
447448
[0 1]x[0 1]x[0 1]

src/sage/typeset/unicode_art.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def unicode_art(*obj, **kwds):
9898
⎮ x + π
9999
100100
sage: ident = lambda n: identity_matrix(ZZ, n)
101-
sage: unicode_art(ident(1), ident(2), ident(3), sep=' : ')
101+
sage: unicode_art(ident(1), ident(2), ident(3), sep=' : ') # needs sage.modules
102102
⎛1 0 0⎞
103103
⎛1 0⎞ ⎜0 1 0⎟
104104
(1) : ⎝0 1⎠ : ⎝0 0 1⎠
@@ -107,7 +107,7 @@ def unicode_art(*obj, **kwds):
107107
an unicode art separator::
108108
109109
sage: sep_line = unicode_art('\n'.join(' ⎟ ' for _ in range(5)), baseline=5)
110-
sage: unicode_art(*AlternatingSignMatrices(3),
110+
sage: unicode_art(*AlternatingSignMatrices(3), # needs sage.combinat sage.modules
111111
....: separator=sep_line, sep_baseline=1)
112112
⎟ ⎟ ⎟ ⎟ ⎟ ⎟
113113
⎛1 0 0⎞ ⎟ ⎛0 1 0⎞ ⎟ ⎛1 0 0⎞ ⎟ ⎛ 0 1 0⎞ ⎟ ⎛0 0 1⎞ ⎟ ⎛0 1 0⎞ ⎟ ⎛0 0 1⎞

0 commit comments

Comments
 (0)