Ticket #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 | Author(s): | |
| Report Upstream: | Reviewer(s): | ||
| Merged in: | Work issues: |
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
Note: See
TracTickets for help on using
tickets.
