Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/sage/rings/infinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@

import sage.rings.abc

from sage.structure.parent import Parent
from sage.categories.rings import Rings
from sage.categories.semirings import Semirings
from sage.misc.fast_methods import Singleton
from sage.misc.lazy_import import lazy_import
from sage.rings.ring import CommutativeRing
Expand All @@ -232,7 +234,7 @@
_obj = {}


class _uniq():
class _uniq:
def __new__(cls, *args):
"""
This ensures uniqueness of these objects.
Expand All @@ -248,7 +250,7 @@ def __new__(cls, *args):
return O


class AnInfinity():
class AnInfinity:
"""
TESTS::

Expand Down Expand Up @@ -560,7 +562,7 @@ def _sage_input_(self, sib, coerced):
return -sib.name('oo')


class UnsignedInfinityRing_class(Singleton, CommutativeRing):
class UnsignedInfinityRing_class(Singleton, Parent):

def __init__(self):
"""
Expand All @@ -584,7 +586,9 @@ def __init__(self):
sage: UnsignedInfinityRing(3) == UnsignedInfinityRing(-19.5)
True
"""
CommutativeRing.__init__(self, self, names=('oo',), normalize=False)
cat = Semirings().Commutative()
Parent.__init__(self, self, names=('oo',), normalize=False,
category=cat)

def ngens(self) -> int:
"""
Expand All @@ -599,19 +603,6 @@ def ngens(self) -> int:
"""
return 1

def fraction_field(self):
"""
The unsigned infinity ring isn't an integral domain.

EXAMPLES::

sage: UnsignedInfinityRing.fraction_field()
Traceback (most recent call last):
...
TypeError: infinity 'ring' has no fraction field
"""
raise TypeError("infinity 'ring' has no fraction field")

def gen(self, n=0):
"""
The "generator" of ``self`` is the infinity object.
Expand Down Expand Up @@ -1869,7 +1860,7 @@ def test_signed_infinity(pos_inf):
sage: test_signed_infinity(RIF(oo)) # needs sage.rings.real_interval_field
sage: test_signed_infinity(SR(oo)) # needs sage.symbolic
"""
msg = 'testing {} ({})'.format(pos_inf, type(pos_inf))
msg = f'testing {pos_inf} ({type(pos_inf)})'
assert InfinityRing(pos_inf) is infinity, msg
assert InfinityRing(-pos_inf) is minus_infinity, msg
assert infinity == pos_inf, msg
Expand Down