Opened 12 years ago
Closed 12 years ago
#4954 closed defect (duplicate)
Words_over_Alphabet should check the type of input alphabet
Reported by: | slabbe | Owned by: | slabbe |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | combinatorics | Keywords: | words alphabet |
Cc: | sage-combinat | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Do
sage: W=Words('ab') sage: W.alphabet?
and you get the following help example :
sage: from sage.combinat.words.words import Words_over_Alphabet sage: W = Words_over_Alphabet([1,2,3]) sage: W.alphabet() [1, 2, 3] sage: from sage.combinat.words.words import OrderedAlphabet sage: W = Words_over_Alphabet(OrderedAlphabet('ab')) sage: W.alphabet() Ordered Alphabet ['a', 'b']
The first of the above example is misleading. In fact, it is not usable :
sage: from sage.combinat.words.words import Words_over_Alphabet sage: W = Words_over_Alphabet([1,2,3]) sage: W.alphabet() [1, 2, 3] sage: W([1,1,1,2,1,3]) Traceback (most recent call last): ... AttributeError: 'list' object has no attribute 'rank'
The problem comes from the fact that Words_over_Alphabet doesn't check the input alphabet before asigning it to self._alphabet(). It should either do alphabet=OrderedAlphabet(alphabet)
before or check the type of the input alphabet with a isinstance.
Change History (4)
comment:1 Changed 12 years ago by
- Owner changed from mhansen to slabbe
comment:2 Changed 12 years ago by
- Cc sage-combinat added
comment:3 Changed 12 years ago by
comment:4 Changed 12 years ago by
- Milestone changed from sage-4.1.1 to sage-duplicate/invalid/wontfix
- Resolution set to duplicate
- Status changed from new to closed
Closing this as a duplicate of #6519.
Note: See
TracTickets for help on using
tickets.
This problem was solved by #6519 :
So, I propose that this ticket be closed.