diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py index a0990ad1720..de5e112343f 100644 --- a/src/sage/rings/padics/factory.py +++ b/src/sage/rings/padics/factory.py @@ -17,7 +17,7 @@ sage: R = QpLF(2) """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007-2013 David Roe # William Stein # @@ -26,10 +26,11 @@ # the License, or (at your option) any later version. # # https://www.gnu.org/licenses/ -#***************************************************************************** +# **************************************************************************** from sage.misc.superseded import experimental +from sage.categories.fields import Fields from sage.structure.factory import UniqueFactory from sage.rings.integer import Integer from sage.rings.infinity import Infinity @@ -783,35 +784,45 @@ def create_object(self, version, key): pass p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key + _Fields = Fields() + if type == 'capped-rel': if print_mode == 'terse': return pAdicFieldCappedRelative(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) else: return pAdicFieldCappedRelative(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) elif type == 'floating-point': if print_mode == 'terse': return pAdicFieldFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) else: return pAdicFieldFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) elif type == 'relaxed': if print_mode == 'terse': return pAdicFieldRelaxed(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) else: return pAdicFieldRelaxed(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name) + 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, + category=_Fields) elif type[:8] == 'lattice-': subtype = type[8:] if print_mode == 'terse': return pAdicFieldLattice(p, prec, subtype, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, label) + 'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, label, + category=_Fields) else: return pAdicFieldLattice(p, prec, subtype, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet, - 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, label) + 'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, label, + category=_Fields) else: raise ValueError("unexpected type") diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py index 5b8c7468c75..c1459a3a204 100644 --- a/src/sage/rings/padics/generic_nodes.py +++ b/src/sage/rings/padics/generic_nodes.py @@ -314,7 +314,7 @@ class pAdicLatticeGeneric(pAdicGeneric): sage: R._prec_type() 'lattice-float' """ - def __init__(self, p, prec, print_mode, names, label=None): + def __init__(self, p, prec, print_mode, names, label=None, category=None): """ Initialization. @@ -357,7 +357,7 @@ def __init__(self, p, prec, print_mode, names, label=None): else: raise ValueError("subtype must be either 'cap' or 'float'") self._element_class = self.__make_element_class__(element_class) - pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None) + pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None, category=category) def _prec_type(self): """ diff --git a/src/sage/rings/padics/padic_base_generic.py b/src/sage/rings/padics/padic_base_generic.py index 8001d366b23..003d34c8315 100644 --- a/src/sage/rings/padics/padic_base_generic.py +++ b/src/sage/rings/padics/padic_base_generic.py @@ -34,7 +34,7 @@ class pAdicBaseGeneric(pAdicGeneric): _implementation = 'GMP' - def __init__(self, p, prec, print_mode, names, element_class): + def __init__(self, p, prec, print_mode, names, element_class, category=None): """ Initialization. @@ -47,7 +47,7 @@ def __init__(self, p, prec, print_mode, names, element_class): self.prime_pow = PowComputer_flint(p, 1, 1, 1, self.is_field()) else: self.prime_pow = PowComputer(p, max(min(prec - 1, 30), 1), prec, self.is_field(), self._prec_type()) - pAdicGeneric.__init__(self, self, p, prec, print_mode, names, element_class) + pAdicGeneric.__init__(self, self, p, prec, print_mode, names, element_class, category=category) if self.is_field(): if self.is_capped_relative(): coerce_list = [pAdicCoercion_ZZ_CR(self), pAdicCoercion_QQ_CR(self)] diff --git a/src/sage/rings/padics/padic_base_leaves.py b/src/sage/rings/padics/padic_base_leaves.py index 64be9291c49..4eb9e584de1 100644 --- a/src/sage/rings/padics/padic_base_leaves.py +++ b/src/sage/rings/padics/padic_base_leaves.py @@ -211,7 +211,7 @@ class pAdicRingCappedRelative(pAdicRingBaseGeneric, pAdicCappedRelativeRingGener An implementation of the `p`-adic integers with capped relative precision. """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -247,7 +247,7 @@ def __init__(self, p, prec, print_mode, names): ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) # long time """ - pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement) + pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category) def _coerce_map_from_(self, R): """ @@ -309,7 +309,7 @@ class pAdicRingCappedAbsolute(pAdicRingBaseGeneric, pAdicCappedAbsoluteRingGener r""" An implementation of the `p`-adic integers with capped absolute precision. """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -345,7 +345,7 @@ def __init__(self, p, prec, print_mode, names): ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ - pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement) + pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement, category=category) def _coerce_map_from_(self, R): """ @@ -410,7 +410,7 @@ class pAdicRingFloatingPoint(pAdicRingBaseGeneric, pAdicFloatingPointRingGeneric An implementation of the `p`-adic integers with floating point precision. """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -446,7 +446,7 @@ def __init__(self, p, prec, print_mode, names): ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ - pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement) + pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category) def _coerce_map_from_(self, R): """ @@ -505,7 +505,7 @@ class pAdicRingFixedMod(pAdicRingBaseGeneric, pAdicFixedModRingGeneric): r""" An implementation of the `p`-adic integers using fixed modulus. """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -550,7 +550,7 @@ def __init__(self, p, prec, print_mode, names): sage: K(R(90)) 3*5 + 3*5^2 """ - pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFixedModElement) + pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFixedModElement, category=category) def _coerce_map_from_(self, R): """ @@ -618,7 +618,7 @@ class pAdicFieldCappedRelative(pAdicFieldBaseGeneric, pAdicCappedRelativeFieldGe sage: K = Qp(101) # indirect doctest """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -660,7 +660,7 @@ def __init__(self, p, prec, print_mode, names): ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ - pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement) + pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category) def _coerce_map_from_(self, R): """ @@ -749,7 +749,7 @@ class pAdicFieldFloatingPoint(pAdicFieldBaseGeneric, pAdicFloatingPointFieldGene An implementation of the `p`-adic rationals with floating point precision. """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -786,7 +786,7 @@ def __init__(self, p, prec, print_mode, names): ....: max_runs=2^5, skip='_test_log') sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) """ - pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement) + pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category) def _coerce_map_from_(self, R): """ @@ -881,7 +881,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric): sage: R 2-adic Ring with lattice-cap precision (label: init) """ - def __init__(self, p, prec, subtype, print_mode, names, label=None): + def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None): """ Initialization. @@ -893,11 +893,11 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None): # We need to set the subtype first, so that # pAdicRingBaseGeneric.__init__ can work self._subtype = subtype - if isinstance(prec,tuple): - pAdicRingBaseGeneric.__init__(self, p, prec[1], print_mode, names, None) + if isinstance(prec, tuple): + pAdicRingBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category) else: - pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, None) - pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label) + pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category) + pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category) def _coerce_map_from_(self, R): """ @@ -1012,7 +1012,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric): sage: R 2-adic Field with lattice-cap precision (label: init) """ - def __init__(self, p, prec, subtype, print_mode, names, label=None): + def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None): """ Initialization. @@ -1024,11 +1024,11 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None): # We need to set the subtype first, so that # pAdicFieldBaseGeneric.__init__ can work self._subtype = subtype - if isinstance(prec,tuple): - pAdicFieldBaseGeneric.__init__(self, p, prec[1], print_mode, names, None) + if isinstance(prec, tuple): + pAdicFieldBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category) else: - pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, None) - pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label) + pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category) + pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category) def _coerce_map_from_(self, R): """ @@ -1137,7 +1137,7 @@ class pAdicRingRelaxed(pAdicRelaxedGeneric, pAdicRingBaseGeneric): sage: type(R) # needs sage.libs.flint """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -1151,7 +1151,7 @@ def __init__(self, p, prec, print_mode, names): """ from sage.rings.padics import padic_relaxed_element self._default_prec, self._halting_prec, self._secure = prec - pAdicRingBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement) + pAdicRingBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category) self._element_class_module = padic_relaxed_element self._element_class_prefix = "pAdicRelaxedElement_" @@ -1176,7 +1176,7 @@ class pAdicFieldRelaxed(pAdicRelaxedGeneric, pAdicFieldBaseGeneric): sage: type(R) # needs sage.libs.flint """ - def __init__(self, p, prec, print_mode, names): + def __init__(self, p, prec, print_mode, names, category=None): """ Initialization. @@ -1190,6 +1190,6 @@ def __init__(self, p, prec, print_mode, names): """ from sage.rings.padics import padic_relaxed_element self._default_prec, self._halting_prec, self._secure = prec - pAdicFieldBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement) + pAdicFieldBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category) self._element_class_module = padic_relaxed_element self._element_class_prefix = "pAdicRelaxedElement_"