Ticket #15429: PadicInverse.patch

File PadicInverse.patch, 4.2 KB (added by afiori, 6 years ago)
  • sage/rings/padics/padic_base_generic.py

    # HG changeset patch
    # User Andrew Fiori <afiori@mast.queensu.ca>
    # Date 1384647035 28800
    # Node ID 08147f4278aff13fd9ea3229a0690fde3b659052
    # Parent  8e37ed5519e10a460a49ae17bc257eee26832e9f
    [mq]: PadicInverses
    
    diff --git a/sage/rings/padics/padic_base_generic.py b/sage/rings/padics/padic_base_generic.py
    a b  
    1111from padic_generic import pAdicGeneric
    1212from sage.rings.padics.pow_computer import PowComputer
    1313from sage.rings.padics.padic_base_coercion import pAdicCoercion_ZZ_CR, pAdicCoercion_QQ_CR, pAdicConvert_QQ_CR, pAdicCoercion_ZZ_CA, pAdicConvert_QQ_CA, pAdicCoercion_ZZ_FM, pAdicConvert_QQ_FM
     14from sage.misc.cachefunc import cached_method
    1415
    1516class pAdicBaseGeneric(pAdicGeneric):
    1617    def __init__(self, p, prec, print_mode, names, element_class):
     
    3940            raise RuntimeError
    4041        self._populate_coercion_lists_(coerce_list=coerce_list, convert_list=convert_list, element_constructor=element_class)
    4142                       
     43    @cached_method
    4244    def fraction_field(self, print_mode=None):
    4345        r"""
    4446        Returns the fraction field of ``self``.
     
    6567        from sage.rings.padics.factory import Qp
    6668        return Qp(self.prime(), self.precision_cap(), 'capped-rel', print_mode=self._modified_print_mode(print_mode), names=self._uniformizer_print())
    6769
     70    @cached_method
    6871    def integer_ring(self, print_mode=None):
    6972        r"""
    7073        Returns the integer ring of ``self``, possibly with
  • sage/rings/padics/padic_capped_relative_element.pyx

    diff --git a/sage/rings/padics/padic_capped_relative_element.pyx b/sage/rings/padics/padic_capped_relative_element.pyx
    a b  
    11171117        cdef pAdicCappedRelativeElement ans
    11181118        ans = self._new_c()
    11191119        if ans.prime_pow.in_field == 0:
    1120             ans._parent = self.parent().fraction_field()
     1120            ans._parent = self._parent.fraction_field()
    11211121            ans.prime_pow = ans._parent.prime_pow
    11221122        ans.ordp = -self.ordp
    11231123        ans._set_prec(self.relprec)
  • sage/rings/padics/padic_extension_generic.py

    diff --git a/sage/rings/padics/padic_extension_generic.py b/sage/rings/padics/padic_extension_generic.py
    a b  
    1010
    1111from padic_generic import pAdicGeneric
    1212from padic_base_generic import pAdicBaseGeneric
     13from sage.misc.cachefunc import cached_method
    1314
    1415class pAdicExtensionGeneric(pAdicGeneric):
    1516    def __init__(self, poly, prec, print_mode, names, element_class):
     
    213214    #        xnew = x - x*delta*(1-q*delta)
    214215    #    return x
    215216
     217    @cached_method
    216218    def fraction_field(self, print_mode=None):
    217219        r"""
    218220        Returns the fraction field of this extension, which is just
     
    251253        else:
    252254            return K.extension(self._pre_poly, prec = self.precision_cap(), res_name = self.residue_field().variable_name(), print_mode=print_mode)
    253255
     256    @cached_method
    254257    def integer_ring(self, print_mode=None):
    255258        r"""
    256259        Returns the ring of integers of self, which is just the
  • sage/rings/padics/padic_generic.py

    diff --git a/sage/rings/padics/padic_generic.py b/sage/rings/padics/padic_generic.py
    a b  
    6262            sage: R._modified_print_mode({'mode': 'bars'})['ram_name']
    6363            '5'
    6464        """
     65        new_print_mode = self._printer.dict().copy()
    6566        if print_mode is None:
    66             print_mode = {}
     67            pass;
    6768        elif isinstance(print_mode, str):
    68             print_mode = {'mode': print_mode}
    69         for option in ['mode', 'pos', 'ram_name', 'unram_name', 'var_name', 'max_ram_terms', 'max_unram_terms', 'max_terse_terms', 'sep', 'alphabet']:
    70             if not print_mode.has_key(option):
    71                 print_mode[option] = self._printer.dict()[option]
    72         return print_mode
     69            new_print_mode['mode']=print_mode;
     70            return new_print_mode;
     71        else:
     72            for k,v in print_mode.iteritems():
     73                new_print_mode[k] = v;
     74        return new_print_mode;
    7375
    7476    def ngens(self):
    7577        """