Skip to content

Commit c7bf519

Browse files
author
Release Manager
committed
gh-37564: use Parent in infinity Let us use `Parent` for the ugly Unsigned Infinity Ring. The case of the Infinity Ring seems to be even more problematic, and is not touched upon here. ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #37564 Reported by: Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 644ba54 + 6f87c77 commit c7bf519

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/sage/rings/infinity.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@
219219

220220
import sage.rings.abc
221221

222+
from sage.structure.parent import Parent
222223
from sage.categories.rings import Rings
224+
from sage.categories.semirings import Semirings
223225
from sage.misc.fast_methods import Singleton
224226
from sage.misc.lazy_import import lazy_import
225227
from sage.rings.ring import CommutativeRing
@@ -232,7 +234,7 @@
232234
_obj = {}
233235

234236

235-
class _uniq():
237+
class _uniq:
236238
def __new__(cls, *args):
237239
"""
238240
This ensures uniqueness of these objects.
@@ -248,7 +250,7 @@ def __new__(cls, *args):
248250
return O
249251

250252

251-
class AnInfinity():
253+
class AnInfinity:
252254
"""
253255
TESTS::
254256
@@ -560,7 +562,7 @@ def _sage_input_(self, sib, coerced):
560562
return -sib.name('oo')
561563

562564

563-
class UnsignedInfinityRing_class(Singleton, CommutativeRing):
565+
class UnsignedInfinityRing_class(Singleton, Parent):
564566

565567
def __init__(self):
566568
"""
@@ -584,7 +586,9 @@ def __init__(self):
584586
sage: UnsignedInfinityRing(3) == UnsignedInfinityRing(-19.5)
585587
True
586588
"""
587-
CommutativeRing.__init__(self, self, names=('oo',), normalize=False)
589+
cat = Semirings().Commutative()
590+
Parent.__init__(self, self, names=('oo',), normalize=False,
591+
category=cat)
588592

589593
def ngens(self) -> int:
590594
"""
@@ -599,19 +603,6 @@ def ngens(self) -> int:
599603
"""
600604
return 1
601605

602-
def fraction_field(self):
603-
"""
604-
The unsigned infinity ring isn't an integral domain.
605-
606-
EXAMPLES::
607-
608-
sage: UnsignedInfinityRing.fraction_field()
609-
Traceback (most recent call last):
610-
...
611-
TypeError: infinity 'ring' has no fraction field
612-
"""
613-
raise TypeError("infinity 'ring' has no fraction field")
614-
615606
def gen(self, n=0):
616607
"""
617608
The "generator" of ``self`` is the infinity object.
@@ -1869,7 +1860,7 @@ def test_signed_infinity(pos_inf):
18691860
sage: test_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field
18701861
sage: test_signed_infinity(SR(oo)) # needs sage.symbolic
18711862
"""
1872-
msg = 'testing {} ({})'.format(pos_inf, type(pos_inf))
1863+
msg = f'testing {pos_inf} ({type(pos_inf)})'
18731864
assert InfinityRing(pos_inf) is infinity, msg
18741865
assert InfinityRing(-pos_inf) is minus_infinity, msg
18751866
assert infinity == pos_inf, msg

0 commit comments

Comments
 (0)