Opened 10 years ago
Closed 10 years ago
#13677 closed enhancement (fixed)
Improve __repr__ and __str__ methods of WordMorphism
Reported by: | slabbe | Owned by: | slabbe |
---|---|---|---|
Priority: | major | Milestone: | sage-5.5 |
Component: | combinatorics | Keywords: | wordmorphism |
Cc: | tjolivet, vdelecroix | Merged in: | sage-5.5.rc0 |
Authors: | Sébastien Labbé | Reviewers: | Timo Jolivet |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The __repr__
method is not fun:
sage: WordMorphism('a->ab,b->ba') Morphism from Words over Ordered Alphabet ['a', 'b'] to Words over Ordered Alphabet ['a', 'b'] sage: WordMorphism({0:[0,1],1:[1,0]}) Morphism from Words over Ordered Alphabet [0, 1] to Words over Ordered Alphabet [0, 1]
One always have to use the print statement (which calls __str__
) ::
sage: print WordMorphism('a->ab,b->ba') WordMorphism: a->ab, b->ba sage: print WordMorphism({0:[0,1],1:[1,0]}) WordMorphism: 0->01, 1->10
Also, this is ugly:
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]}) sage: E = E1Star(sigma) sage: E E_1^*(WordMorphism: 1->12, 2->13, 3->1)
The proposed solution is to change the code of __repr__
so that it behaves like the actual __str__
and change the __str__
to remove the WordMorphism:
part. See examples below :
The new __repr__
method :
sage: WordMorphism('a->ab,b->ba') WordMorphism: a->ab, b->ba sage: WordMorphism({0:[0,1],1:[1,0]}) WordMorphism: 0->01, 1->10
The new __str__
method :
sage: print WordMorphism('a->ab,b->ba') a->ab, b->ba
sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]}) sage: E = E1Star(sigma) sage: E E_1^*(1->12, 2->13, 3->1)
Attachments (3)
Change History (12)
comment:1 Changed 10 years ago by
- Dependencies set to #13676
comment:2 Changed 10 years ago by
- Status changed from new to needs_review
comment:3 Changed 10 years ago by
- Cc tjolivet vdelecroix added
Changed 10 years ago by
Changed 10 years ago by
comment:4 Changed 10 years ago by
- Dependencies #13676 deleted
Changed 10 years ago by
comment:5 Changed 10 years ago by
- Milestone changed from sage-5.5 to sage-5.4
- Reviewers set to Timo Jolivet
- Status changed from needs_review to positive_review
comment:6 Changed 10 years ago by
- Milestone changed from sage-5.4 to sage-5.5
comment:7 follow-up: ↓ 8 Changed 10 years ago by
Please clarify which patches need to be applied.
comment:8 in reply to: ↑ 7 Changed 10 years ago by
comment:9 Changed 10 years ago by
- Merged in set to sage-5.5.rc0
- Resolution set to fixed
- Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
I changed #13676 to remove the dependancies (by not including new
_latex_
method next to the__repr__
and__str__
methods).I separated the patch into 3 pieces : the code changed, docfixes in
sage/combinat/words
, docfixes insage/combinat/iet
. It will be easier to review like that and also easier to update if future conflicts occur.Needs review!