From 8153dbd027a4a21bcc0de7a60793b1252fff60d1 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 4 Nov 2023 10:24:42 -0700 Subject: [PATCH] sage.combinat.words: More block tags --- src/sage/combinat/words/finite_word.py | 13 +++++++------ src/sage/combinat/words/morphism.py | 27 +++++++++++++------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/sage/combinat/words/finite_word.py b/src/sage/combinat/words/finite_word.py index d43624c8ebe..35fd6e69c55 100644 --- a/src/sage/combinat/words/finite_word.py +++ b/src/sage/combinat/words/finite_word.py @@ -6824,18 +6824,19 @@ def colored_vector(self, x=0, y=0, width='default', height=1, cmap='hsv', thickn EXAMPLES:: - sage: Word(range(20)).colored_vector() # needs sage.plot + sage: # needs sage.plot + sage: Word(range(20)).colored_vector() Graphics object consisting of 21 graphics primitives - sage: Word(range(100)).colored_vector(0,0,10,1) # needs sage.plot + sage: Word(range(100)).colored_vector(0,0,10,1) Graphics object consisting of 101 graphics primitives - sage: Words(range(100))(range(10)).colored_vector() # needs sage.plot + sage: Words(range(100))(range(10)).colored_vector() Graphics object consisting of 11 graphics primitives sage: w = Word('abbabaab') - sage: w.colored_vector() # needs sage.plot + sage: w.colored_vector() Graphics object consisting of 9 graphics primitives - sage: w.colored_vector(cmap='autumn') # needs sage.plot + sage: w.colored_vector(cmap='autumn') Graphics object consisting of 9 graphics primitives - sage: Word(range(20)).colored_vector(label='Rainbow') # needs sage.plot + sage: Word(range(20)).colored_vector(label='Rainbow') Graphics object consisting of 23 graphics primitives When two words are defined under the same parent, same letters are diff --git a/src/sage/combinat/words/morphism.py b/src/sage/combinat/words/morphism.py index de7f00902ef..279c238718e 100644 --- a/src/sage/combinat/words/morphism.py +++ b/src/sage/combinat/words/morphism.py @@ -346,7 +346,7 @@ def __init__(self, data, domain=None, codomain=None): The image of a letter can be a set, but the order is not preserved:: - sage: WordMorphism({2:[4,5,6],3:set([4,1,8])}) #random results + sage: WordMorphism({2:[4,5,6],3:set([4,1,8])}) # random results WordMorphism: 2->456, 3->814 If the image of a letter is not iterable, it is considered as a @@ -1099,23 +1099,24 @@ def _matrix_(self, R=None): EXAMPLES:: + sage: # needs sage.modules sage: fibo = WordMorphism('a->ab,b->a') sage: tm = WordMorphism('a->ab,b->ba') - sage: Mfibo = matrix(fibo); Mfibo # indirect doctest # needs sage.modules + sage: Mfibo = matrix(fibo); Mfibo # indirect doctest [1 1] [1 0] - sage: Mtm = matrix(tm); Mtm # needs sage.modules + sage: Mtm = matrix(tm); Mtm [1 1] [1 1] - sage: Mtm * Mfibo == matrix(tm*fibo) # indirect doctest # needs sage.modules + sage: Mtm * Mfibo == matrix(tm*fibo) # indirect doctest True - sage: Mfibo * Mtm == matrix(fibo*tm) # indirect doctest # needs sage.modules + sage: Mfibo * Mtm == matrix(fibo*tm) # indirect doctest True - sage: Mfibo.parent() # needs sage.modules + sage: Mfibo.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring - sage: p = Mfibo.charpoly(); p # needs sage.modules + sage: p = Mfibo.charpoly(); p x^2 - x - 1 - sage: p.roots(ring=RR, multiplicities=False) # needs sage.modules + sage: p.roots(ring=RR, multiplicities=False) [-0.618033988749895, 1.61803398874989] """ if R is None: @@ -1406,19 +1407,19 @@ def partition_of_domain_alphabet(self): EXAMPLES:: sage: m = WordMorphism('a->b,b->a') - sage: m.partition_of_domain_alphabet() #random ordering + sage: m.partition_of_domain_alphabet() # random ordering ({'a'}, {'b'}, {}) sage: m = WordMorphism('a->b,b->a,c->c') - sage: m.partition_of_domain_alphabet() #random ordering + sage: m.partition_of_domain_alphabet() # random ordering ({'a'}, {'b'}, {'c'}) sage: m = WordMorphism('a->a,b->b,c->c') - sage: m.partition_of_domain_alphabet() #random ordering + sage: m.partition_of_domain_alphabet() # random ordering ({}, {}, {'a', 'c', 'b'}) sage: m = WordMorphism('A->T,T->A,C->G,G->C') - sage: m.partition_of_domain_alphabet() #random ordering + sage: m.partition_of_domain_alphabet() # random ordering ({'A', 'C'}, {'T', 'G'}, {}) sage: I = WordMorphism({0:oo,oo:0,1:-1,-1:1,2:-2,-2:2,3:-3,-3:3}) - sage: I.partition_of_domain_alphabet() #random ordering + sage: I.partition_of_domain_alphabet() # random ordering ({0, -1, -3, -2}, {1, 2, 3, +Infinity}, {}) TESTS::