Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the print of predefined words to the default behavior #7405

Closed
seblabbe opened this issue Nov 6, 2009 · 9 comments
Closed

Change the print of predefined words to the default behavior #7405

seblabbe opened this issue Nov 6, 2009 · 9 comments

Comments

@seblabbe
Copy link
Contributor

seblabbe commented Nov 6, 2009

This ticket concern 4 relatively small things.

(1) Change the print of predefined words to the default behavior.

(2) Correct a bug of __mul__ of WordMorphism.

(3) Adds the Fibonacci word defined from function.

(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.

CC: @saliola

Component: combinatorics

Keywords: words

Author: Sébastien Labbé

Reviewer: Florent Hivert

Merged: sage-4.3.alpha1

Issue created by migration from https://trac.sagemath.org/ticket/7405

@seblabbe seblabbe added this to the sage-4.3 milestone Nov 6, 2009
@seblabbe seblabbe self-assigned this Nov 6, 2009
@seblabbe
Copy link
Contributor Author

seblabbe commented Nov 6, 2009

@seblabbe

This comment has been minimized.

@hivert
Copy link

hivert commented Nov 22, 2009

comment:3

The patch looks good and all tests pass. I'm ready to give a positive review.

However I'm not a word expert so that I'd like someone who is to confirm that the change of printing is really the wanted behavior. Franco: once you agree with that please put a positive review on that patch. I will shorten a bit more the combinat queue...

Cheers,

Florent

@hivert
Copy link

hivert commented Nov 22, 2009

Reviewer: Florent Hivert

@seblabbe
Copy link
Contributor Author

Author: Sébastien Labbé

@seblabbe
Copy link
Contributor Author

comment:4

Thanks Florent for the review.

I also would like Franco to agree with the print changes before any inclusion in sage since he wrote some of those rename of objects.

Sébastien

@saliola
Copy link

saliola commented Nov 23, 2009

comment:5

I strongly agree with the changes. I think this way is much better.

@saliola
Copy link

saliola commented Nov 23, 2009

comment:6

Opps, I forgot to change the summary.

@mwhansen
Copy link
Contributor

Merged: sage-4.3.alpha1

@sagetrac-mvngu sagetrac-mvngu mannequin changed the title Change the print of predefined words to the default behavior. Change the print of predefined words to the default behavior Dec 26, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants