Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 58fd34e

Browse files
author
Release Manager
committed
Trac #28582: some cleaning for is_ring
as a first step towards deprecation URL: https://trac.sagemath.org/28582 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 6369d2b + 6694a51 commit 58fd34e

File tree

5 files changed

+10
-26
lines changed

5 files changed

+10
-26
lines changed

src/doc/en/thematic_tutorials/coercion_and_categories.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ This base class provides a lot more methods than a general parent::
155155
'is_integrally_closed',
156156
'is_noetherian',
157157
'is_prime_field',
158-
'is_ring',
159158
'is_subring',
160159
'krull_dimension',
161160
'ngens',

src/sage/categories/rings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@ def is_ring(self):
266266
267267
sage: Parent(QQ,category=Rings()).is_ring()
268268
True
269-
270269
"""
271270
return True
272271

src/sage/matroids/constructor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
from sage.graphs.all import Graph
110110
from sage.structure.element import is_Matrix
111111
from sage.rings.all import ZZ, QQ
112+
from sage.categories.all import Fields, Rings
112113
from sage.rings.finite_rings.finite_field_base import FiniteField
113114
import sage.matroids.matroid
114115
import sage.matroids.basis_exchange_matroid
@@ -694,11 +695,11 @@ def Matroid(groundset=None, data=None, **kwds):
694695
base_ring = None
695696
if 'field' in kwds:
696697
base_ring = kwds.pop('field')
697-
if check and not base_ring.is_field():
698+
if check and not base_ring in Fields:
698699
raise TypeError("{} is not a field".format(base_ring))
699700
elif 'ring' in kwds:
700701
base_ring = kwds.pop('ring')
701-
if check and not base_ring.is_ring():
702+
if check and not base_ring in Rings:
702703
raise TypeError("{} is not a ring".format(base_ring))
703704

704705
# "key" is the kind of data we got

src/sage/rings/polynomial/infinite_polynomial_ring.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238

239239
import six
240240
from sage.rings.ring import CommutativeRing
241+
from sage.categories.rings import Rings
241242
from sage.structure.all import SageObject, parent
242243
from sage.structure.factory import UniqueFactory
243244
from sage.misc.cachefunc import cached_method
@@ -684,17 +685,14 @@ def __init__(self, R, names, order):
684685
names = ['x']
685686
for n in names:
686687
if not (isinstance(n, six.string_types) and n.isalnum() and (not n[0].isdigit())):
687-
raise ValueError("generator names must be alpha-numeric strings not starting with a digit, but %s isn't"%n)
688-
if len(names)!=len(set(names)):
688+
raise ValueError("generator names must be alpha-numeric strings not starting with a digit, but %s isn't" % n)
689+
if len(names) != len(set(names)):
689690
raise ValueError("generator names must be pairwise different")
690691
self._names = tuple(names)
691692
if not isinstance(order, six.string_types):
692693
raise TypeError("The monomial order must be given as a string")
693-
try:
694-
if not (hasattr(R,'is_ring') and R.is_ring() and hasattr(R,'is_commutative') and R.is_commutative()):
695-
raise TypeError
696-
except Exception:
697-
raise TypeError("The given 'base ring' (= %s) must be a commutative ring"%(R))
694+
if not R in Rings().Commutative():
695+
raise TypeError("The given 'base ring' (= %s) must be a commutative ring" % R)
698696

699697
# now, the input is accepted
700698
if hasattr(R,'_underlying_ring'):

src/sage/rings/ring.pyx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ cdef class Ring(ParentWithGens):
179179
sage: QQ.cardinality()
180180
+Infinity
181181
"""
182-
def __init__(self, base, names=None, normalize=True, category = None):
182+
def __init__(self, base, names=None, normalize=True, category=None):
183183
"""
184184
Initialize ``self``.
185185
@@ -997,17 +997,6 @@ cdef class Ring(ParentWithGens):
997997
else:
998998
return False
999999

1000-
def is_ring(self):
1001-
"""
1002-
Return ``True`` since ``self`` is a ring.
1003-
1004-
EXAMPLES::
1005-
1006-
sage: QQ.is_ring()
1007-
True
1008-
"""
1009-
return True
1010-
10111000
def is_noetherian(self):
10121001
"""
10131002
Return ``True`` if this ring is Noetherian.
@@ -2549,6 +2538,4 @@ def is_Ring(x):
25492538
sage: is_Ring(MS)
25502539
True
25512540
"""
2552-
# TODO: use the idiom `x in _Rings` as soon as all rings will be
2553-
# in the category Rings()
2554-
return isinstance(x, Ring) or x in _Rings
2541+
return x in _Rings

0 commit comments

Comments
 (0)