Ticket #12997 (closed defect: fixed)

Opened 12 months ago

Last modified 2 months ago

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

lyndon_word.py Download (12.4 KB) - added by Adrien 12 months ago.
Modified lyndon_word.py
diff Download (303 bytes) - added by Adrien 12 months ago.
diff
trac_12997-LyndonWords-compositions.patch Download (873 bytes) - added by Adrien 12 months ago.
patch
trac_12997-LyndonWords-review-ts.patch Download (1.2 KB) - added by tscrim 3 months ago.
trac_12997-Lyndon-review-fc.patch Download (1.5 KB) - added by chapoton 2 months ago.

Change History

comment:1 Changed 12 months ago by Adrien

  • Description modified (diff)

Changed 12 months ago by Adrien

Modified lyndon_word.py

Changed 12 months ago by Adrien

  • attachment diff Download added

diff

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:3 Changed 12 months ago by saliola

  • Cc slabbe, saliola added

comment:4 Changed 12 months ago by Adrien

  • Status changed from new to needs_review

Changed 12 months ago by Adrien

patch

comment:5 Changed 10 months ago by jdemeyer

Please fill in your real name as Author.

comment:6 Changed 10 months ago by Adrien

  • Authors set to Adrien Brochier

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

Changed 3 months ago by tscrim

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

Changed 2 months ago by chapoton

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
Note: See TracTickets for help on using tickets.