Ticket #7405: trac_7405_words_change_print_to_default-sl.patch

File trac_7405_words_change_print_to_default-sl.patch, 22.8 KB (added by Sébastien Labbé, 13 years ago)
  • sage/combinat/words/morphism.py

    # HG changeset patch
    # User Sebastien Labbe <slabqc@gmail.com>
    # Date 1257529749 -3600
    # Node ID 8bfe4395fe1242b0761eafba4ca03a79f85f51ce
    # Parent  6791cd02aa299c609e232549acb707de459530e5
    #7405: Changes the print of predefined words to default.
    Corrects a bug in the multiplication of word morphisms.
    Creation of Fibonacci word from function.
    Add missing doctests to word.py.
    
    diff -r 6791cd02aa29 -r 8bfe4395fe12 sage/combinat/words/morphism.py
    a b  
    5454
    5555    sage: fix = m.fixed_point('x')
    5656    sage: fix
    57     Fixed point beginning with 'x' of the morphism WordMorphism: s->xyss, x->xyxsxss, y->ys
     57    word: xyxsxssysxyxsxssxyssxyxsxssxyssxyssysxys...
    5858    sage: fix.length()
    5959    +Infinity
    60     sage: fix[100:]
    61     word: ysxyxsxssxyssxyxsxssxyssxyssxyxsxssysxys...
    6260
    6361Incidence matrix::
    6462
     
    378376        3. The infinitely iterated image of a letter::
    379377
    380378            sage: tm('a', oo)
    381             Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->ba
     379            word: abbabaabbaababbabaababbaabbabaabbaababba...
    382380
    383381        4. The image of an infinite word::
    384382
     
    521519            sage: p2.codomain()
    522520            Words over Ordered Alphabet ['a', 'b']
    523521
     522        ::
     523
     524            sage: m = WordMorphism('0->a,1->b')
     525            sage: n = WordMorphism('a->c,b->e',codomain=Words('abcde'))
     526            sage: p = n * m
     527            sage: p.codomain()
     528            Words over Ordered Alphabet ['a', 'b', 'c', 'd', 'e']
     529
    524530        TESTS::
    525531
    526532            sage: m = WordMorphism('a->b,b->c,c->a')
     
    533539        """
    534540        #TODO : Est-ce que c'est le comportement que l'on veut pour le produit
    535541        #par le morphisme vide? Voir lignes ci-haut.
    536         return WordMorphism(dict((key, self(w)) for (key, w) in other._morph.iteritems()))
     542        return WordMorphism(dict((key, self(w)) for (key, w) in other._morph.iteritems()), codomain=self.codomain())
    537543   
    538544    def __pow__(self, exp):
    539545        r"""
     
    11951201        1. Infinite fixed point::
    11961202
    11971203            sage: WordMorphism('a->ab,b->ba').fixed_point(letter='a')
    1198             Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->ba
     1204            word: abbabaabbaababbabaababbaabbabaabbaababba...
    11991205            sage: WordMorphism('a->ab,b->a').fixed_point(letter='a')
    1200             Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->a
     1206            word: abaababaabaababaababaabaababaabaababaaba...
    12011207            sage: WordMorphism('a->ab,b->b,c->ba').fixed_point(letter='a')
    1202             Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->b, c->ba
     1208            word: abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
    12031209
    12041210        2. Infinite fixed point of an erasing morphism::
    12051211
    12061212            sage: WordMorphism('a->ab,b->,c->ba').fixed_point(letter='a')
    1207             Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->, c->ba
     1213            word: ab
    12081214           
    12091215        3. Finite fixed point::
    12101216
     
    12151221
    12161222            sage: m = WordMorphism('a->abc,b->,c->')
    12171223            sage: fp = m.fixed_point('a'); fp
    1218             Fixed point beginning with 'a' of the morphism WordMorphism: a->abc, b->, c->
    1219             sage: fp[:10]
    12201224            word: abc
    12211225            sage: m = WordMorphism('a->ba,b->')
    12221226            sage: m('ba')
     
    12281232
    12291233            sage: m = WordMorphism('a->ba,b->ab')
    12301234            sage: (m^2).fixed_point(letter='a')
    1231             Fixed point beginning with 'a' of the morphism WordMorphism: a->abba, b->baab
     1235            word: abbabaabbaababbabaababbaabbabaabbaababba...
    12321236           
    12331237        TESTS::
    12341238
     
    12621266           
    12631267        # Construct the word.
    12641268        w = self.codomain()(self.letter_iterator(letter), datatype='iter')
    1265         w.rename("Fixed point beginning with %r of the morphism %s"%(letter,self))
    12661269        return w
    12671270
    12681271    def list_fixed_points(self):
  • sage/combinat/words/word.py

    diff -r 6791cd02aa29 -r 8bfe4395fe12 sage/combinat/words/word.py
    a b  
    127127    sage: mu = WordMorphism('a->ab,b->ba'); print mu
    128128    WordMorphism: a->ab, b->ba
    129129    sage: mu.fixed_point('a')
    130     Fixed point beginning with 'a' of the morphism WordMorphism: a->ab, b->ba
     130    word: abbabaabbaababbabaababbaabbabaabbaababba...
    131131
    132132Infinite words in a specific combinatorial class::
    133133
     
    833833        For infinite words::
    834834
    835835            sage: t = words.ThueMorseWord([0,1]); t
    836             Thue-Morse word over Ordered Alphabet [0, 1]
     836            word: 0110100110010110100101100110100110010110...
    837837            sage: t.apply_morphism({0:8,1:9})
    838838            word: 8998988998898998988989988998988998898998...
    839839        """
  • sage/combinat/words/word_generators.py

    diff -r 6791cd02aa29 -r 8bfe4395fe12 sage/combinat/words/word_generators.py
    a b  
    1818EXAMPLES::
    1919
    2020    sage: t = words.ThueMorseWord(); t
    21     Thue-Morse word over Ordered Alphabet [0, 1]
     21    word: 0110100110010110100101100110100110010110...
    2222"""
    2323#*****************************************************************************
    2424#       Copyright (C) 2008 Franco Saliola <saliola@gmail.com>,
     
    9393
    9494    EXAMPLES::
    9595
    96         sage: w = words.LowerChristoffelWord(1,0); w
    97         Lower Christoffel word of slope 1/0 over Ordered Alphabet [0, 1]
    98         sage: print w
    99         word: 1
    100    
    101     ::
    102        
    103         sage: w = words.LowerChristoffelWord(0,1,'xy'); w
    104         Lower Christoffel word of slope 0/1 over Ordered Alphabet ['x', 'y']
    105         sage: print w
    106         word: x
    107    
    108     ::
    109        
    110         sage: w = words.LowerChristoffelWord(1,1); w
    111         Lower Christoffel word of slope 1/1 over Ordered Alphabet [0, 1]
    112         sage: print w
    113         word: 01
    114    
    115     ::
    116        
    117         sage: w = words.LowerChristoffelWord(4,7); w
    118         Lower Christoffel word of slope 4/7 over Ordered Alphabet [0, 1]
    119         sage: print w
     96        sage: words.LowerChristoffelWord(4,7)
    12097        word: 00100100101
    12198   
    12299    ::
    123100
    124         sage: w = words.LowerChristoffelWord(4,7,alphabet='ab'); w
    125         Lower Christoffel word of slope 4/7 over Ordered Alphabet ['a', 'b']
    126         sage: print w
     101        sage: words.LowerChristoffelWord(4,7,alphabet='ab')
    127102        word: aabaabaabab
     103
     104    TESTS::
     105       
     106        sage: words.LowerChristoffelWord(1,0)
     107        word: 1
     108        sage: words.LowerChristoffelWord(0,1,'xy')
     109        word: x
     110        sage: words.LowerChristoffelWord(1,1)
     111        word: 01
    128112    """
    129113
    130114    def __init__(self, p, q, alphabet=(0,1)):
     
    167151        self.__p = p
    168152        self.__q = q
    169153
    170     def __repr__(self):
    171         r"""
    172         EXAMPLES::
    173 
    174             sage: w = words.LowerChristoffelWord(4,7,alphabet='ab'); w
    175             Lower Christoffel word of slope 4/7 over Ordered Alphabet ['a', 'b']
    176         """
    177         return "Lower Christoffel word of slope %s/%s over %s" % (self.__p, self.__q, self.parent().alphabet())
    178 
    179154    def markoff_number(self):
    180155        r"""
    181156        Returns the Markoff number associated to the Christoffel word self.
     
    226201            sage: w = words.LowerChristoffelWord(51,37)
    227202            sage: w1, w2 = w.standard_factorization()
    228203            sage: w1
    229             Lower Christoffel word of slope 11/8 over Ordered Alphabet [0, 1]
     204            word: 0101011010101101011
    230205            sage: w2
    231             Lower Christoffel word of slope 40/29 over Ordered Alphabet [0, 1]
     206            word: 0101011010101101011010101101010110101101...
    232207            sage: w1 * w2 == w
    233208            True
    234209        """
     
    263238            sage: from sage.combinat.words.word_generators import ChristoffelWord_Lower
    264239            sage: w = ChristoffelWord_Lower(1,0); w
    265240            doctest:1: DeprecationWarning: ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead
    266             Lower Christoffel word of slope 1/0 over Ordered Alphabet [0, 1]
     241            word: 1
    267242        """
    268243        from sage.misc.misc import deprecation
    269244        deprecation("ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead")
     
    302277        Thue-Morse word::
    303278
    304279            sage: t = words.ThueMorseWord(); t
    305             Thue-Morse word over Ordered Alphabet [0, 1]
    306             sage: print t[:50]
    307             word: 01101001100101101001011001101001100101100110100101
     280            word: 0110100110010110100101100110100110010110...
    308281
    309282        Thue-Morse word on other alphabets::
    310283
    311284            sage: t = words.ThueMorseWord('ab'); t
    312             Thue-Morse word over Ordered Alphabet ['a', 'b']
    313             sage: print t[:50]
    314             word: abbabaabbaababbabaababbaabbabaabbaababbaabbabaabab
     285            word: abbabaabbaababbabaababbaabbabaabbaababba...
    315286
    316287        ::
    317288
    318             sage: t = words.ThueMorseWord(['L1', 'L2']); t
    319             Thue-Morse word over Ordered Alphabet ['L1', 'L2']
    320             sage: words.ThueMorseWord(['L1','L2'])[:8]
     289            sage: t = words.ThueMorseWord(['L1', 'L2'])
     290            sage: t[:8]
    321291            word: L1,L2,L2,L1,L2,L1,L1,L2
    322292
    323293        Generalized Thue Morse word::
    324294
    325295            sage: words.ThueMorseWord(alphabet=(0,1,2), base=2)
    326             Generalized Thue-Morse word using base 2 over Ordered Alphabet [0, 1, 2]
     296            word: 0112122012202001122020012001011212202001...
    327297            sage: t = words.ThueMorseWord(alphabet=(0,1,2), base=5); t
    328             Generalized Thue-Morse word using base 5 over Ordered Alphabet [0, 1, 2]
    329             sage: t[:20]
    330             word: 01201120122012001201
     298            word: 0120112012201200120112012120122012001201...
    331299            sage: t[100:130].critical_exponent()
    332300            10/3
    333301
     
    354322
    355323        alphabet = w.parent().alphabet()
    356324        m = w.parent().size_of_alphabet()
    357         if base == 2 and m == 2 :
    358             name = "Thue-Morse word over %s" % alphabet
    359         elif base < 2 or m < 2 :
     325        if base < 2 or m < 2 :
    360326            raise ValueError, "base (=%s) and size of alphabet (=%s) must be at least 2"%(base, m)
    361         else:
    362             name = "Generalized Thue-Morse word using base %s over %s" %(base, alphabet)
    363         w.rename(name)
    364327        return w
    365328   
    366329    def _ThueMorseWord_nth_digit(self, n, alphabet=(0,1), base=2):
     
    420383        -  ``alphabet`` - any container of length two that is suitable to
    421384           build an instance of OrderedAlphabet (list, tuple, str, ...)
    422385        -  ``construction_method`` - can be any of the following:
    423            "recursive", "fixed point" (see below for definitions).
     386           "recursive", "fixed point", "function" (see below for definitions).
    424387
    425388        Recursive construction: the Fibonacci word is the limit of the
    426389        following sequence of words: `S_0 = 0`, `S_1 = 01`,
     
    436399        |    move to the next letter of the word.
    437400        |
    438401
     402        Function: Over the alphabet `\{1, 2\}`, the n-th letter of the
     403        Fibonacci word is
     404        `\lfloor (n+2) \varphi \rfloor - \lfloor (n+1) \varphi \rfloor`
     405        where `\varphi=(1+\sqrt{5})/2` is the golden ratio.
     406
    439407        EXAMPLES::
    440408
    441409            sage: w = words.FibonacciWord(construction_method="recursive"); w
    442             Fibonacci word over Ordered Alphabet [0, 1], defined recursively
    443             sage: print w[:99]
    444             word: 010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001
     410            word: 0100101001001010010100100101001001010010...
    445411
    446412        ::
    447413
    448414            sage: v = words.FibonacciWord(construction_method="recursive", alphabet='ab'); v
    449             Fibonacci word over Ordered Alphabet ['a', 'b'], defined recursively
    450             sage: print v[:99]
    451             word: abaababaabaababaababaabaababaabaababaababaabaababaababaabaababaabaababaababaabaababaabaababaababaab
     415            word: abaababaabaababaababaabaababaabaababaaba...
     416       
     417        ::
     418       
     419            sage: u = words.FibonacciWord(construction_method="fixed point"); u
     420            word: 0100101001001010010100100101001001010010...
    452421
    453422        ::
    454423
    455             sage: u = words.FibonacciWord(construction_method="fixed point"); u
    456             Fibonacci word over Ordered Alphabet [0, 1], defined as the fixed point of a morphism
    457             sage: print u[:99]
    458             word: 010010100100101001010010010100100101001010010010100101001001010010010100101001001010010010100101001
     424            sage: words.FibonacciWord(construction_method="fixed point", alphabet=[4, 1])
     425            word: 4144141441441414414144144141441441414414...
    459426
    460427        ::
    461428
    462             sage: x = words.FibonacciWord(construction_method="fixed point", alphabet=[4, 1]); x
    463             Fibonacci word over Ordered Alphabet [1, 4], defined as the fixed point of a morphism
    464             sage: print x[:99]
    465             word: 414414144144141441414414414144144141441414414414144141441441414414414144141441441414414414144141441
     429            sage: words.FibonacciWord([0,1], 'function')
     430            word: 0100101001001010010100100101001001010010...
     431            sage: words.FibonacciWord('ab', 'function')
     432            word: abaababaabaababaababaabaababaabaababaaba...
    466433
    467434        TESTS::
    468435
     
    481448            ...
    482449            TypeError: alphabet does not contain two distinct elements
    483450        """
    484         if len(set(alphabet)) != 2:
     451        from sage.combinat.words.alphabet import Alphabet
     452        alphabet = Alphabet(alphabet)
     453        if alphabet.cardinality() != 2:
    485454            raise TypeError, "alphabet does not contain two distinct elements"
     455
     456        a,b = alphabet
     457        W = Words(alphabet)
     458
    486459        if construction_method == "recursive":
    487             w = Words(alphabet)(\
    488                     self._FibonacciWord_RecursiveConstructionIterator(alphabet), \
     460            w = W(self._FibonacciWord_RecursiveConstructionIterator(alphabet), \
    489461                    datatype='iter')
    490             w.rename("Fibonacci word over %s, defined recursively" % w.parent().alphabet())
    491462            return w
     463
    492464        elif construction_method in ("fixed point", "fixed_point"):
    493             d = {alphabet[1]:[alphabet[0]],alphabet[0]:[alphabet[0],alphabet[1]]}
    494             w = self.FixedPointOfMorphism(d, alphabet[0])
    495             w.rename("Fibonacci word over %s, defined as the fixed point of a morphism" % w.parent().alphabet())
     465            d = {b:[a],a:[a,b]}
     466            w = self.FixedPointOfMorphism(d, a)
    496467            return w
     468
     469        elif construction_method == "function":
     470            from sage.functions.other import sqrt, floor
     471            phi = (1 + sqrt(5))/2 # the golden ratio
     472            f = lambda n:a if floor((n+2)*phi) - floor((n+1)*phi) == 2 else b
     473            return W(f)
     474
    497475        else:
    498476            raise NotImplementedError
    499477
     
    545523
    546524            sage: mu = {0:[0,1], 1:[1,0]}
    547525            sage: tm = words.FixedPointOfMorphism(mu,0); tm
    548             Fixed point beginning with 0 of the morphism WordMorphism: 0->01, 1->10
     526            word: 0110100110010110100101100110100110010110...
    549527            sage: TM = words.ThueMorseWord()
    550528            sage: tm[:1000] == TM[:1000]
    551529            True
     
    554532
    555533            sage: mu = {0:[0,1], 1:[0]}
    556534            sage: f = words.FixedPointOfMorphism(mu,0); f
    557             Fixed point beginning with 0 of the morphism WordMorphism: 0->01, 1->0
     535            word: 0100101001001010010100100101001001010010...
    558536            sage: F = words.FibonacciWord(); F
    559             Fibonacci word over Ordered Alphabet [0, 1], defined recursively
     537            word: 0100101001001010010100100101001001010010...
    560538            sage: f[:1000] == F[:1000]
    561539            True
    562540   
    563541        ::
    564542
    565543            sage: fp = words.FixedPointOfMorphism('a->abc,b->,c->','a'); fp
    566             Fixed point beginning with 'a' of the morphism WordMorphism: a->abc, b->, c->
    567             sage: fp[:10]
    568544            word: abc
    569545        """
    570546        return WordMorphism(morphism).fixed_point(letter=first_letter)
     
    583559
    584560            sage: alpha = 0.45
    585561            sage: beta = 0.48
    586             sage: w = words.CodingOfRotationWord(0.45, 0.48); w
    587             Coding of rotation with parameters (0.450000000000000, 0.480000000000000, 0)
    588             sage: w[:100]
     562            sage: words.CodingOfRotationWord(0.45, 0.48)
    589563            word: 1101010101001010101011010101010010101010...
    590564
    591565        ::
    592566
    593             sage: w = words.CodingOfRotationWord(0.45, 0.48, alphabet='xy')
    594             sage: w[:100]
     567            sage: words.CodingOfRotationWord(0.45, 0.48, alphabet='xy')
    595568            word: yyxyxyxyxyxxyxyxyxyxyyxyxyxyxyxxyxyxyxyx...
    596569
    597570        TESTS::
     
    612585        from functools import partial
    613586        f = partial(self._CodingOfRotationWord_function,alpha=alpha,beta=beta,x=x,alphabet=alphabet)
    614587        w = Words(alphabet)(f, datatype='callable')
    615         w.rename("Coding of rotation with parameters (%s, %s, %s)"%(alpha,beta,x))
    616588        return w
    617589
    618590    def _CodingOfRotationWord_function(self, n, alpha, beta, x=0, alphabet=(0,1)):
     
    670642            ...     while True: yield 1
    671643            ...
    672644            sage: F = words.CharacteristicSturmianWord(cf()); F
    673             Characteristic Sturmian word over Ordered Alphabet [0, 1], defined recursively
     645            word: 0100101001001010010100100101001001010010...
    674646            sage: Fib = words.FibonacciWord(); Fib
    675             Fibonacci word over Ordered Alphabet [0, 1], defined recursively
     647            word: 0100101001001010010100100101001001010010...
    676648            sage: F[:10000] == Fib[:10000]
    677649            True
    678650
     
    683655            ...     while True: yield 1
    684656            ...
    685657            sage: G = words.CharacteristicSturmianWord(cf(),'rs'); G
    686             Characteristic Sturmian word over Ordered Alphabet ['r', 's'], defined recursively
     658            word: rsrrsrsrrsrrsrsrrsrsrrsrrsrsrrsrrsrsrrsr...
    687659            sage: print G[:50]
    688660            word: rsrrsrsrrsrrsrsrrsrsrrsrrsrsrrsrrsrsrrsrsrrsrrsrsr
    689661
     
    703675        w = Words(alphabet)( \
    704676                self._CharacteristicSturmianWord_LetterIterator(d,alphabet), \
    705677                datatype='iter')
    706         w.rename("Characteristic Sturmian word over %s, defined recursively" \
    707                 % w.parent().alphabet())
    708678        return w
    709679
    710680    def _CharacteristicSturmianWord_LetterIterator(self, d, alphabet=(0,1)):
     
    757727        EXAMPLES::
    758728
    759729            sage: Fibonacci = words.StandardEpisturmianWord(Words('ab')('ab')); Fibonacci
    760             Standard episturmian word over Ordered Alphabet ['a', 'b']
    761             sage: Fibonacci[:25]
    762             word: abaababaabaababaababaabaa
     730            word: abaababaabaababaababaabaababaabaababaaba...
    763731            sage: Tribonacci = words.StandardEpisturmianWord(Words('abc')('abc')); Tribonacci
    764             Standard episturmian word over Ordered Alphabet ['a', 'b', 'c']
    765             sage: Tribonacci[:25]
    766             word: abacabaabacababacabaabaca
     732            word: abacabaabacababacabaabacabacabaabacababa...
    767733            sage: S = words.StandardEpisturmianWord(Words('abcd')('aabcabada')); S
    768             Standard episturmian word over Ordered Alphabet ['a', 'b', 'c', 'd']
    769             sage: print S[:75]
    770             word: aabaacaabaaabaacaabaabaacaabaaabaacaabaaabaacaabaabaacaabaaabaacaabaadaabaa
     734            word: aabaacaabaaabaacaabaabaacaabaaabaacaabaa...
    771735            sage: S = words.StandardEpisturmianWord(Fibonacci); S
    772             Standard episturmian word over Ordered Alphabet ['a', 'b']
     736            word: abaabaababaabaabaababaabaababaabaabaabab...
    773737            sage: S[:25]
    774738            word: abaabaababaabaabaababaaba
    775739            sage: S = words.StandardEpisturmianWord(Tribonacci); S
    776             Standard episturmian word over Ordered Alphabet ['a', 'b', 'c']
    777             sage: S[:25]
    778             word: abaabacabaabaabacabaababa
     740            word: abaabacabaabaabacabaababaabacabaabaabaca...
    779741            sage: words.StandardEpisturmianWord(123)
    780742            Traceback (most recent call last):
    781743            ...
     
    800762        epistandard = directive_word.parent()(\
    801763                self._StandardEpisturmianWord_LetterIterator(directive_word), \
    802764                datatype='iter')
    803         epistandard.rename("Standard episturmian word over %s" % \
    804                 epistandard.parent().alphabet())
    805765        return epistandard
    806766
    807767    def _StandardEpisturmianWord_LetterIterator(self, directive_word):
     
    954914       
    955915        EXAMPLES::
    956916       
    957             sage: w = words.UpperChristoffelWord(1,0); w
    958             Upper Christoffel word of slope 1/0 over Ordered Alphabet [0, 1]
    959             sage: print w
     917            sage: words.UpperChristoffelWord(1,0)
    960918            word: 1
    961919       
    962920        ::
    963921       
    964             sage: w = words.UpperChristoffelWord(0,1); w
    965             Upper Christoffel word of slope 0/1 over Ordered Alphabet [0, 1]
    966             sage: print w
     922            sage: words.UpperChristoffelWord(0,1)
    967923            word: 0
    968924       
    969925        ::
    970926       
    971             sage: w = words.UpperChristoffelWord(1,1); w
    972             Upper Christoffel word of slope 1/1 over Ordered Alphabet [0, 1]
    973             sage: print w
     927            sage: words.UpperChristoffelWord(1,1)
    974928            word: 10
    975929       
    976930        ::
    977931       
    978             sage: w = words.UpperChristoffelWord(4,7); w
    979             Upper Christoffel word of slope 4/7 over Ordered Alphabet [0, 1]
    980             sage: print w
     932            sage: words.UpperChristoffelWord(4,7)
    981933            word: 10100100100
    982934       
    983935        TESTS:::
     
    988940            ValueError: alphabet must contain exactly two distinct elements
    989941        """
    990942        w = words.LowerChristoffelWord(p, q, alphabet=alphabet).reversal()
    991         w.rename("Upper Christoffel word of slope %s/%s over %s" % (p, q, w.parent().alphabet()))
    992943        return w
    993944
    994945    @cached_method
  • sage/combinat/words/words.py

    diff -r 6791cd02aa29 -r 8bfe4395fe12 sage/combinat/words/words.py
    a b  
    127127    """
    128128    @lazy_attribute
    129129    def _element_classes(self):
     130        r"""
     131        Returns a dictionary that gives the class of the element of self.
     132
     133        The word may be finite, infinite or of unknown length.
     134        Its data may be str, list, tuple, a callable or an iterable.
     135        For callable and iterable, the data may be cached.
     136
     137        TESTS::
     138
     139            sage: d = Words()._element_classes
     140            sage: type(d)
     141            <type 'dict'>
     142            sage: len(d)
     143            13
     144            sage: e = Words('abcdefg')._element_classes
     145            sage: d == e
     146            True
     147        """
    130148        import sage.combinat.words.word as word
    131149        return {
    132150            'FiniteWord_list': word.FiniteWord_list,