Opened 11 years ago
Closed 11 years ago
#10134 closed enhancement (fixed)
Provide the enumeration of word morphisms from a range of integers
Reported by: | slabbe | Owned by: | slabbe |
---|---|---|---|
Priority: | major | Milestone: | sage-4.6.2 |
Component: | combinatorics | Keywords: | |
Cc: | sage-combinat, abmasse | Merged in: | sage-4.6.2.alpha0 |
Authors: | Sébastien Labbé | Reviewers: | Alexandre Blondin Massé |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The method iter_morphisms
may iterate through all morphisms (infinite iterator) or through all morphisms having particular lengths for the image of each letter. Recently, I needed something in the middle, that is, a finite iterator that behaves like the infinite one. Thus, I added a new possible type for the argument (tuple) which specifies a range for the sum of the lengths of the images. Here is an example:
sage: W = Words('ab') sage: for m in W.iter_morphisms( (2, 4) ): print m WordMorphism: a->a, b->a WordMorphism: a->a, b->b WordMorphism: a->b, b->a WordMorphism: a->b, b->b WordMorphism: a->aa, b->a WordMorphism: a->aa, b->b WordMorphism: a->ab, b->a WordMorphism: a->ab, b->b WordMorphism: a->ba, b->a WordMorphism: a->ba, b->b WordMorphism: a->bb, b->a WordMorphism: a->bb, b->b WordMorphism: a->a, b->aa WordMorphism: a->a, b->ab WordMorphism: a->a, b->ba WordMorphism: a->a, b->bb WordMorphism: a->b, b->aa WordMorphism: a->b, b->ab WordMorphism: a->b, b->ba WordMorphism: a->b, b->bb
Patch to be posted soon.
Attachments (3)
Change History (11)
Changed 11 years ago by
comment:1 Changed 11 years ago by
- Cc abmasse added
- Status changed from new to needs_review
comment:2 follow-up: ↓ 3 Changed 11 years ago by
- Status changed from needs_review to needs_work
comment:3 in reply to: ↑ 2 Changed 11 years ago by
- I dislike the parameter name
l
for two reasons. First, it might be confused with the digit1
. Second, because it is not significant. I suggest you use the namelengths
ororder_iterating
, well, anything else more significant.
OK. The parameter l
could be changed. I agree. But, to keep it backward
compatible, we still need to support l
. Maybe arg
would be more adapted.
- The possible values for
l
are quite confusing. List means something, tuple, something else... I don't know if there's a more understandable interface that could be offered. Maybe there could be a parameterlengths_interval
orfixed_lengths
, etc. that could distinguish the different cases.
I disagree on that. It is not C code, it is python. For example, it is OK to do :
sage: Permutation((5,3,2,4,1)) # tuple means cycle notation [5, 4, 2, 1, 3] sage: Permutation([5,3,2,4,1]) # list means images of [1, 2, 3, 4, 5] in that order [5, 3, 2, 4, 1]
The problems with many arguments like lengths_interval
or fixed_lengths
is (1) you still need to look at the documentation to use and understand those arguments, (2) you need to type the name of those argument everytime you use them and (3) the code needs to consider inconsistencies, that is, if both argument are defined by the user.
- The sentence "The length of the list must be the number of letters in the alphabet, and the
i
-th integer ofl
determines the length of the word mapped to by thei
-th letter of the (ordered) alphabet" is not very clear. Maybe it would be better to describe it with mathematical expressions (although it's harder to read in terminal mode). I would suggest something simpler such as : "Ifl
is a list, then it describes the length of the images for each letter of the morphism."
I suggest :
"The length of the list must be equal to the size of the alphabet, and the
i
-th integer of l
determines the length of the word mapped to by the i
-th
letter of the (ordered) alphabet"
Note also that I get some doctest failures:
I do not get those doctest failures. Did you rebuild your branch !?
comment:5 follow-up: ↓ 6 Changed 11 years ago by
I tested the two patches on sage-4.6 and all tests passed. The documentation looked fine, except for a typo I corrected in a review patch.
I'm ready to set this ticket to positive review as soon as Sébastien acknowledge my review patch.
comment:6 in reply to: ↑ 5 Changed 11 years ago by
- Reviewers set to Alexandre Blondin Massé
- Status changed from needs_review to positive_review
I'm ready to set this ticket to positive review as soon as Sébastien acknowledge my review patch.
I aknowledge.
comment:7 Changed 11 years ago by
- Milestone changed from sage-4.6.1 to sage-4.6.2
comment:8 Changed 11 years ago by
- Merged in set to sage-4.6.2.alpha0
- Resolution set to fixed
- Status changed from positive_review to closed
Hi Sébastien!
I took a look at your patch. It should be easy to review but I still have some comments:
l
for two reasons. First, it might be confused with the digit1
. Second, because it is not significant. I suggest you use the namelengths
ororder_iterating
, well, anything else more significant.l
are quite confusing. List means something, tuple, something else... I don't know if there's a more understandable interface that could be offered. Maybe there could be a parameterlengths_interval
orfixed_lengths
, etc. that could distinguish the different cases.i
-th integer ofl
determines the length of the word mapped to by thei
-th letter of the (ordered) alphabet" is not very clear. Maybe it would be better to describe it with mathematical expressions (although it's harder to read in terminal mode). I would suggest something simpler such as : "Ifl
is a list, then it describes the length of the images for each letter of the morphism."I know my ideas aren't very clear, but maybe it could still inspire you into improving the docstring. I'll wait for your answer to resume the review. Note also that I get some doctest failures: