Ticket #8604: trac_8604-corrections-sl.patch

File trac_8604-corrections-sl.patch, 6.4 KB (added by slabbe, 12 years ago)

Applies over the precedent patch

  • sage/combinat/words/nfactor_enumerable_word.py

    # HG changeset patch
    # User Sebastien Labbe <slabqc at gmail.com>
    # Date 1271618803 -7200
    # Node ID 431d538522b2442e9469b6bac4337559855e2c5e
    # Parent  828e5ca876f0acb873268f5054de6d90b219be64
    #8604: corrections after reviewer's comments
    
    diff --git a/sage/combinat/words/nfactor_enumerable_word.py b/sage/combinat/words/nfactor_enumerable_word.py
    a b class Word_nfactor_enumerable(Word_class 
    453453                g.delete_vertex(v)
    454454        return g
    455455
    456     def _left_special_factors_iterator(self, n=None):
     456    def left_special_factors_iterator(self, n=None):
    457457        r"""
    458458        Returns an iterator over the left special factors (of length n).
    459459
    class Word_nfactor_enumerable(Word_class 
    466466        -  ``n`` - integer (optional, default: None). If None, it returns
    467467           an iterator over all left special factors.
    468468
    469         EXAMPLES:
     469        EXAMPLES::
    470470
    471471            sage: alpha, beta, x = 0.54, 0.294, 0.1415
    472472            sage: w = words.CodingOfRotationWord(alpha, beta, x)[:40]
    473             sage: sorted(w._left_special_factors_iterator(3))
     473            sage: sorted(w.left_special_factors_iterator(3))
    474474            [word: 000, word: 010]
    475             sage: sorted(w._left_special_factors_iterator(4))
     475            sage: sorted(w.left_special_factors_iterator(4))
    476476            [word: 0000, word: 0101]
    477             sage: sorted(w._left_special_factors_iterator(5))
     477            sage: sorted(w.left_special_factors_iterator(5))
    478478            [word: 00000, word: 01010]
    479479        """
    480480        if n is None:
    481481            for i in range(self.length()):
    482                 for w in self._left_special_factors_iterator(i):
     482                for w in self.left_special_factors_iterator(i):
    483483                    yield w
    484484        else:
    485485            g = self.rauzy_graph(n)
    class Word_nfactor_enumerable(Word_class 
    505505
    506506        A list of words.
    507507
     508        .. WARNING::
     509
     510            This may not halt for infinite words having an infinite number
     511            of such factors. Use the iterator version of this function
     512            instead.
     513
    508514        EXAMPLES::
    509515
    510516            sage: alpha, beta, x = 0.54, 0.294, 0.1415
    class Word_nfactor_enumerable(Word_class 
    516522            3 [word: 000, word: 010]
    517523            4 [word: 0000, word: 1010]
    518524        """
    519         return list(self._left_special_factors_iterator(n))
     525        return list(self.left_special_factors_iterator(n))
    520526
    521     def _right_special_factors_iterator(self, n=None):
     527    def right_special_factors_iterator(self, n=None):
    522528        r"""
    523529        Returns an iterator over the right special factors (of length n).
    524530
    class Word_nfactor_enumerable(Word_class 
    531537        -  ``n`` - integer (optional, default: None). If None, it returns
    532538           an iterator over all right special factors.
    533539
    534         EXAMPLES:
     540        EXAMPLES::
    535541
    536542            sage: alpha, beta, x = 0.61, 0.54, 0.3
    537543            sage: w = words.CodingOfRotationWord(alpha, beta, x)[:40]
    538             sage: sorted(w._right_special_factors_iterator(3))
     544            sage: sorted(w.right_special_factors_iterator(3))
    539545            [word: 010, word: 101]
    540             sage: sorted(w._right_special_factors_iterator(4))
     546            sage: sorted(w.right_special_factors_iterator(4))
    541547            [word: 0101, word: 1010]
    542             sage: sorted(w._right_special_factors_iterator(5))
     548            sage: sorted(w.right_special_factors_iterator(5))
    543549            [word: 00101, word: 11010]
    544550        """
    545551        if n is None:
    546552            for i in range(self.length()):
    547                 for w in self._right_special_factors_iterator(i):
     553                for w in self.right_special_factors_iterator(i):
    548554                    yield w
    549555        else:
    550556            g = self.rauzy_graph(n)
    class Word_nfactor_enumerable(Word_class 
    570576
    571577        A list of words.
    572578
     579        .. WARNING::
     580
     581            This may not halt for infinite words having an infinite number
     582            of such factors. Use the iterator version of this function
     583            instead.
     584
    573585        EXAMPLES::
    574586
    575587            sage: w = words.ThueMorseWord()[:30]
    class Word_nfactor_enumerable(Word_class 
    580592            3 [word: 001, word: 010, word: 101, word: 110]
    581593            4 [word: 0110, word: 1001]
    582594        """
    583         return list(self._right_special_factors_iterator(n))
     595        return list(self.right_special_factors_iterator(n))
    584596
    585     def _bispecial_factors_iterator(self, n=None):
     597    def bispecial_factors_iterator(self, n=None):
    586598        r"""
    587599        Returns an iterator over the bispecial factors (of length n).
    588600
    class Word_nfactor_enumerable(Word_class 
    594606        -  ``n`` - integer (optional, default: None). If None, it returns
    595607           an iterator over all bispecial factors.
    596608
    597         EXAMPLES:
     609        EXAMPLES::
    598610           
    599611            sage: w = words.ThueMorseWord()[:30]
    600612            sage: for i in range(10):
    601             ...     for u in w._bispecial_factors_iterator(i):
     613            ...     for u in w.bispecial_factors_iterator(i):
    602614            ...         print i,u
    603615            0 word:
    604616            1 word: 1
    class Word_nfactor_enumerable(Word_class 
    615627
    616628        ::
    617629
    618             sage: for u in w._bispecial_factors_iterator(): u
     630            sage: for u in w.bispecial_factors_iterator(): u
    619631            word:
    620632            word: 1
    621633            word: 0
    class Word_nfactor_enumerable(Word_class 
    631643        """
    632644        if n is None:
    633645            for i in range(self.length()):
    634                 for w in self._bispecial_factors_iterator(i):
     646                for w in self.bispecial_factors_iterator(i):
    635647                    yield w
    636648        else:
    637649            g = self.rauzy_graph(n)
    class Word_nfactor_enumerable(Word_class 
    657669
    658670        A list of words.
    659671
     672        .. WARNING::
     673
     674            This may not halt for infinite words having an infinite number
     675            of such factors. Use the iterator version of this function
     676            instead.
     677
    660678        EXAMPLES::
    661679           
    662680            sage: w = words.FibonacciWord()[:30]
    class Word_nfactor_enumerable(Word_class 
    678696            8 [word: 10010110]
    679697            9 []
    680698        """
    681         return list(self._bispecial_factors_iterator(n))
     699        return list(self.bispecial_factors_iterator(n))
    682700
    683701    def number_of_left_special_factors(self, n):
    684702        r"""