Ticket #11751: trac_11751_whitespace.patch

File trac_11751_whitespace.patch, 4.3 KB (added by jdemeyer, 10 years ago)

small review patch to fix some whitespace and doc issues

  • sage/modules/free_module.py

    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    # Date 1317723359 -7200
    # Node ID 02bb573d138a430a5b674abf784335d9eca23525
    # Parent  111f9ef9c95af31e0911422af604385737bf2728
    Trac 11751: minimal whitespace and doctest patches
    
    diff --git a/sage/modules/free_module.py b/sage/modules/free_module.py
    a b  
    25022502            Echelon basis matrix:
    25032503            [1/5   0   0]
    25042504            [  0 1/4   0]
    2505        
    2506 
    2507         Show that it also works with other things than integers
    2508 
    2509         ::
     2505 
     2506
     2507        It also works with other things than integers::
    25102508
    25112509            sage: R.<x>=QQ[]
    25122510            sage: L=R^1
     
    25242522            Echelon basis matrix:
    25252523            [x/(x^3 - 6*x^2 + 11*x - 6)  2/15*x^2 - 17/75*x - 1/75]
    25262524            [                         0 x^3 - 11/5*x^2 - 3*x + 4/5]
    2527        
    2528         Note that the base_ring can make a huge difference. If we just want the answer to be the
    2529         sub vectorspace over the fraction field of R everything becomes a lot easier.
    2530        
    2531         ::
     2525 
     2526        Note that the ``base_ring`` can make a huge difference. We repeat the previous example over the fraction field of R and get a simpler vector space.::
    25322527
    25332528            sage: L2.span([[(x^2+x)/(x^2-3*x+2),1/5],[(x^2+2*x)/(x^2-4*x+3),x]],base_ring=R.fraction_field())
    25342529            Vector space of degree 2 and dimension 2 over Fraction Field of Univariate Polynomial Ring in x over Rational Field
    25352530            Basis matrix:
    25362531            [1 0]
    25372532            [0 1]
    2538        
    2539 
    25402533        """
    25412534        if is_FreeModule(gens):
    25422535            gens = gens.gens()
  • sage/modules/free_module_element.pyx

    diff --git a/sage/modules/free_module_element.pyx b/sage/modules/free_module_element.pyx
    a b  
    33343334            sage: type(vector([-1,0,3,pi]))   # indirect doctest
    33353335            <class 'sage.modules.vector_symbolic_dense.Vector_symbolic_dense'>
    33363336
    3337         TESTS::
    3338         
     3337        TESTS:
     3338 
    33393339        Check that #11751 is fixed::
    33403340
    33413341            sage: K.<x> = QQ[]
     
    33503350            Traceback (most recent call last):
    33513351            ...
    33523352            TypeError: element (= [1/x^2]) is not in free module
    3353        
    3354        
     3353
     3354        ::
     3355
    33553356            sage: L=K^2
    33563357            sage: R=L.span([[x,0],[0,1/x]], check=False, already_echelonized=True)
    33573358            sage: R.basis()[0][0].parent()
     
    33593360            sage: R=L.span([[x,x^2]])
    33603361            sage: R.basis()[0][0].parent()
    33613362            Univariate Polynomial Ring in x over Rational Field
    3362        
    33633363        """
    33643364        FreeModuleElement.__init__(self, parent)
    33653365        R = self.parent().base_ring()
     
    38073807            (0, 5/4, 0)
    38083808            sage: v.is_sparse()
    38093809            True
    3810        
    3811            
    3812         TESTS::
    3813 
    3814         Test that 11751 is fixed
    3815            
     3810
     3811        TESTS:
     3812
     3813        Test that 11751 is fixed::
     3814
    38163815            sage: K.<x> = QQ[]
    38173816            sage: M = FreeModule(K, 1, sparse=True)
    38183817            sage: N = M.span([{0:1/x}]); N
     
    38243823            sage: N({0:1/x^2})
    38253824            Traceback (most recent call last):
    38263825            ...
    3827             TypeError: element (= {0: 1/x^2}) is not in free module
    3828        
    3829        
     3826            TypeError: element (= {0: 1/x^2}) is not in free module
     3827
     3828        ::
     3829
    38303830            sage: L = FreeModule(K, 2, sparse=True)
    38313831            sage: R = L.span([{0:x, 1:0}, {0:0, 1:1/x}], check=False, already_echelonized=True)
    38323832            sage: R.basis()[0][0].parent()
     
    38343834            sage: R = L.span([{0:x, 1:x^2}])
    38353835            sage: R.basis()[0][0].parent()
    38363836            Univariate Polynomial Ring in x over Rational Field
    3837        
    38383837        """
    38393838        #WARNING: In creation, we do not check that the i pairs satisfy
    38403839        #     0 <= i < degree.
     
    38583857                # Make a copy
    38593858                entries = dict(entries)
    38603859            if coerce:
    3861                 if len(entries) != 0: 
    3862                     coefficient_ring = parent.basis()[0][0].parent() 
     3860                if len(entries) != 0:
     3861                    coefficient_ring = parent.basis()[0][0].parent()
    38633862                    try:
    38643863                        for k, x in entries.iteritems():
    38653864                            entries[k] = coefficient_ring(x)