Skip to content

Commit a069568

Browse files
committed
adding the category keyword to padic rings and fields classes
1 parent 1be0a58 commit a069568

File tree

4 files changed

+51
-40
lines changed

4 files changed

+51
-40
lines changed

src/sage/rings/padics/factory.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
sage: R = QpLF(2)
1818
"""
1919

20-
#*****************************************************************************
20+
# ****************************************************************************
2121
# Copyright (C) 2007-2013 David Roe <[email protected]>
2222
# William Stein <[email protected]>
2323
#
@@ -26,10 +26,11 @@
2626
# the License, or (at your option) any later version.
2727
#
2828
# https://www.gnu.org/licenses/
29-
#*****************************************************************************
29+
# ****************************************************************************
3030

3131
from sage.misc.superseded import experimental
3232

33+
from sage.categories.fields import Fields
3334
from sage.structure.factory import UniqueFactory
3435
from sage.rings.integer import Integer
3536
from sage.rings.infinity import Infinity
@@ -783,35 +784,45 @@ def create_object(self, version, key):
783784
pass
784785
p, prec, type, print_mode, name, print_pos, print_sep, print_alphabet, print_max_terms, show_prec, label = key
785786

787+
_Fields = Fields()
788+
786789
if type == 'capped-rel':
787790
if print_mode == 'terse':
788791
return pAdicFieldCappedRelative(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
789-
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name)
792+
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name,
793+
category=_Fields)
790794
else:
791795
return pAdicFieldCappedRelative(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
792-
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name)
796+
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name,
797+
category=_Fields)
793798
elif type == 'floating-point':
794799
if print_mode == 'terse':
795800
return pAdicFieldFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
796-
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name)
801+
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name,
802+
category=_Fields)
797803
else:
798804
return pAdicFieldFloatingPoint(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
799-
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name)
805+
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name,
806+
category=_Fields)
800807
elif type == 'relaxed':
801808
if print_mode == 'terse':
802809
return pAdicFieldRelaxed(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
803-
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name)
810+
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name,
811+
category=_Fields)
804812
else:
805813
return pAdicFieldRelaxed(p, prec, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
806-
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name)
814+
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name,
815+
category=_Fields)
807816
elif type[:8] == 'lattice-':
808817
subtype = type[8:]
809818
if print_mode == 'terse':
810819
return pAdicFieldLattice(p, prec, subtype, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
811-
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, label)
820+
'ram_name': name, 'max_terse_terms': print_max_terms, 'show_prec': show_prec}, name, label,
821+
category=_Fields)
812822
else:
813823
return pAdicFieldLattice(p, prec, subtype, {'mode': print_mode, 'pos': print_pos, 'sep': print_sep, 'alphabet': print_alphabet,
814-
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, label)
824+
'ram_name': name, 'max_ram_terms': print_max_terms, 'show_prec': show_prec}, name, label,
825+
category=_Fields)
815826
else:
816827
raise ValueError("unexpected type")
817828

src/sage/rings/padics/generic_nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class pAdicLatticeGeneric(pAdicGeneric):
314314
sage: R._prec_type()
315315
'lattice-float'
316316
"""
317-
def __init__(self, p, prec, print_mode, names, label=None):
317+
def __init__(self, p, prec, print_mode, names, label=None, category=None):
318318
"""
319319
Initialization.
320320
@@ -357,7 +357,7 @@ def __init__(self, p, prec, print_mode, names, label=None):
357357
else:
358358
raise ValueError("subtype must be either 'cap' or 'float'")
359359
self._element_class = self.__make_element_class__(element_class)
360-
pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None)
360+
pAdicGeneric.__init__(self, self, p, prec, print_mode, names, None, category=category)
361361

362362
def _prec_type(self):
363363
"""

src/sage/rings/padics/padic_base_generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class pAdicBaseGeneric(pAdicGeneric):
3535
_implementation = 'GMP'
3636

37-
def __init__(self, p, prec, print_mode, names, element_class):
37+
def __init__(self, p, prec, print_mode, names, element_class, category=None):
3838
"""
3939
Initialization.
4040
@@ -47,7 +47,7 @@ def __init__(self, p, prec, print_mode, names, element_class):
4747
self.prime_pow = PowComputer_flint(p, 1, 1, 1, self.is_field())
4848
else:
4949
self.prime_pow = PowComputer(p, max(min(prec - 1, 30), 1), prec, self.is_field(), self._prec_type())
50-
pAdicGeneric.__init__(self, self, p, prec, print_mode, names, element_class)
50+
pAdicGeneric.__init__(self, self, p, prec, print_mode, names, element_class, category=category)
5151
if self.is_field():
5252
if self.is_capped_relative():
5353
coerce_list = [pAdicCoercion_ZZ_CR(self), pAdicCoercion_QQ_CR(self)]

src/sage/rings/padics/padic_base_leaves.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class pAdicRingCappedRelative(pAdicRingBaseGeneric, pAdicCappedRelativeRingGener
211211
An implementation of the `p`-adic integers with capped relative
212212
precision.
213213
"""
214-
def __init__(self, p, prec, print_mode, names):
214+
def __init__(self, p, prec, print_mode, names, category=None):
215215
"""
216216
Initialization.
217217
@@ -247,7 +247,7 @@ def __init__(self, p, prec, print_mode, names):
247247
....: max_runs=2^5, skip='_test_log')
248248
sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)]) # long time
249249
"""
250-
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement)
250+
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category)
251251

252252
def _coerce_map_from_(self, R):
253253
"""
@@ -309,7 +309,7 @@ class pAdicRingCappedAbsolute(pAdicRingBaseGeneric, pAdicCappedAbsoluteRingGener
309309
r"""
310310
An implementation of the `p`-adic integers with capped absolute precision.
311311
"""
312-
def __init__(self, p, prec, print_mode, names):
312+
def __init__(self, p, prec, print_mode, names, category=None):
313313
"""
314314
Initialization.
315315
@@ -345,7 +345,7 @@ def __init__(self, p, prec, print_mode, names):
345345
....: max_runs=2^5, skip='_test_log')
346346
sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
347347
"""
348-
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement)
348+
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedAbsoluteElement, category=category)
349349

350350
def _coerce_map_from_(self, R):
351351
"""
@@ -410,7 +410,7 @@ class pAdicRingFloatingPoint(pAdicRingBaseGeneric, pAdicFloatingPointRingGeneric
410410
An implementation of the `p`-adic integers with floating point
411411
precision.
412412
"""
413-
def __init__(self, p, prec, print_mode, names):
413+
def __init__(self, p, prec, print_mode, names, category=None):
414414
"""
415415
Initialization.
416416
@@ -446,7 +446,7 @@ def __init__(self, p, prec, print_mode, names):
446446
....: max_runs=2^5, skip='_test_log')
447447
sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
448448
"""
449-
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement)
449+
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category)
450450

451451
def _coerce_map_from_(self, R):
452452
"""
@@ -505,7 +505,7 @@ class pAdicRingFixedMod(pAdicRingBaseGeneric, pAdicFixedModRingGeneric):
505505
r"""
506506
An implementation of the `p`-adic integers using fixed modulus.
507507
"""
508-
def __init__(self, p, prec, print_mode, names):
508+
def __init__(self, p, prec, print_mode, names, category=None):
509509
"""
510510
Initialization.
511511
@@ -550,7 +550,7 @@ def __init__(self, p, prec, print_mode, names):
550550
sage: K(R(90))
551551
3*5 + 3*5^2
552552
"""
553-
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFixedModElement)
553+
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFixedModElement, category=category)
554554

555555
def _coerce_map_from_(self, R):
556556
"""
@@ -618,7 +618,7 @@ class pAdicFieldCappedRelative(pAdicFieldBaseGeneric, pAdicCappedRelativeFieldGe
618618
sage: K = Qp(101) # indirect doctest
619619
"""
620620

621-
def __init__(self, p, prec, print_mode, names):
621+
def __init__(self, p, prec, print_mode, names, category=None):
622622
"""
623623
Initialization.
624624
@@ -660,7 +660,7 @@ def __init__(self, p, prec, print_mode, names):
660660
....: max_runs=2^5, skip='_test_log')
661661
sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
662662
"""
663-
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement)
663+
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicCappedRelativeElement, category=category)
664664

665665
def _coerce_map_from_(self, R):
666666
"""
@@ -749,7 +749,7 @@ class pAdicFieldFloatingPoint(pAdicFieldBaseGeneric, pAdicFloatingPointFieldGene
749749
An implementation of the `p`-adic rationals with floating point
750750
precision.
751751
"""
752-
def __init__(self, p, prec, print_mode, names):
752+
def __init__(self, p, prec, print_mode, names, category=None):
753753
"""
754754
Initialization.
755755
@@ -786,7 +786,7 @@ def __init__(self, p, prec, print_mode, names):
786786
....: max_runs=2^5, skip='_test_log')
787787
sage: R._test_log(max_runs=2, elements=[R.random_element() for i in range(4)])
788788
"""
789-
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement)
789+
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, pAdicFloatingPointElement, category=category)
790790

791791
def _coerce_map_from_(self, R):
792792
"""
@@ -881,7 +881,7 @@ class pAdicRingLattice(pAdicLatticeGeneric, pAdicRingBaseGeneric):
881881
sage: R
882882
2-adic Ring with lattice-cap precision (label: init)
883883
"""
884-
def __init__(self, p, prec, subtype, print_mode, names, label=None):
884+
def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None):
885885
"""
886886
Initialization.
887887
@@ -893,11 +893,11 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None):
893893
# We need to set the subtype first, so that
894894
# pAdicRingBaseGeneric.__init__ can work
895895
self._subtype = subtype
896-
if isinstance(prec,tuple):
897-
pAdicRingBaseGeneric.__init__(self, p, prec[1], print_mode, names, None)
896+
if isinstance(prec, tuple):
897+
pAdicRingBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category)
898898
else:
899-
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, None)
900-
pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label)
899+
pAdicRingBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category)
900+
pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category)
901901

902902
def _coerce_map_from_(self, R):
903903
"""
@@ -1012,7 +1012,7 @@ class pAdicFieldLattice(pAdicLatticeGeneric, pAdicFieldBaseGeneric):
10121012
sage: R
10131013
2-adic Field with lattice-cap precision (label: init)
10141014
"""
1015-
def __init__(self, p, prec, subtype, print_mode, names, label=None):
1015+
def __init__(self, p, prec, subtype, print_mode, names, label=None, category=None):
10161016
"""
10171017
Initialization.
10181018
@@ -1024,11 +1024,11 @@ def __init__(self, p, prec, subtype, print_mode, names, label=None):
10241024
# We need to set the subtype first, so that
10251025
# pAdicFieldBaseGeneric.__init__ can work
10261026
self._subtype = subtype
1027-
if isinstance(prec,tuple):
1028-
pAdicFieldBaseGeneric.__init__(self, p, prec[1], print_mode, names, None)
1027+
if isinstance(prec, tuple):
1028+
pAdicFieldBaseGeneric.__init__(self, p, prec[1], print_mode, names, None, category=category)
10291029
else:
1030-
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, None)
1031-
pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label)
1030+
pAdicFieldBaseGeneric.__init__(self, p, prec, print_mode, names, None, category=category)
1031+
pAdicLatticeGeneric.__init__(self, p, prec, print_mode, names, label, category=category)
10321032

10331033
def _coerce_map_from_(self, R):
10341034
"""
@@ -1137,7 +1137,7 @@ class pAdicRingRelaxed(pAdicRelaxedGeneric, pAdicRingBaseGeneric):
11371137
sage: type(R) # needs sage.libs.flint
11381138
<class 'sage.rings.padics.padic_base_leaves.pAdicRingRelaxed_with_category'>
11391139
"""
1140-
def __init__(self, p, prec, print_mode, names):
1140+
def __init__(self, p, prec, print_mode, names, category=None):
11411141
"""
11421142
Initialization.
11431143
@@ -1151,7 +1151,7 @@ def __init__(self, p, prec, print_mode, names):
11511151
"""
11521152
from sage.rings.padics import padic_relaxed_element
11531153
self._default_prec, self._halting_prec, self._secure = prec
1154-
pAdicRingBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement)
1154+
pAdicRingBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category)
11551155
self._element_class_module = padic_relaxed_element
11561156
self._element_class_prefix = "pAdicRelaxedElement_"
11571157

@@ -1176,7 +1176,7 @@ class pAdicFieldRelaxed(pAdicRelaxedGeneric, pAdicFieldBaseGeneric):
11761176
sage: type(R) # needs sage.libs.flint
11771177
<class 'sage.rings.padics.padic_base_leaves.pAdicFieldRelaxed_with_category'>
11781178
"""
1179-
def __init__(self, p, prec, print_mode, names):
1179+
def __init__(self, p, prec, print_mode, names, category=None):
11801180
"""
11811181
Initialization.
11821182
@@ -1190,6 +1190,6 @@ def __init__(self, p, prec, print_mode, names):
11901190
"""
11911191
from sage.rings.padics import padic_relaxed_element
11921192
self._default_prec, self._halting_prec, self._secure = prec
1193-
pAdicFieldBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement)
1193+
pAdicFieldBaseGeneric.__init__(self, p, self._default_prec, print_mode, names, padic_relaxed_element.pAdicRelaxedElement, category=category)
11941194
self._element_class_module = padic_relaxed_element
11951195
self._element_class_prefix = "pAdicRelaxedElement_"

0 commit comments

Comments
 (0)