Ticket #13620: trac_13620.patch

File trac_13620.patch, 3.0 KB (added by saraedum, 8 years ago)
  • sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py

    # HG changeset patch
    # User Julian Rueth <julian.rueth@gmail.com>
    # Date 1350615789 0
    # Node ID 7ffe38b585130075a207b9069d9f0d72c0e231d6
    # Parent  698ec14c513f99fa5a3a7aeca982cc14fd249a89
    Trac #13620: initialization of padic polynomial from empty dict
    
    diff --git a/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py b/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py
    a b Polynomial_integer_dense = sage.rings.polynomial.polynomial_integer_dense_ntl.Po 
    2727class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain):
    2828    def __init__(self, parent, x=None, check=True, is_gen=False, construct = False, absprec = infinity, relprec = infinity):
    2929        """
    30         TESTS:
     30        TESTS::
     31
    3132            sage: K = Qp(13,7)
    3233            sage: R.<t> = K[]
    3334            sage: R([K(13), K(1)])
    class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain): 
    3536            sage: T.<t> = ZZ[]
    3637            sage: R(t + 2)
    3738            (1 + O(13^7))*t + (2 + O(13^7))
     39
     40        Check that :trac:`13620` has been fixed::
     41
     42            sage: f = R.zero()
     43            sage: R(f.dict())
     44            0
     45
    3846        """
    3947        Polynomial.__init__(self, parent, is_gen=is_gen)
    4048        parentbr = parent.base_ring()
    class Polynomial_padic_capped_relative_dense(Polynomial_generic_domain): 
    8997                check = False
    9098        elif isinstance(x, dict):
    9199            zero = parentbr.zero_element()
    92             n = max(x.keys())
     100            n = max(x.keys()) if len(x) else 0
    93101            v = [zero for _ in xrange(n + 1)]
    94102            for i, z in x.iteritems():
    95103                v[i] = z
  • sage/rings/polynomial/padics/polynomial_padic_flat.py

    diff --git a/sage/rings/polynomial/padics/polynomial_padic_flat.py b/sage/rings/polynomial/padics/polynomial_padic_flat.py
    a b import sage.rings.padics.misc 
    88class Polynomial_padic_flat(Polynomial_generic_dense):
    99    def __init__(self, parent, x=None, check=True, is_gen=False, construct=False, absprec=None):
    1010        """
    11         Initialization function for the class  Polynomial_padic_flat.
     11        TESTS:
     12
     13        Check that :trac:`13620` has been fixed::
     14
     15            sage: K = ZpFM(3)
     16            sage: R.<t> = K[]
     17            sage: R(R.zero())
     18            0
     19
    1220        """
    13        
    1421        if x is None:
    1522            Polynomial_generic_dense.__init__(self, parent, x = None, is_gen = is_gen)
    1623            return
    class Polynomial_padic_flat(Polynomial_generic_dense): 
    3239            if check:
    3340                m = infinity
    3441                zero = R(0)
    35                 n = max(x.keys())
     42                n = max(x.keys()) if len(x) else 0
    3643                v = [zero for _ in xrange(n+1)]
    3744                for i, z in x.iteritems():
    3845                    v[i] = R(z)