id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
7405 Change the print of predefined words to the default behavior Sébastien Labbé Sébastien Labbé "This ticket concern 4 relatively small things.
(1) Change the print of predefined words to the default behavior.[[BR]]
(2) Correct a bug of {{{__mul__}}} of {{{WordMorphism.}}}[[BR]]
(3) Adds the Fibonacci word defined from function.[[BR]]
(4) Adds documentation and doctest to a recently added function called {{{_element_classes}}} in {{{word.py}}}.
See below for more explanations.
(1) The {{{rename}}} function is used a lot for predefined words :
{{{
sage: words.FibonacciWord()
Fibonacci word over Ordered Alphabet [0, 1], defined recursively
sage: words.FibonacciWord((0,1),'fixed point')
Fibonacci word over Ordered Alphabet [0, 1], defined as the fixed point of a morphism
sage: words.ThueMorseWord(alphabet = (3,4))
Thue-Morse word over Ordered Alphabet [3, 4]
sage: words.FixedPointOfMorphism('a->ab,b->ba','a')
Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->ba
sage: words.ChristoffelWord(4,7)
Lower Christoffel word of slope 4/7 over Ordered Alphabet [0, 1]
}}}
But I more and more dislike this behavior made for the user since (1) it repeats the information already given by the user and (2) the first thing that the user do with the word is to look the prefix of the word (well, that's what I always do and that's what is done everywhere in the doctests).
To print a prefix, one needs to crete it (which is not always necessary for the user) :
{{{
sage: f = words.FibonacciWord()
sage: f
Fibonacci word over Ordered Alphabet [0, 1], defined recursively
sage: print f
Fibonacci word over Ordered Alphabet [0, 1], defined recursively
sage: f[:100]
word: 0100101001001010010100100101001001010010...
sage: print f[:100]
word: 0100101001001010010100100101001001010010100100101001010010010100100101001010010010100100101001010010
}}}
I would simply like the following to work :
{{{
sage: words.FibonacciWord()
word: 0100101001001010010100100101001001010010...
}}}
which is the default behavior anyway :
{{{
sage: Word(lambda n:n%10)
word: 0123456789012345678901234567890123456789...
}}}
(2) The codomain of the product of {{{WordMorphism}}} is not correct :
{{{
sage: m = WordMorphism('0->a,1->b')
sage: n = WordMorphism('a->c,b->e',codomain=Words('abcde'))
sage: p = n * m
sage: p.codomain()
Words over Ordered Alphabet ['c', 'e']
}}}
(3) See the patch.
(4) See the patch.
" enhancement closed major sage-4.3 combinatorics fixed words Franco Saliola sage-4.3.alpha1 Sébastien Labbé Florent Hivert N/A