#8139: Can not compute (very) high power of WordMorphism
-----------------------------+----------------------------------------------
Reporter: vdelecroix | Owner: sage-combinat
Type: defect | Status: new
Priority: major | Milestone: sage-4.3.2
Component: combinatorics | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-----------------------------+----------------------------------------------
When taking a power greater than 30 of a WordMorphism I (we?) get a ugly
backtrace of a ValueError
{{{
sage: m = WordMorphism('a->ab,b->ba')
sage: m^30
Morphism from Words over Ordered Alphabet ['a', 'b'] to Words over Ordered
Alphabet ['a', 'b']
sage: m^31
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
/usr/local/sage-4.3.1/devel/sage-test/<ipython console> in <module>()
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/morphism.pyc in __pow__(self, exp)
698 res = (self * self) ** nexp
699 if over == 1:
--> 700 res *= self
701 return res
702
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/morphism.pyc in __mul__(self, other)
642 #TODO : Est-ce que c'est le comportement que l'on veut
pour le produit
643 #par le morphisme vide? Voir lignes ci-haut.
--> 644 return WordMorphism(dict((key, self(w)) for (key, w) in
other._morph.iteritems()), codomain=self.codomain())
645
646 def __pow__(self, exp):
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/morphism.pyc in <genexpr>((key, w))
642 #TODO : Est-ce que c'est le comportement que l'on veut
pour le produit
643 #par le morphisme vide? Voir lignes ci-haut.
--> 644 return WordMorphism(dict((key, self(w)) for (key, w) in
other._morph.iteritems()), codomain=self.codomain())
645
646 def __pow__(self, exp):
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/morphism.pyc in __call__(self, w, order,
datatype)
580 if isinstance(w, FiniteWord_class):
581 length = sum(self._morph[a].length() * b for (a,b)
in w.evaluation_dict().iteritems())
--> 582 return self.codomain()((x for y in w for x in
self._morph[y]), length=length, datatype=datatype)
583 else:
584 return self.codomain()((x for y in w for x in
self._morph[y]), length=Infinity, datatype='iter')
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/words.pyc in __call__(self, data, length,
datatype, **kwds)
269
270 # The function _construct_word handles the construction of
the words.
--> 271 w = self._construct_word(**kwds)
272 self._check(w)
273 return w
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/words.pyc in _construct_word(self, data,
length, datatype, caching)
471 else:
472 raise ValueError, "not a correct value for
length (%s)" % length
--> 473 w = cls(parent=self,iter=data,length=length)
474 else:
475 raise ValueError, "Not known datatype"
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/word_infinite_datatypes.pyc in __init__(self,
parent, iter, length)
857 8
858 """
--> 859
super(WordDatatype_iter_with_caching,self).__init__(parent,iter,length)
860 # we use self._data for returning an iterator through
__iter__;
861 # we use self._gen for caching
/usr/local/sage-4.3.1/local/lib/python2.6/site-
packages/sage/combinat/words/word_infinite_datatypes.pyc in __init__(self,
parent, iter, length)
558 else:
559 self._len = length
--> 560 self._data = itertools.islice(iter, length)
561
562 self._parent = parent
ValueError: Stop argument for islice() must be a non-negative integer or
None.
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8139>
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.