Changeset 2337:361b4570d4ff


Ignore:
Timestamp:
01/11/07 17:31:58 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Parents:
2335:f4df42f5af11 (diff), 2336:ca018d0ae6ed (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Bunches of little things to fix doctest problems.

Location:
sage
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • sage/combinat/combinat.py

    r2114 r2337  
    381381        Traceback (most recent call last): 
    382382        ... 
    383         TypeError         
     383        TypeError: no implicit coercion of element to the rational numbers 
    384384         
    385385    There was a conjecture that the sequence $L_n$ defined by  
  • sage/combinat/combinat.py

    r2114 r2337  
    381381        Traceback (most recent call last): 
    382382        ... 
    383         TypeError         
     383        TypeError: no implicit coercion of element to the rational numbers 
    384384         
    385385    There was a conjecture that the sequence $L_n$ defined by  
  • sage/libs/pari/gen.pyx

    r1816 r2337  
    884884            remainder, with respect to v (to main variable if v is 
    885885            omitted). 
    886  
    887         sage:  
    888886        """ 
    889887        t0GEN(y) 
  • sage/libs/pari/gen.pyx

    r1816 r2337  
    884884            remainder, with respect to v (to main variable if v is 
    885885            omitted). 
    886  
    887         sage:  
    888886        """ 
    889887        t0GEN(y) 
  • sage/matrix/matrix0.pyx

    r2320 r2337  
    55 
    66EXAMPLES: 
    7  
     7    sage: matrix(2,[1,2,3,4]) 
     8    [1 2] 
     9    [3 4]     
    810""" 
    911 
     
    16431645        """ 
    16441646        Add two matrices with the same parent. 
    1645  
    1646         EXAMPLES: 
    1647             sage:  
    16481647        """ 
    16491648        cdef Py_ssize_t i, j 
     
    16631662            sage: a = matrix(2,2, [1,2,x*y,y*x]) 
    16641663            sage: b = matrix(2,2, [1,2,y*x,y*x]) 
    1665          
    1666  
    16671664        """ 
    16681665        return self._add_c_impl(right._left_scalar_multiply(-1)) 
     
    21332130        EXAMPLES: 
    21342131        EXAMPLE cmparing sparse and dense matrices: 
    2135             sage:  
    21362132            sage: matrix(QQ,2,range(4)) == matrix(QQ,2,range(4),sparse=True) 
    21372133            True 
  • sage/matrix/matrix0.pyx

    r2183 r2337  
    55 
    66EXAMPLES: 
    7  
     7    sage: matrix(2,[1,2,3,4]) 
     8    [1 2] 
     9    [3 4]     
    810""" 
    911 
     
    16431645        """ 
    16441646        Add two matrices with the same parent. 
    1645  
    1646         EXAMPLES: 
    1647             sage:  
    16481647        """ 
    16491648        cdef Py_ssize_t i, j 
     
    16631662            sage: a = matrix(2,2, [1,2,x*y,y*x]) 
    16641663            sage: b = matrix(2,2, [1,2,y*x,y*x]) 
    1665          
    1666  
    16671664        """ 
    16681665        return self._add_c_impl(right._left_scalar_multiply(-1)) 
     
    21002097        if n < 0: 
    21012098            return (~self)**(-n) 
    2102         ans = self.parent()(1) 
     2099        if n == 1: 
     2100            return self 
     2101        ans = None 
    21032102        apow = self 
    21042103        while n != 0: 
    21052104            if n%2 != 0: 
    2106                 ans = ans * apow 
     2105                if ans is None: 
     2106                    ans = apow 
     2107                else: 
     2108                    ans = ans * apow 
    21072109            n = n/2 
    21082110            if n == 0:  # to not waste time doing an extra multiplication/increment 
     
    21282130        EXAMPLES: 
    21292131        EXAMPLE cmparing sparse and dense matrices: 
    2130             sage:  
    21312132            sage: matrix(QQ,2,range(4)) == matrix(QQ,2,range(4),sparse=True) 
    21322133            True 
  • sage/modular/modsym/ambient.py

    r2288 r2337  
    764764            sage: M = ModularSymbols(Gamma0(22), 2); M 
    765765            Modular Symbols space of dimension 7 for Gamma_0(22) of weight 2 with sign 0 over Rational Field 
    766             sage: for b, e in M.factorization(): 
     766            sage: M.factorization(): 
    767767            ...    print b.dimension(), b.level(), e 
    768768            1 11 2 
     
    798798            2 26 1 
    799799            2 26 1 
    800              
     800 
    801801        An example with level divisible by a square: 
    802802            sage: M = ModularSymbols(Gamma0(2*9),2); M 
     
    11101110        return self.__integral_structure 
    11111111     
    1112              
    11131112 
    11141113class ModularSymbolsAmbient_wtk_g0(ModularSymbolsAmbient): 
  • sage/modular/modsym/ambient.py

    r2288 r2337  
    764764            sage: M = ModularSymbols(Gamma0(22), 2); M 
    765765            Modular Symbols space of dimension 7 for Gamma_0(22) of weight 2 with sign 0 over Rational Field 
    766             sage: for b, e in M.factorization(): 
     766            sage: M.factorization(): 
    767767            ...    print b.dimension(), b.level(), e 
    768768            1 11 2 
     
    798798            2 26 1 
    799799            2 26 1 
    800              
     800 
    801801        An example with level divisible by a square: 
    802802            sage: M = ModularSymbols(Gamma0(2*9),2); M 
     
    11101110        return self.__integral_structure 
    11111111     
    1112              
    11131112 
    11141113class ModularSymbolsAmbient_wtk_g0(ModularSymbolsAmbient): 
  • sage/modular/ssmod/ssmod.py

    r2159 r2337  
    1313    sage: D = a.decomposition() 
    1414    sage: D[:3] 
    15         [(Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    16         Basis matrix: 
    17         [ 0  0  0  1 96 96  1  0 95  1  1  1  1 95  2 96  0  0 96 96  0  0 96  2 96 96  2  0  0  1  1 95  0], 1), (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    18         Basis matrix: 
    19         [ 0  1 96 16 75 22 81  0  0 17 17 80 80  0  0 16  1 40 74 23 57 96 81  0 23 74  0  0  0 24 73  0  0], 1), (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    20         Basis matrix: 
    21         [ 0  1 96 90 90  7  7  0  0  6 91  6 91  0  0  7 13  0 91  6  0 84 90  0 91  6  0  0  0 90  7  0  0], 1)]     
     15    [ 
     16    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     17    Basis matrix: 
     18    [ 0  0  0  1 96 96  1  0 95  1  1  1  1 95  2 96  0  0 96 96  0  0 96  2 96 96  2  0  0  1  1 95  0], 1), 
     19    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     20    Basis matrix: 
     21    [ 0  1 96 16 75 22 81  0  0 17 17 80 80  0  0 16  1 40 74 23 57 96 81  0 23 74  0  0  0 24 73  0  0], 1), 
     22    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     23    Basis matrix: 
     24    [ 0  1 96 90 90  7  7  0  0  6 91  6 91  0  0  7 13  0 91  6  0 84 90  0 91  6  0  0  0 90  7  0  0], 1) 
     25    ] 
    2226    sage: len(D) 
    2327    9 
  • sage/modular/ssmod/ssmod.py

    r2159 r2337  
    1313    sage: D = a.decomposition() 
    1414    sage: D[:3] 
    15         [(Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    16         Basis matrix: 
    17         [ 0  0  0  1 96 96  1  0 95  1  1  1  1 95  2 96  0  0 96 96  0  0 96  2 96 96  2  0  0  1  1 95  0], 1), (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    18         Basis matrix: 
    19         [ 0  1 96 16 75 22 81  0  0 17 17 80 80  0  0 16  1 40 74 23 57 96 81  0 23 74  0  0  0 24 73  0  0], 1), (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
    20         Basis matrix: 
    21         [ 0  1 96 90 90  7  7  0  0  6 91  6 91  0  0  7 13  0 91  6  0 84 90  0 91  6  0  0  0 90  7  0  0], 1)]     
     15    [ 
     16    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     17    Basis matrix: 
     18    [ 0  0  0  1 96 96  1  0 95  1  1  1  1 95  2 96  0  0 96 96  0  0 96  2 96 96  2  0  0  1  1 95  0], 1), 
     19    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     20    Basis matrix: 
     21    [ 0  1 96 16 75 22 81  0  0 17 17 80 80  0  0 16  1 40 74 23 57 96 81  0 23 74  0  0  0 24 73  0  0], 1), 
     22    (Vector space of degree 33 and dimension 1 over Finite Field of size 97 
     23    Basis matrix: 
     24    [ 0  1 96 90 90  7  7  0  0  6 91  6 91  0  0  7 13  0 91  6  0 84 90  0 91  6  0  0  0 90  7  0  0], 1) 
     25    ] 
    2226    sage: len(D) 
    2327    9 
  • sage/modules/complex_double_vector.pyx

    r2321 r2337  
    122122            Traceback (most recent call last): 
    123123            ... 
    124             IndexError: index 5 out of range 
     124            IndexError: index out of range 
    125125        """ 
    126126        cdef gsl_complex z_temp 
  • sage/modules/complex_double_vector.pyx

    r2274 r2337  
    2020 
    2121from sage.rings.complex_double cimport ComplexDoubleElement 
    22 from sage.rings.complex_double import CDF 
     22from sage.rings.complex_double import CDF, new_ComplexDoubleElement 
    2323 
    2424include '../ext/stdsage.pxi' 
     
    111111 
    112112    def __getitem__(self,size_t i): 
     113        """ 
     114        Return the ith entry of self. 
     115         
     116        EXAMPLES: 
     117            sage: v = vector(CDF, [1,CDF(3,2), -1]); v 
     118            (1.0, 3.0 + 2.0*I, -1.0) 
     119            sage: v[1] 
     120            3.0 + 2.0*I 
     121            sage: v[5] 
     122            Traceback (most recent call last): 
     123            ... 
     124            IndexError: index out of range 
     125        """ 
    113126        cdef gsl_complex z_temp 
     127        cdef ComplexDoubleElement x 
    114128        if i < 0 or i >= self.v.size: 
    115             raise IndexError 
    116         else: 
    117             z_temp = <gsl_complex> gsl_vector_complex_get(self.v,i) 
    118             return CDF(GSL_REAL(z_temp),GSL_IMAG (z_temp)) 
    119  
     129            raise IndexError, 'index out of range' 
     130        else: 
     131            x = new_ComplexDoubleElement() 
     132            x._complex = <gsl_complex> gsl_vector_complex_get(self.v,i) 
     133            return x 
    120134 
    121135    cdef ModuleElement _add_c_impl(self, ModuleElement right): 
  • sage/plot/tachyon.py

    r2334 r2337  
    8585        sage: t.plane((0,-20,0), (0,1,0), 'white') 
    8686        sage: t.plane((-20,0,0), (1,0,0), 'white') 
    87         sage:  
     87         
    8888        sage: k=0 
    8989        sage: for i in srange(-1,1,0.05): 
     
    536536 
    537537    def get_colors(self, list): 
    538         return texture_recolor(self._tachyon, self._texture, list) 
     538        return self._tachyon.texture_recolor(self._texture, list) 
    539539 
    540540 
  • sage/plot/tachyon.py

    r2334 r2337  
    8585        sage: t.plane((0,-20,0), (0,1,0), 'white') 
    8686        sage: t.plane((-20,0,0), (1,0,0), 'white') 
    87         sage:  
     87         
    8888        sage: k=0 
    8989        sage: for i in srange(-1,1,0.05): 
     
    536536 
    537537    def get_colors(self, list): 
    538         return texture_recolor(self._tachyon, self._texture, list) 
     538        return self._tachyon.texture_recolor(self._texture, list) 
    539539 
    540540 
  • sage/rings/quotient_ring.py

    r2014 r2337  
    113113            sage: pi(5) 
    114114            2 
    115             sage:  
    116115            sage: l = pi.lift() 
    117116 
  • sage/rings/quotient_ring.py

    r2014 r2337  
    113113            sage: pi(5) 
    114114            2 
    115             sage:  
    116115            sage: l = pi.lift() 
    117116 
  • sage/server/notebook/cell.py

    r2330 r2337  
    267267            output = output[:i] 
    268268        if len(output) > MAX_OUTPUT: 
     269            if not self.computing(): 
     270                file = "%s/full_output.txt"%self.directory() 
     271                open(file,"w").write(output) 
     272                html+="<br><a href='/%s' target='_new' class='file_link'>full_output.txt</a>"%file 
    269273            if output.lstrip()[:len(TRACEBACK)] != TRACEBACK: 
    270                 output = 'WARNING: Output truncated!\n' + output[:MAX_OUTPUT] + '\n(truncated)' 
     274                output = 'WARNING: Output truncated!\n' + output[:MAX_OUTPUT/2] + '...\n\n...' + output[-MAX_OUTPUT/2:] 
    271275            else: 
    272                 output = output[:MAX_OUTPUT] + '\n(truncated)' 
     276                output = output[:MAX_OUTPUT/2] + '...\n\n...' + output[-MAX_OUTPUT/2:] 
    273277        self.__out = output 
    274278        self.__out_html = html 
     
    495499                images.append('<embed src="%s/%s" type="image/svg+xml" name="emap">'%(dir,F)) 
    496500            else: 
    497                 files.append('<a target="_new" href="%s/%s">%s</a>'%(dir, F, F)) 
     501                files.append('<a target="_new" href="%s/%s" class="file_link">%s</a>'%(dir, F, F)) 
    498502        if len(images) == 0: 
    499503            images = '' 
  • sage/server/notebook/cell.py

    r2336 r2337  
    4141        self.__text = text 
    4242        self.__worksheet = worksheet 
     43 
     44    def set_worksheet(self, worksheet, id=None): 
     45        self.__worksheet = worksheet 
     46        self.__dir = '%s/cells/%s'%(worksheet.directory(), self.relative_id()) 
     47        if not id is None: 
     48            self.__id = id 
     49 
     50    def relative_id(self): 
     51        return self.__id - self.__worksheet.id()*notebook.MAX_WORKSHEETS 
    4352 
    4453    def html(self, ncols, do_print=False, do_math_parse=True): 
     
    99108            self.set_id(id) 
    100109        self.__out_html = self.files_html() 
     110 
     111    def id(self): 
     112        return self.__id 
     113 
     114    def relative_id(self): 
     115        return self.__id - self.__worksheet.id()*notebook.MAX_WORKSHEETS 
     116 
     117    def set_id(self, id): 
     118        self.__id = int(id) 
     119 
     120    def worksheet(self): 
     121        return self.__worksheet 
     122 
     123    def notebook(self): 
     124        return self.__worksheet.notebook() 
     125 
     126    def directory(self): 
     127        if not os.path.exists(self.__dir): 
     128            os.makedirs(self.__dir) 
     129        return self.__dir 
    101130 
    102131    def __cmp__(self, right): 
     
    209238    def computing(self): 
    210239        return self in self.__worksheet.queue() 
    211  
    212     def directory(self): 
    213         if not os.path.exists(self.__dir): 
    214             os.makedirs(self.__dir) 
    215         return self.__dir 
    216  
    217     def id(self): 
    218         return self.__id 
    219  
    220     def relative_id(self): 
    221         return self.__id - self.__worksheet.id()*notebook.MAX_WORKSHEETS 
    222  
    223     def set_id(self, id): 
    224         self.__id = int(id) 
    225  
    226     def worksheet(self): 
    227         return self.__worksheet 
    228  
    229     def notebook(self): 
    230         return self.__worksheet.notebook() 
    231240 
    232241    def set_input_text(self, input): 
  • sage/server/notebook/worksheet.py

    r2335 r2337  
    615615        # Finished a computation. 
    616616        self.__comp_is_running = False 
     617        del self.__queue[0] 
    617618        out = self._process_output(out) 
    618619        if C.introspect(): 
     
    636637            self.notebook().add_to_history(history) 
    637638 
    638         del self.__queue[0] 
    639639        return 'd', C 
    640640 
  • sage/server/notebook/worksheet.py

    r2336 r2337  
    11031103                input = input.split('\n') 
    11041104 
     1105                # The following is all so the last line (or single lines) 
     1106                # will implicitly print as they should, unless they are 
     1107                # an assignment.   "display hook"  It's very complicated, 
     1108                # but it has to be... 
    11051109                i = len(input)-1 
    11061110                if i >= 0: 
  • sage/structure/element.pyx

    r2321 r2337  
    297297     
    298298    def _is_atomic(self): 
     299        """ 
     300        Return True if and only if parenthesis are not required when *printing* out 
     301        any of x - self, x + self, x^self and x/self. 
     302 
     303        EXAMPLES: 
     304            sage: n = 5; n._is_atomic() 
     305            True 
     306            sage: n = x+1; n._is_atomic() 
     307            False 
     308        """ 
    299309        if self._parent.is_atomic_repr(): 
    300310            return True 
  • sage/structure/element.pyx

    r2078 r2337  
    297297     
    298298    def _is_atomic(self): 
     299        """ 
     300        Return True if and only if parenthesis are not required when *printing* out 
     301        any of x - self, x + self, x^self and x/self. 
     302 
     303        EXAMPLES: 
     304            sage: n = 5; n._is_atomic() 
     305            True 
     306            sage: n = x+1; n._is_atomic() 
     307            False 
     308        """ 
    299309        if self._parent.is_atomic_repr(): 
    300310            return True 
     
    553563        # self * right,  where right need not be a ring element in the base ring 
    554564        # This does type checking and canonical coercion then calls _lmul_c_impl. 
    555         if PY_TYPE_CHECK(right, Element) and (<Element>right)._parent is self._parent._base: 
    556             # No coercion needed 
    557             return self._lmul_c(right) 
    558         else: 
    559             # Otherwise we do an explicit canonical coercion. 
    560             try: 
    561                 return self._lmul_c( self._parent._base._coerce_c(right) ) 
    562             except TypeError: 
    563                 # that failed -- try to base extend right then do the multiply: 
    564                 self = self.base_extend((<RingElement>right)._parent) 
    565                 return (<ModuleElement>self)._lmul_c(right) 
     565        if PY_TYPE_CHECK(right, Element): 
     566            if (<Element>right)._parent is self._parent._base: 
     567                # No coercion needed 
     568                return self._lmul_c(right) 
     569            else: 
     570                # Otherwise we do an explicit canonical coercion. 
     571                try: 
     572                    return self._lmul_c( self._parent._base._coerce_c(right) ) 
     573                except TypeError: 
     574                    # that failed -- try to base extend right then do the multiply: 
     575                    self = self.base_extend((<RingElement>right)._parent) 
     576                    return (<ModuleElement>self)._lmul_c(right) 
     577        else: 
     578            # right is not an element at all 
     579            return (<ModuleElement>self)._lmul_c(self._parent._base._coerce_c(right)) 
    566580 
    567581    cdef ModuleElement _rmultiply_by_scalar(self, left): 
    568582        # left * self, where left need not be a ring element in the base ring 
    569583        # This does type checking and canonical coercion then calls _rmul_c_impl. 
    570         if PY_TYPE_CHECK(left, Element) and (<Element>self)._parent is self._parent._base: 
    571             # No coercion needed 
    572             return self._rmul_c(right) 
    573         else: 
    574             # Otherwise we do an explicit canonical coercion. 
    575             try: 
    576                 return self._rmul_c(self._parent._base._coerce_c(left)) 
    577             except TypeError: 
    578                 # that failed -- try to base extend self then do the multiply: 
    579                 self = self.base_extend((<RingElement>left)._parent) 
    580                 return (<ModuleElement>self)._rmul_c(left) 
     584        if PY_TYPE_CHECK(left, Element): 
     585            if (<Element>self)._parent is self._parent._base: 
     586                # No coercion needed 
     587                return self._rmul_c(right) 
     588            else: 
     589                # Otherwise we do an explicit canonical coercion. 
     590                try: 
     591                    return self._rmul_c(self._parent._base._coerce_c(left)) 
     592                except TypeError: 
     593                    # that failed -- try to base extend self then do the multiply: 
     594                    self = self.base_extend((<RingElement>left)._parent) 
     595                    return (<ModuleElement>self)._rmul_c(left) 
     596        else: 
     597            # now left is not an element at all. 
     598            return (<ModuleElement>self)._rmul_c(self._parent._base._coerce_c(left)) 
    581599 
    582600    cdef ModuleElement _lmul_nonscalar_c(left, right): 
     
    823841 
    824842        a = self 
    825         power = self.parent()(1) 
     843        power = None 
    826844        if n < 0: 
    827845            n = -n 
    828846            a = ~self 
    829847        elif n == 0: 
    830             return power 
     848            return self.parent()(1) 
    831849 
    832850        power = (<Element>self)._parent(1) 
    833851        apow = a 
    834852        while True: 
    835             if n&1 > 0: power = power*apow 
     853            if n&1 > 0: 
     854                if power is None: 
     855                    power = apow 
     856                else: 
     857                    power = power*apow 
    836858            n = n >> 1 
    837859            if n != 0: 
Note: See TracChangeset for help on using the changeset viewer.