Ticket #13677: trac_13677_docfixes_words-sl.patch

File trac_13677_docfixes_words-sl.patch, 30.0 KB (added by Sébastien Labbé, 10 years ago)
  • sage/combinat/e_one_star.py

    # HG changeset patch
    # User Sebastien Labbe <slabqc at gmail.com>
    # Date 1351769980 -3600
    # Node ID b12240b3b77291be31e7776cf53dc71324b7525b
    # Parent  00f84c26354a61c7b0c9b0a7427d5ccc8021f640
    Fix doctest after improvement of __repr__ and __str__ methods of WordMorphism
    
    diff --git a/sage/combinat/e_one_star.py b/sage/combinat/e_one_star.py
    a b which only work in dimension two or thre 
    176176    sage: sigma = WordMorphism({1:[1,2],2:[1,3],3:[1,4],4:[1,5],5:[1,6],6:[1,7],7:[1,8],8:[1,9],9:[1,10],10:[1,11],11:[1,12],12:[1]})
    177177    sage: E = E1Star(sigma)
    178178    sage: E
    179     E_1^*(WordMorphism: 1->12, 10->1,11, 11->1,12, 12->1, 2->13, 3->14, 4->15, 5->16, 6->17, 7->18, 8->19, 9->1,10)
     179    E_1^*(1->12, 10->1,11, 11->1,12, 12->1, 2->13, 3->14, 4->15, 5->16, 6->17, 7->18, 8->19, 9->1,10)
    180180    sage: P = Patch([Face((0,0,0,0,0,0,0,0,0,0,0,0),t) for t in [1,2,3]])
    181181    sage: for x in sorted(list(E(P)), key=lambda x : (x.vector(),x.type())): print x
    182182    [(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 1]*
    class E1Star(SageObject): 
    14401440            sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
    14411441            sage: E = E1Star(sigma)
    14421442            sage: E
    1443             E_1^*(WordMorphism: 1->12, 2->13, 3->1)
     1443            E_1^*(1->12, 2->13, 3->1)
    14441444        """
    14451445        if not isinstance(sigma, WordMorphism):
    14461446            raise TypeError, "sigma (=%s) must be an instance of WordMorphism"%sigma
    class E1Star(SageObject): 
    15701570            sage: s = WordMorphism({1:[2],2:[3],3:[1,2]})
    15711571            sage: t = WordMorphism({1:[1,3,1],2:[1],3:[1,1,3,2]})
    15721572            sage: E1Star(s) * E1Star(t)
    1573             E_1^*(WordMorphism: 1->1, 2->1132, 3->1311)
     1573            E_1^*(1->1, 2->1132, 3->1311)
    15741574            sage: E1Star(t * s)
    1575             E_1^*(WordMorphism: 1->1, 2->1132, 3->1311)
     1575            E_1^*(1->1, 2->1132, 3->1311)
    15761576        """
    15771577        if not isinstance(other, E1Star):
    15781578            raise TypeError, "other (=%s) must be an instance of E1Star" % other
    class E1Star(SageObject): 
    15881588            sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
    15891589            sage: E = E1Star(sigma)
    15901590            sage: E
    1591             E_1^*(WordMorphism: 1->12, 2->13, 3->1)
     1591            E_1^*(1->12, 2->13, 3->1)
    15921592        """
    15931593        return "E_1^*(%s)" % str(self._sigma)
    15941594
    class E1Star(SageObject): 
    16651665            sage: from sage.combinat.e_one_star import E1Star, Face, Patch
    16661666            sage: sigma = WordMorphism({1:[1,2], 2:[1,3], 3:[1]})
    16671667            sage: E = E1Star(sigma)
    1668             sage: print E.sigma()
     1668            sage: E.sigma()
    16691669            WordMorphism: 1->12, 2->13, 3->1
    16701670        """
    16711671        return self._sigma
  • sage/combinat/words/infinite_word.py

    diff --git a/sage/combinat/words/infinite_word.py b/sage/combinat/words/infinite_word.py
    a b Infinite words from morphism 
    5050For example, let `A=\{a,b\}` and `\mu : A^* \rightarrow A^*`
    5151be the morphism defined by `a\mapsto ab, b\mapsto ba`::
    5252
    53     sage: mu = WordMorphism('a->ab,b->ba'); print mu
     53    sage: mu = WordMorphism('a->ab,b->ba'); mu
    5454    WordMorphism: a->ab, b->ba
    5555    sage: mu.fixed_point('a')
    5656    word: abbabaabbaababbabaababbaabbabaabbaababba...
  • sage/combinat/words/morphism.py

    diff --git a/sage/combinat/words/morphism.py b/sage/combinat/words/morphism.py
    a b Creation of a morphism from a dictionary 
    2626::
    2727
    2828    sage: n
    29     Morphism from Words over Ordered Alphabet [0, 1, 2] to Words over Ordered Alphabet [0, 1, 2]
     29    WordMorphism: 0->0221, 1->02, 2->221
    3030    sage: m
    31     Morphism from Words over Ordered Alphabet ['s', 'x', 'y'] to Words over Ordered Alphabet ['s', 'x', 'y']
     31    WordMorphism: s->xyss, x->xyxsxss, y->ys
    3232
    3333The codomain may be specified::
    3434
    35     sage: WordMorphism({0:[0,2,2,1],1:[0,2],2:[2,2,1]}, codomain=Words([0,1,2,3,4])) 
    36     Morphism from Words over Ordered Alphabet [0, 1, 2] to Words over Ordered Alphabet [0, 1, 2, 3, 4]
     35    sage: WordMorphism({0:[0,2,2,1],1:[0,2],2:[2,2,1]}, codomain=Words([0,1,2,3,4]))
     36    WordMorphism: 0->0221, 1->02, 2->221
    3737
    3838Power of a morphism::
    3939
    40     sage: print n^2
     40    sage: n^2
    4141    WordMorphism: 0->022122122102, 1->0221221, 2->22122102
    4242
    4343Image under a morphism::
    class WordMorphism(SageObject): 
    172172
    173173    Power of a morphism::
    174174
    175         sage: print n^2
     175        sage: n^2
    176176        WordMorphism: 0->022122122102, 1->0221221, 2->22122102
    177177
    178178    Image under a morphism::
    class WordMorphism(SageObject): 
    221221    def __init__(self, data, codomain=None):
    222222        r"""
    223223        Construction of the morphism.
    224        
     224
    225225        EXAMPLES:
    226        
     226
    227227        1. If data is a str::
    228228
    229             sage: print WordMorphism('a->ab,b->ba')
     229            sage: WordMorphism('a->ab,b->ba')
    230230            WordMorphism: a->ab, b->ba
    231             sage: print WordMorphism('a->ab,b->ba')
     231            sage: WordMorphism('a->ab,b->ba')
    232232            WordMorphism: a->ab, b->ba
    233             sage: print WordMorphism('a->abc,b->bca,c->cab')
     233            sage: WordMorphism('a->abc,b->bca,c->cab')
    234234            WordMorphism: a->abc, b->bca, c->cab
    235             sage: print WordMorphism('a->abdsf,b->hahdad,c->asdhasd')
     235            sage: WordMorphism('a->abdsf,b->hahdad,c->asdhasd')
    236236            WordMorphism: a->abdsf, b->hahdad, c->asdhasd
    237             sage: print WordMorphism('(->(),)->)(')                 
     237            sage: WordMorphism('(->(),)->)(')
    238238            WordMorphism: (->(), )->)(
    239             sage: print WordMorphism('a->53k,b->y5?,$->49i')
     239            sage: WordMorphism('a->53k,b->y5?,$->49i')
    240240            WordMorphism: $->49i, a->53k, b->y5?
    241            
     241
    242242        An erasing morphism::
    243243
    244             sage: print WordMorphism('a->ab,b->')
     244            sage: WordMorphism('a->ab,b->')
    245245            WordMorphism: a->ab, b->
    246            
     246
    247247        Use the arrows ('->') correctly::
    248248
    249249            sage: WordMorphism('a->ab,b-')
    250250            Traceback (most recent call last):
    251251            ...
    252252            ValueError: The second and third characters must be '->' (not '-')
    253             sage: WordMorphism('a->ab,b') 
     253            sage: WordMorphism('a->ab,b')
    254254            Traceback (most recent call last):
    255255            ...
    256256            ValueError: The second and third characters must be '->' (not '')
    class WordMorphism(SageObject): 
    258258            Traceback (most recent call last):
    259259            ...
    260260            ValueError: The second and third characters must be '->' (not '-]')
    261            
     261
    262262        Each letter must be defined only once::
    263263
    264264            sage: WordMorphism('a->ab,a->ba')
    265265            Traceback (most recent call last):
    266266            ...
    267267            ValueError: The image of 'a' is defined twice.
    268            
     268
    269269        2. From a dictionary::
    270270
    271             sage: print WordMorphism({"a":"ab","b":"ba"})
     271            sage: WordMorphism({"a":"ab","b":"ba"})
    272272            WordMorphism: a->ab, b->ba
    273             sage: print WordMorphism({2:[4,5,6],3:[1,2,3]}) 
     273            sage: WordMorphism({2:[4,5,6],3:[1,2,3]})
    274274            WordMorphism: 2->456, 3->123
    275             sage: print WordMorphism({'a':['a',6,'a'],6:[6,6,6,'a']})
     275            sage: WordMorphism({'a':['a',6,'a'],6:[6,6,6,'a']})
    276276            WordMorphism: 6->666a, a->a6a
    277            
    278         The image of a letter can be a set, but the order is not 
     277
     278        The image of a letter can be a set, but the order is not
    279279        preserved::
    280280
    281             sage: print WordMorphism({2:[4,5,6],3:set([4,1,8])}) #random results
     281            sage: WordMorphism({2:[4,5,6],3:set([4,1,8])}) #random results
    282282            WordMorphism: 2->456, 3->814
    283            
    284         If the image of a letter is not iterable, it is considered as a 
     283
     284        If the image of a letter is not iterable, it is considered as a
    285285        letter::
    286286
    287             sage: print WordMorphism({0:1, 1:0})
     287            sage: WordMorphism({0:1, 1:0})
    288288            WordMorphism: 0->1, 1->0
    289             sage: print WordMorphism({0:123, 1:789})
     289            sage: WordMorphism({0:123, 1:789})
    290290            WordMorphism: 0->123, 1->789
    291             sage: print WordMorphism({2:[4,5,6], 3:123})   
     291            sage: WordMorphism({2:[4,5,6], 3:123})
    292292            WordMorphism: 2->456, 3->123
    293            
     293
    294294        3. From a WordMorphism::
    295295
    296             sage: print WordMorphism(WordMorphism('a->ab,b->ba'))
     296            sage: WordMorphism(WordMorphism('a->ab,b->ba'))
    297297            WordMorphism: a->ab, b->ba
    298298
    299299        TESTS::
    300300
    301             sage: print WordMorphism(',,,a->ab,,,b->ba,,')
     301            sage: WordMorphism(',,,a->ab,,,b->ba,,')
    302302            WordMorphism: a->ab, b->ba
    303303        """
    304304        if isinstance(data, WordMorphism):
    class WordMorphism(SageObject): 
    310310                data = self._build_dict(data)
    311311            elif not isinstance(data, dict):
    312312                raise NotImplementedError
    313            
     313
    314314            if codomain is None:
    315315                codomain = self._build_codomain(data)
    316316
    317317            if not isinstance(codomain,Words_all):
    318318                raise TypeError, "the codomain must be a Words domain"
    319319            self._codomain = codomain
    320            
     320
    321321            self._morph = {}
    322322           
    323323            dom_alph = list()
    class WordMorphism(SageObject): 
    416416            True
    417417            sage: WordMorphism('b->ba,a->ab') == WordMorphism({"a":"ab","b":"ba"})
    418418            True
    419             sage: m = WordMorphism({0:[1,2,3],1:[4,5,6]}); print m
     419            sage: m = WordMorphism({0:[1,2,3],1:[4,5,6]}); m
    420420            WordMorphism: 0->123, 1->456
    421             sage: o = WordMorphism('0->123,1->456'); print o
     421            sage: o = WordMorphism('0->123,1->456'); o
    422422            WordMorphism: 0->123, 1->456
    423423            sage: m == o
    424424            False
    class WordMorphism(SageObject): 
    719719
    720720            sage: m = WordMorphism('a->ab,b->ba')
    721721            sage: fibo = WordMorphism('a->ab,b->a')
    722             sage: print fibo*m
     722            sage: fibo*m
    723723            WordMorphism: a->aba, b->aab
    724             sage: print fibo*fibo
     724            sage: fibo*fibo
    725725            WordMorphism: a->aba, b->ab
    726             sage: print m*fibo
     726            sage: m*fibo
    727727            WordMorphism: a->abba, b->ab
    728728
    729729        ::
    730730
    731731            sage: n = WordMorphism('a->a,b->aa,c->aaa')
    732732            sage: p1 = n*m
    733             sage: print p1
     733            sage: p1
    734734            WordMorphism: a->aaa, b->aaa
    735735            sage: p1.domain()
    736736            Words over Ordered Alphabet ['a', 'b']
    class WordMorphism(SageObject): 
    740740        ::
    741741
    742742            sage: p2 = m*n
    743             sage: print p2
     743            sage: p2
    744744            WordMorphism: a->ab, b->abab, c->ababab
    745745            sage: p2.domain()
    746746            Words over Ordered Alphabet ['a', 'b', 'c']
    class WordMorphism(SageObject): 
    762762            Traceback (most recent call last):
    763763            ...
    764764            KeyError: 'b'
    765             sage: print m * WordMorphism('')
     765            sage: m * WordMorphism('')
    766766            WordMorphism:
    767767        """
    768768        return WordMorphism(dict((key, self(w)) for (key, w) in other._morph.iteritems()), codomain=self.codomain())
    class WordMorphism(SageObject): 
    778778        EXAMPLES::
    779779
    780780            sage: m = WordMorphism('a->ab,b->ba')
    781             sage: print m^1
     781            sage: m^1
    782782            WordMorphism: a->ab, b->ba
    783             sage: print m^2
     783            sage: m^2
    784784            WordMorphism: a->abba, b->baab
    785             sage: print m^3
     785            sage: m^3
    786786            WordMorphism: a->abbabaab, b->baababba
    787787
    788788        The exponent must be a positive integer::
    class WordMorphism(SageObject): 
    791791            Traceback (most recent call last):
    792792            ...
    793793            ValueError: exponent (1.50000000000000) must be an integer
    794             sage: print m^-2
     794            sage: m^-2
    795795            Traceback (most recent call last):
    796796            ...
    797797            ValueError: exponent (-2) must be strictly positive
    class WordMorphism(SageObject): 
    845845
    846846            sage: m = WordMorphism('a->ab,b->ba')
    847847            sage: n = WordMorphism({0:1,1:0,'a':5})
    848             sage: print m.extend_by(n)
     848            sage: m.extend_by(n)
    849849            WordMorphism: 0->1, 1->0, a->ab, b->ba
    850             sage: print n.extend_by(m)
     850            sage: n.extend_by(m)
    851851            WordMorphism: 0->1, 1->0, a->5, b->ba
    852             sage: print m.extend_by(m)
     852            sage: m.extend_by(m)
    853853            WordMorphism: a->ab, b->ba
    854854           
    855855        TESTS::
    class WordMorphism(SageObject): 
    889889        EXAMPLES::
    890890
    891891            sage: m = WordMorphism('a->b,b->a')
    892             sage: print m.restrict_domain('a')
     892            sage: m.restrict_domain('a')
    893893            WordMorphism: a->b
    894             sage: print m.restrict_domain('')
     894            sage: m.restrict_domain('')
    895895            WordMorphism:
    896             sage: print m.restrict_domain('A')
     896            sage: m.restrict_domain('A')
    897897            WordMorphism:
    898             sage: print m.restrict_domain('Aa')
     898            sage: m.restrict_domain('Aa')
    899899            WordMorphism: a->b
    900900
    901901        The input alphabet must be iterable::
    902902
    903             sage: print m.restrict_domain(66) 
     903            sage: m.restrict_domain(66)
    904904            Traceback (most recent call last):
    905905            ...
    906906            TypeError: 'sage.rings.integer.Integer' object is not iterable
    class WordMorphism(SageObject): 
    10861086       
    10871087        EXAMPLES::
    10881088
    1089             sage: print WordMorphism('6->ab,y->5,0->asd').reversal()
     1089            sage: WordMorphism('6->ab,y->5,0->asd').reversal()
    10901090            WordMorphism: 0->dsa, 6->ba, y->5
    1091             sage: print WordMorphism('a->ab,b->a').reversal()
     1091            sage: WordMorphism('a->ab,b->a').reversal()
    10921092            WordMorphism: a->ba, b->a
    10931093        """
    10941094        return WordMorphism(dict((key, w.reversal()) for (key, w) in self._morph.iteritems()))
    class WordMorphism(SageObject): 
    12551255            sage: WordMorphism({0:1,1:0,2:3}).is_involution()
    12561256            Traceback (most recent call last):
    12571257            ...
    1258             TypeError: self (=WordMorphism: 0->1, 1->0, 2->3) is not a endomorphism
     1258            TypeError: self (=0->1, 1->0, 2->3) is not a endomorphism
    12591259        """
    12601260        if not self.is_endomorphism():
    12611261            raise TypeError, "self (=%s) is not a endomorphism"%self
    class WordMorphism(SageObject): 
    13391339            sage: fibo = WordMorphism('a->ab,b->a')
    13401340            sage: fibo._check_primitive()
    13411341            False
    1342             sage: print WordMorphism({2:[4,5,6],3:[4,1,8]})     
     1342            sage: WordMorphism({2:[4,5,6],3:[4,1,8]})
    13431343            WordMorphism: 2->456, 3->418
    13441344            sage: WordMorphism({2:[4,5,6],3:[4,1,8]})._check_primitive()
    13451345            False
    class WordMorphism(SageObject): 
    14061406            sage: m.is_primitive()
    14071407            Traceback (most recent call last):
    14081408            ...
    1409             TypeError: self (=WordMorphism: a->bb, b->aac) is not a endomorphism
     1409            TypeError: self (=a->bb, b->aac) is not a endomorphism
    14101410            sage: m = WordMorphism('a->,b->',codomain=Words('ab'))
    14111411            sage: m.is_primitive()
    14121412            False
    class WordMorphism(SageObject): 
    16691669            sage: WordMorphism('a->aa,b->aac').fixed_point(letter='a')
    16701670            Traceback (most recent call last):
    16711671            ...
    1672             TypeError: self (=WordMorphism: a->aa, b->aac) is not a endomorphism
     1672            TypeError: self (=a->aa, b->aac) is not a endomorphism
    16731673        """
    16741674        if not self.is_endomorphism():
    16751675            raise TypeError, "self (=%s) is not a endomorphism"%self
    class WordMorphism(SageObject): 
    17821782            sage: m = WordMorphism('a->abcde')
    17831783            sage: m.conjugate(0) == m
    17841784            True
    1785             sage: print m.conjugate(1)           
     1785            sage: m.conjugate(1)
    17861786            WordMorphism: a->bcdea
    1787             sage: print m.conjugate(3)
     1787            sage: m.conjugate(3)
    17881788            WordMorphism: a->deabc
    1789             sage: print WordMorphism('').conjugate(4)
     1789            sage: WordMorphism('').conjugate(4)
    17901790            WordMorphism:
    17911791            sage: m = WordMorphism('a->abcde,b->xyz')
    1792             sage: print m.conjugate(2)
     1792            sage: m.conjugate(2)
    17931793            WordMorphism: a->cdeab, b->zxy
    17941794        """
    17951795        return WordMorphism(dict((key, w.conjugate(pos)) for (key, w) in self._morph.iteritems()))
    class WordMorphism(SageObject): 
    18851885        EXAMPLES::
    18861886
    18871887            sage: m = WordMorphism('a->abbab,b->abb')
    1888             sage: map(str, m.list_of_conjugates())
    1889             ['WordMorphism: a->babba, b->bab',
    1890             'WordMorphism: a->abbab, b->abb',
    1891             'WordMorphism: a->bbaba, b->bba',
    1892             'WordMorphism: a->babab, b->bab',
    1893             'WordMorphism: a->ababb, b->abb',
    1894             'WordMorphism: a->babba, b->bba',
    1895             'WordMorphism: a->abbab, b->bab']
    1896             sage: m = WordMorphism('a->aaa,b->aa')   
    1897             sage: map(str, m.list_of_conjugates())
    1898             ['WordMorphism: a->aaa, b->aa']
     1888            sage: m.list_of_conjugates()
     1889            [WordMorphism: a->babba, b->bab,
     1890            WordMorphism: a->abbab, b->abb,
     1891            WordMorphism: a->bbaba, b->bba,
     1892            WordMorphism: a->babab, b->bab,
     1893            WordMorphism: a->ababb, b->abb,
     1894            WordMorphism: a->babba, b->bba,
     1895            WordMorphism: a->abbab, b->bab]
     1896            sage: m = WordMorphism('a->aaa,b->aa')
     1897            sage: m.list_of_conjugates()
     1898            [WordMorphism: a->aaa, b->aa]
    18991899            sage: WordMorphism('').list_of_conjugates()
    1900             [Morphism from Words over Ordered Alphabet [] to Words over Ordered Alphabet []]
     1900            [WordMorphism: ]
    19011901            sage: m = WordMorphism('a->aba,b->aba')
    1902             sage: map(str, m.list_of_conjugates())
    1903             ['WordMorphism: a->baa, b->baa',
    1904             'WordMorphism: a->aab, b->aab',
    1905             'WordMorphism: a->aba, b->aba']
     1902            sage: m.list_of_conjugates()
     1903            [WordMorphism: a->baa, b->baa,
     1904            WordMorphism: a->aab, b->aab,
     1905            WordMorphism: a->aba, b->aba]
    19061906            sage: m = WordMorphism('a->abb,b->abbab,c->')
    1907             sage: map(str, m.list_of_conjugates())
    1908             ['WordMorphism: a->bab, b->babba, c->',
    1909             'WordMorphism: a->abb, b->abbab, c->',
    1910             'WordMorphism: a->bba, b->bbaba, c->',
    1911             'WordMorphism: a->bab, b->babab, c->',
    1912             'WordMorphism: a->abb, b->ababb, c->',
    1913             'WordMorphism: a->bba, b->babba, c->',
    1914             'WordMorphism: a->bab, b->abbab, c->']
     1907            sage: m.list_of_conjugates()
     1908            [WordMorphism: a->bab, b->babba, c->,
     1909            WordMorphism: a->abb, b->abbab, c->,
     1910            WordMorphism: a->bba, b->bbaba, c->,
     1911            WordMorphism: a->bab, b->babab, c->,
     1912            WordMorphism: a->abb, b->ababb, c->,
     1913            WordMorphism: a->bba, b->babba, c->,
     1914            WordMorphism: a->bab, b->abbab, c->]
    19151915        """
    19161916        if self.is_empty():
    19171917            return [self]
    class WordMorphism(SageObject): 
    20852085
    20862086            sage: sigma = WordMorphism({1:[2],2:[3],3:[1,2]})
    20872087            sage: sigma.dual_map()
    2088             E_1^*(WordMorphism: 1->2, 2->3, 3->12)
     2088            E_1^*(1->2, 2->3, 3->12)
    20892089
    20902090        ::
    20912091
  • sage/combinat/words/word_generators.py

    diff --git a/sage/combinat/words/word_generators.py b/sage/combinat/words/word_generators.py
    a b class WordGenerator(object): 
    16571657            sage: Word(words._s_adic_iterator([m1,m2,m3],'ecb'))
    16581658            Traceback (most recent call last):
    16591659            ...
    1660             ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 3-th letter (=b) under the 3-th morphism (=WordMorphism: a->cd, b->dc) should start with the 2-th letter (=c).
     1660            ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 3-th letter (=b) under the 3-th morphism (=a->cd, b->dc) should start with the 2-th letter (=c).
    16611661
    16621662        Two examples of infinite s-adic words::
    16631663
    class WordGenerator(object): 
    16841684            sage: Word(words._s_adic_iterator(repeat(sigma),repeat('a')))
    16851685            Traceback (most recent call last):
    16861686            ...
    1687             ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=a) under the 2-th morphism (=WordMorphism: a->ba, b->b) should start with the 1-th letter (=a).
     1687            ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=a) under the 2-th morphism (=a->ba, b->b) should start with the 1-th letter (=a).
    16881688
    16891689        AUTHORS:
    16901690
    class WordGenerator(object): 
    17761776            sage: words.s_adic([m1,m2,m3],'ecb')
    17771777            Traceback (most recent call last):
    17781778            ...
    1779             ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 3-th letter (=b) under the 3-th morphism (=WordMorphism: a->cd, b->dc) should start with the 2-th letter (=c).
     1779            ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 3-th letter (=b) under the 3-th morphism (=a->cd, b->dc) should start with the 2-th letter (=c).
    17801780
    17811781        Let's define the Thue-Morse morphism and the Fibonacci morphism
    17821782        which will be used below to illustrate more examples and let's import
    class WordGenerator(object): 
    18561856            sage: words.s_adic(repeat(sigma),repeat('a'))
    18571857            Traceback (most recent call last):
    18581858            ...
    1859             ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=a) under the 2-th morphism (=WordMorphism: a->ba, b->b) should start with the 1-th letter (=a).
     1859            ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=a) under the 2-th morphism (=a->ba, b->b) should start with the 1-th letter (=a).
    18601860            sage: words.s_adic([sigma],'a')
    18611861            word: ba
    18621862            sage: words.s_adic([sigma,sigma],'a')
    class WordGenerator(object): 
    18771877
    18781878            sage: x = lambda h:WordMorphism({1:[2],2:[3]+[1]*(h+1),3:[3]+[1]*h})
    18791879            sage: for h in [0,1,2,3]: print h, x(h)
    1880             0 WordMorphism: 1->2, 2->31, 3->3
    1881             1 WordMorphism: 1->2, 2->311, 3->31
    1882             2 WordMorphism: 1->2, 2->3111, 3->311
    1883             3 WordMorphism: 1->2, 2->31111, 3->3111
     1880            0 1->2, 2->31, 3->3
     1881            1 1->2, 2->311, 3->31
     1882            2 1->2, 2->3111, 3->311
     1883            3 1->2, 2->31111, 3->3111
    18841884            sage: w = Word(lambda n : valuation(n+1, 2) ); w
    18851885            word: 0102010301020104010201030102010501020103...
    18861886            sage: s = words.s_adic(w, repeat(3), x); s
    class WordGenerator(object): 
    19201920            sage: words.s_adic([fib,fib],'bb')
    19211921            Traceback (most recent call last):
    19221922            ...
    1923             ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=b) under the 2-th morphism (=WordMorphism: a->ab, b->a) should start with the 1-th letter (=b).
     1923            ValueError: The hypothesis of the algorithm used is not satisfied: the image of the 2-th letter (=b) under the 2-th morphism (=a->ab, b->a) should start with the 1-th letter (=b).
    19241924
    19251925        Test on different letters::
    19261926
  • sage/combinat/words/words.py

    diff --git a/sage/combinat/words/words.py b/sage/combinat/words/words.py
    a b class Words_over_Alphabet(Words_all): 
    925925        EXAMPLES::
    926926
    927927            sage: W = Words('ab')
    928             sage: print W.identity_morphism()
     928            sage: W.identity_morphism()
    929929            WordMorphism: a->a, b->b
    930930
    931931        ::
    932932
    933933            sage: W = Words(range(3))
    934             sage: print W.identity_morphism()
     934            sage: W.identity_morphism()
    935935            WordMorphism: 0->0, 1->1, 2->2
    936936
    937937        There is no support yet for infinite alphabet::
    class Words_over_OrderedAlphabet(Words_o 
    11391139       
    11401140            sage: W = Words('ab')
    11411141            sage: it = W.iter_morphisms()
    1142             sage: for _ in range(7): print it.next()
     1142            sage: for _ in range(7): it.next()
    11431143            WordMorphism: a->a, b->a
    11441144            WordMorphism: a->a, b->b
    11451145            WordMorphism: a->b, b->a
    class Words_over_OrderedAlphabet(Words_o 
    11521152       
    11531153            sage: W = Words('ab')
    11541154            sage: it = W.iter_morphisms(min_length=0)
    1155             sage: for _ in range(7): print it.next()
     1155            sage: for _ in range(7): it.next()
    11561156            WordMorphism: a->, b->
    11571157            WordMorphism: a->a, b->
    11581158            WordMorphism: a->b, b->
    class Words_over_OrderedAlphabet(Words_o 
    11641164        Iterator over morphisms where the sum of the lengths of the images
    11651165        of the letters is in a specific range::
    11661166
    1167             sage: for m in W.iter_morphisms((0, 3), min_length=0): print m
     1167            sage: for m in W.iter_morphisms((0, 3), min_length=0): m
    11681168            WordMorphism: a->, b->
    11691169            WordMorphism: a->a, b->
    11701170            WordMorphism: a->b, b->
    class Words_over_OrderedAlphabet(Words_o 
    11851185
    11861186        ::
    11871187
    1188             sage: for m in W.iter_morphisms( (2, 4) ): print m
     1188            sage: for m in W.iter_morphisms( (2, 4) ): m
    11891189            WordMorphism: a->a, b->a
    11901190            WordMorphism: a->a, b->b
    11911191            WordMorphism: a->b, b->a
    class Words_over_OrderedAlphabet(Words_o 
    12091209
    12101210        Iterator over morphisms with specific image lengths::
    12111211
    1212             sage: for m in W.iter_morphisms([0, 0]): print m
     1212            sage: for m in W.iter_morphisms([0, 0]): m
    12131213            WordMorphism: a->, b->
    1214             sage: for m in W.iter_morphisms([0, 1]): print m
     1214            sage: for m in W.iter_morphisms([0, 1]): m
    12151215            WordMorphism: a->, b->a
    12161216            WordMorphism: a->, b->b
    1217             sage: for m in W.iter_morphisms([2, 1]): print m
     1217            sage: for m in W.iter_morphisms([2, 1]): m
    12181218            WordMorphism: a->aa, b->a
    12191219            WordMorphism: a->aa, b->b
    12201220            WordMorphism: a->ab, b->a
    class Words_over_OrderedAlphabet(Words_o 
    12231223            WordMorphism: a->ba, b->b
    12241224            WordMorphism: a->bb, b->a
    12251225            WordMorphism: a->bb, b->b
    1226             sage: for m in W.iter_morphisms([2, 2]): print m
     1226            sage: for m in W.iter_morphisms([2, 2]): m
    12271227            WordMorphism: a->aa, b->aa
    12281228            WordMorphism: a->aa, b->ab
    12291229            WordMorphism: a->aa, b->ba
    class Words_over_OrderedAlphabet(Words_o 
    12441244        The codomain may be specified as well::
    12451245
    12461246            sage: Y = Words('xyz')
    1247             sage: for m in W.iter_morphisms([0, 2], codomain=Y): print m
     1247            sage: for m in W.iter_morphisms([0, 2], codomain=Y): m
    12481248            WordMorphism: a->, b->xx
    12491249            WordMorphism: a->, b->xy
    12501250            WordMorphism: a->, b->xz
    class Words_over_OrderedAlphabet(Words_o 
    12541254            WordMorphism: a->, b->zx
    12551255            WordMorphism: a->, b->zy
    12561256            WordMorphism: a->, b->zz
    1257             sage: for m in Y.iter_morphisms([0,2,1], codomain=W): print m
     1257            sage: for m in Y.iter_morphisms([0,2,1], codomain=W): m
    12581258            WordMorphism: x->, y->aa, z->a
    12591259            WordMorphism: x->, y->aa, z->b
    12601260            WordMorphism: x->, y->ab, z->a
    class Words_over_OrderedAlphabet(Words_o 
    12641264            WordMorphism: x->, y->bb, z->a
    12651265            WordMorphism: x->, y->bb, z->b
    12661266            sage: it = W.iter_morphisms(codomain=Y)
    1267             sage: for _ in range(10): print it.next()
     1267            sage: for _ in range(10): it.next()
    12681268            WordMorphism: a->x, b->x
    12691269            WordMorphism: a->x, b->y
    12701270            WordMorphism: a->x, b->z
    class Words_over_OrderedAlphabet(Words_o 
    12791279        TESTS::
    12801280
    12811281            sage: list(W.iter_morphisms([1,0]))
    1282             [Morphism from Words over Ordered Alphabet ['a', 'b'] to Words over Ordered Alphabet ['a', 'b'], Morphism from Words over Ordered Alphabet ['a', 'b'] to Words over Ordered Alphabet ['a', 'b']]
    1283             sage: list(W.iter_morphisms([0,0], codomain=Y))   
    1284             [Morphism from Words over Ordered Alphabet ['a', 'b'] to Words over Ordered Alphabet ['x', 'y', 'z']]
     1282            [WordMorphism: a->a, b->, WordMorphism: a->b, b->]
     1283            sage: list(W.iter_morphisms([0,0], codomain=Y))
     1284            [WordMorphism: a->, b->]
    12851285            sage: list(W.iter_morphisms([0, 1, 2]))
    12861286            Traceback (most recent call last):
    12871287            ...
    12881288            TypeError: arg (=[0, 1, 2]) must be an iterable of 2 integers
    1289             sage: list(W.iter_morphisms([0, 'a'])) 
     1289            sage: list(W.iter_morphisms([0, 'a']))
    12901290            Traceback (most recent call last):
    12911291            ...
    12921292            TypeError: arg (=[0, 'a']) must be an iterable of 2 integers
    1293             sage: list(W.iter_morphisms([0, 1], codomain='a')) 
     1293            sage: list(W.iter_morphisms([0, 1], codomain='a'))
    12941294            Traceback (most recent call last):
    12951295            ...
    12961296            TypeError: codomain (=a) must be an instance of Words_over_OrderedAlphabet
  • sage/sets/disjoint_set.pyx

    diff --git a/sage/sets/disjoint_set.pyx b/sage/sets/disjoint_set.pyx
    a b cdef class DisjointSet_of_integers(Disjo 
    524524            sage: d.union(4,1)
    525525            sage: e = d.element_to_root_dict(); e
    526526            {0: 0, 1: 4, 2: 2, 3: 2, 4: 4}
    527             sage: print WordMorphism(e)
     527            sage: WordMorphism(e)
    528528            WordMorphism: 0->0, 1->4, 2->2, 3->2, 4->4
    529529        """
    530530        d = {}
    cdef class DisjointSet_of_hashables(Disj 
    812812            sage: d.union(4,1)
    813813            sage: e = d.element_to_root_dict(); e
    814814            {0: 0, 1: 4, 2: 2, 3: 2, 4: 4}
    815             sage: print WordMorphism(e)
     815            sage: WordMorphism(e)
    816816            WordMorphism: 0->0, 1->4, 2->2, 3->2, 4->4
    817817        """
    818818        d = {}