#9877: Add is_sturmian_factor, is_tangent methods for finite words
-----------------------------+----------------------------------------------
Reporter: tmonteil | Owner: tmonteil
Type: enhancement | Status: needs_work
Priority: major | Milestone: sage-4.6
Component: combinatorics | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-----------------------------+----------------------------------------------
Comment(by abmasse):
There is another problem with your function:
{{{
TypeError: Your word must be defined on a binary alphabet
sage:
sage:
sage: Word('ababab', alphabet='ab').is_sturmian_factor()
True
sage: Word('ababab').is_sturmian_factor()
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)
/Users/alexandre/Applications/sage/devel/sage-
combinat/sage/combinat/words/<ipython console> in <module>()
/Users/alexandre/Applications/sage/local/lib/python2.6/site-
packages/sage/combinat/words/finite_word.pyc in is_sturmian_factor(self)
4197 - Thierry Monteil
4198 """
-> 4199 return self.sturmian_desubstitute_as_possible().is_empty()
4200
4201
/Users/alexandre/Applications/sage/local/lib/python2.6/site-
packages/sage/combinat/words/finite_word.pyc in
sturmian_desubstitute_as_possible(self)
4086 W = self.parent()
4087 if (W.size_of_alphabet() != 2):
-> 4088 raise TypeError, 'Your word must be defined on a
binary alphabet'
4089 alphabet = W.alphabet()
4090 if self.is_empty():
TypeError: Your word must be defined on a binary alphabet
}}}
I think this shouldn't be the case. In fact, this is interesting, because
it raises another problem I had when working on another patch. What I
suggest is that you could first verify if the parent has size 2 and, if
it's not the case, you check if its *real* alphabet has size 2 by using
the expression
len(set(self)) == 2
I think the clean solution would be to replace the deprecated function
`alphabet()` by a new one that would compute the *real alphabet* in
question, so that there would be two kinds of alphabet:
1. The one corresponding to the parent of the word (for instance `aaab`
might be a word defined on the alphabet `{a,b,c}`).
2. The one corresponding to the alphabet realized by the word `Alph(aaab)
= {a,b}`
The first one is called by `w.parent().alphabet()` while the second one
would be obtained from `w.alphabet()`. But this is for another ticket.
What I suggest is that you simply add the `len(set(w)) == 2` condition to
your code and we'll clean it eventually.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9877#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.