Ticket #12997 (closed defect: fixed)
LyndonWords from composition beginning by 0's
| Reported by: | Adrien | Owned by: | sage-combinat |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-5.9 |
| Component: | combinatorics | Keywords: | lyndon words, sage-combinat, days45 |
| Cc: | slabbe, saliola | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Travis Scrimshaw, Frédéric Chapoton |
| Authors: | Adrien Brochier | Merged in: | sage-5.9.beta1 |
| Dependencies: | Stopgaps: |
Description (last modified by chapoton) (diff)
LyndonWords, when applied to a composition starting with 0's, gives a wrong result, e.g.:
for w in LyndonWords(list([0,1])):
print w
return 1 instead of 2, and in a similar vein
for w in LyndonWords(list([0,2])):
print w
return '12'
The problem is also described here : http://groups.google.com/group/sage-combinat-devel/browse_thread/thread/5c4b691a692b56b0#
The problem is that necklace._sfc() ignores 0's at the begining of a list.
A modified lyndon_word.py file which fix the problem is attached.
Apply:
Attachments
Change History
comment:2 Changed 12 months ago by saliola
Hello Adrien, can you post a patch with your changes instead of the .py file?
You can follow Sébastien's guide on http://thales.math.uqam.ca/~labbes/Sage/how-to-contribute/ How to contribute to Sage (especially steps 15 to 17).
comment:7 Changed 7 months ago by tscrim
- Status changed from needs_review to needs_work
- Reviewers set to Travis Scrimshaw
Please add some tests to the __iter__ method showing the ticket has been fixed such as:
TESTS:
Showing :trac:`12997` is fixed::
sage: LyndonWords([0,1]).list()
[word: 2]
sage: LyndonWords([0,2]).list()
[]
sage: LyndonWords([0,0,1,0,1]).list()
[word: 35]
Thanks,
Travis
comment:8 Changed 3 months ago by tscrim
- Keywords sage-combinat, days45 added; sage-combinat removed
- Status changed from needs_work to needs_review
I've attached the review patch which adds the doctests and tweaks the code format. Could someone give this a quick second review please?
Thanks,
Travis
comment:9 Changed 2 months ago by chapoton
- Status changed from needs_review to positive_review
- Description modified (diff)
Ok, this looks good to me.
I have added a patch to change the "raise" to python3 syntax
positive review
comment:10 Changed 2 months ago by chapoton
- Reviewers changed from Travis Scrimshaw to Travis Scrimshaw, Frédéric Chapoton
comment:11 Changed 2 months ago by tscrim
Thanks Frederic!
comment:12 Changed 2 months ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-5.9.beta1

