#5037: Bug fixes and new functionalities for Words library
---------------------------+------------------------------------------------
 Reporter:  slabbe         |       Owner:  slabbe       
     Type:  enhancement    |      Status:  new          
 Priority:  major          |   Milestone:  sage-combinat
Component:  combinatorics  |    Keywords:               
 Reviewer:                 |      Author:               
   Merged:                 |  
---------------------------+------------------------------------------------

Comment(by slabbe):

 This is the example of a bad ticket having many feature to fix/add.
 Fortunately, all of those were solved by #6519 merged in sage recently.

 In fact, you can now glue word morphism together using the function
 {{{extend_by}}} :

 {{{
 sage: n = WordMorphism({0:1,1:0,'a':5})
 sage: m = WordMorphism('a->ab,b->ba')
 sage: print n.extend_by(m)
 WordMorphism: 0->1, 1->0, a->5, b->ba
 sage:
 sage: print m.extend_by(n)
 WordMorphism: 0->1, 1->0, a->ab, b->ba
 }}}

 You can now restrict the domain of a morphism by using
 {{{restrict_domain}}} :
 {{{
 sage: print n.restrict_domain([0,'a'])
 WordMorphism: 0->1, a->5
 }}}

 You can now get the partition of the domain alphabet defined (not
 uniquely) by a involution :

 {{{
 sage: inv = WordMorphism({0:1,1:0,2:2,3:3,4:5,5:4})
 sage: inv.is_involution()
 True
 sage: inv.partition_of_domain_alphabet()
 ({0, 4}, {1, 5}, {2, 3})
 }}}


 The code of {{{is_involution}}} first check that self is an endomorphism
 before comptuting the square of self, which gives a better error message :

 {{{
 sage: print n
 WordMorphism: 0->1, 1->0, a->5
 sage: n.is_involution()
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /home/slabbe/.sage/temp/slabbe_laptop/8706/_home_slabbe__sage_init_sage_0.py
 in <module>()

 /home/slabbe/sage-4.1/local/lib/python2.6/site-
 packages/sage/combinat/words/morphism.pyc in is_involution(self)
     973         """
     974         if not self.is_endomorphism():
 --> 975             raise TypeError, "self (=%s) is not a
 endomorphism"%self
     976
     977         return (self*self).is_identity()

 TypeError: self (=WordMorphism: 0->1, 1->0, a->5) is not a endomorphism
 }}}

 The colored vector is not broken anymore on the empty word :

 {{{
 sage: empty = Word(); empty
 word:
 sage: empty.colored_vector()

 }}}

 A label can now be added to the colored vector of a word (a graphic object
 useful to study equations on words) :

 {{{
 sage: w = Word([0..10]+[10,9..0])
 sage: w.colored_vector(label='a palindrome rainbow')

 }}}

 Hence, I recommand that this ticket be closed.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5037#comment:2>
Sage <http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to