Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use Parent for the Pari pseudo-ring #37465

Merged
merged 1 commit into from
Mar 31, 2024
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
21 changes: 11 additions & 10 deletions src/sage/rings/pari_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
# ****************************************************************************
import sage.libs.pari.all as pari
from sage.rings.ring import Ring
from sage.categories.rings import Rings
from sage.structure.parent import Parent
from sage.structure.element import RingElement
from sage.structure.richcmp import richcmp
from sage.misc.fast_methods import Singleton
Expand All @@ -27,7 +28,7 @@ class Pari(RingElement):
"""
Element of Pari pseudo-ring.
"""
def __init__(self, x, parent=None):
def __init__(self, x, parent=None) -> None:
"""
EXAMPLES::

Expand All @@ -45,7 +46,7 @@ def __init__(self, x, parent=None):
RingElement.__init__(self, parent)
self.__x = pari.pari(x)

def __repr__(self):
def __repr__(self) -> str:
"""
EXAMPLES::

Expand Down Expand Up @@ -138,7 +139,7 @@ def __invert__(self):
"""
return self.__class__(~self.__x, parent=_inst)

def _richcmp_(self, other, op):
def _richcmp_(self, other, op) -> bool:
"""
EXAMPLES::

Expand All @@ -154,11 +155,11 @@ def _richcmp_(self, other, op):
"""
return richcmp(self.__x, other.__x, op)

def __int__(self):
def __int__(self) -> int:
return int(self.__x)


class PariRing(Singleton, Ring):
class PariRing(Singleton, Parent):
"""
EXAMPLES::

Expand All @@ -170,17 +171,17 @@ class PariRing(Singleton, Ring):
Element = Pari

def __init__(self):
Ring.__init__(self, self)
Parent.__init__(self, self, category=Rings())

def __repr__(self):
def __repr__(self) -> str:
return 'Pseudoring of all PARI objects.'

def _element_constructor_(self, x):
if isinstance(x, Pari):
return x
return self.element_class(x, parent=self)

def is_field(self, proof=True):
def is_field(self, proof=True) -> bool:
return False

def characteristic(self):
Expand Down
Loading