#7519: Allowing the choice of word datatype for images under WordMorphism
-----------------------------+----------------------------------------------
   Reporter:  slabbe         |       Owner:  slabbe  
       Type:  enhancement    |      Status:  new     
   Priority:  major          |   Milestone:  sage-4.3
  Component:  combinatorics  |    Keywords:          
Work_issues:                 |      Author:          
   Upstream:  N/A            |    Reviewer:          
     Merged:                 |  
-----------------------------+----------------------------------------------
 By default, the image of a word under a morphism is given by a iterator
 which is good because it is returned in constant time but which is bad
 because it is not directly picklable.

 {{{
 sage: m = WordMorphism({0:[0,1], 1:[1,0,0,1]})
 sage: print m
 WordMorphism: 0->01, 1->1001
 sage: W = m.domain()
 sage: w = W([0,1,1,1])
 sage: type(w)
 <class 'sage.combinat.words.word.FiniteWord_list'>
 sage: z = m(w)
 sage: type(z)
 <class 'sage.combinat.words.word.FiniteWord_iter_with_caching'>
 sage: loads(dumps(z))
 Traceback (most recent call last):
 ...
 PicklingError: Can't pickle <type 'generator'>: attribute lookup
 __builtin__.generator failed
 }}}

 This patch allows one to suggest under which datatype to represent the
 word :

 {{{
 sage: m = WordMorphism({0:[0,1], 1:[1,0,0,1]})
 sage: z = m([0,1,1,1], datatype='list')
 sage: type(z)
 <class 'sage.combinat.words.word.FiniteWord_list'>
 sage: loads(dumps(z))
 word: 01100110011001
 }}}

 It also leaves the current default behavior :

 {{{
 sage: m = WordMorphism({0:[0,1], 1:[1,0,0,1]})
 sage: m([0,1,1,1])
 word: 01100110011001
 sage: type(_)
 <class 'sage.combinat.words.word.FiniteWord_iter_with_caching'>
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7519>
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=.


Reply via email to