Skip to content

Commit

Permalink
sagemathgh-36684: get rid of some ParentWithGens in real and complex …
Browse files Browse the repository at this point in the history
…fields

    
another step towards suppression of `ParentWithGens`, here in real and
complex rings

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#36684
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Dec 6, 2023
2 parents c1bca2a + e5333f8 commit 8278562
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/sage/rings/complex_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ cdef extern from "<complex.h>":
import sage.rings.abc
cimport sage.rings.ring
cimport sage.rings.integer
from sage.rings.ring import Ring

from sage.structure.element cimport Element, FieldElement
from sage.structure.parent cimport Parent
from sage.structure.parent_gens import ParentWithGens
from sage.structure.richcmp cimport rich_to_bool
from sage.categories.morphism cimport Morphism
from sage.structure.coerce cimport is_numpy_type
Expand Down Expand Up @@ -149,7 +149,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
(-1.0, -1.0 + 1.2246...e-16*I, False)
"""
from sage.categories.fields import Fields
ParentWithGens.__init__(self, self, ('I',), normalize=False, category=Fields().Infinite().Metric().Complete())
Ring.__init__(self, self, ('I',), normalize=False, category=Fields().Infinite().Metric().Complete())
self._populate_coercion_lists_()

def __reduce__(self):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ from sage.cpython.string cimport str_to_bytes
from sage.libs.mpfr cimport *
from sage.libs.mpc cimport *
from sage.structure.parent cimport Parent
from sage.structure.parent_gens cimport ParentWithGens
from sage.structure.element cimport Element
from sage.structure.richcmp cimport rich_to_bool
from sage.categories.map cimport Map
from sage.libs.pari.all import pari
from sage.rings.ring import Ring

from sage.rings.integer cimport Integer
from sage.rings.complex_mpfr cimport ComplexNumber
Expand Down Expand Up @@ -319,7 +319,7 @@ cdef class MPComplexField_class(sage.rings.ring.Field):
self.__real_field = real_mpfr.RealField(prec, rnd=_mpfr_rounding_modes[rnd_re(n)])
self.__imag_field = real_mpfr.RealField(prec, rnd=_mpfr_rounding_modes[rnd_im(n)])

ParentWithGens.__init__(self, self._real_field(), ('I',), False, category=Fields().Infinite())
Ring.__init__(self, self._real_field(), ('I',), False, category=Fields().Infinite())
self._populate_coercion_lists_(coerce_list=[MPFRtoMPC(self._real_field(), self)])

cdef MPComplexNumber _new(self) noexcept:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ from sage.structure.element cimport RingElement, Element
from sage.structure.richcmp cimport rich_to_bool
from sage.categories.map cimport Map
from sage.structure.parent import Parent
from sage.structure.parent_gens import ParentWithGens
from sage.rings.ring import Ring

from sage.misc.sage_eval import sage_eval

Expand Down Expand Up @@ -277,7 +277,7 @@ class ComplexField_class(sage.rings.abc.ComplexField):
"""
self._prec = int(prec)
from sage.categories.fields import Fields
ParentWithGens.__init__(self, self._real_field(), ('I',), False, category=Fields().Infinite().Metric().Complete())
Ring.__init__(self, self._real_field(), ('I',), False, category=Fields().Infinite().Metric().Complete())
self._populate_coercion_lists_(coerce_list=[RRtoCC(self._real_field(), self)],
convert_method_name='_complex_mpfr_')

Expand Down
16 changes: 8 additions & 8 deletions src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ Make sure we don't have a new field for every new literal::
True
"""

#*****************************************************************************
# *****************************************************************************
# Copyright (C) 2005-2006 William Stein <wstein@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
#*****************************************************************************
# *****************************************************************************

import math # for log
import sys
Expand Down Expand Up @@ -158,8 +158,8 @@ from sage.rings.real_double cimport RealDoubleElement
import sage.rings.rational_field

import sage.rings.infinity
from sage.rings.ring import Ring

from sage.structure.parent_gens cimport ParentWithGens
from sage.arith.numerical_approx cimport digits_to_bits
from sage.arith.constants cimport M_LN2_LN10
from sage.arith.long cimport is_small_python_int
Expand All @@ -169,11 +169,11 @@ cimport gmpy2
gmpy2.import_gmpy2()


#*****************************************************************************
# ****************************************************************************
#
# Implementation
#
#*****************************************************************************
# ****************************************************************************

_re_skip_zeroes = re.compile(r'^(.+?)0*$')

Expand Down Expand Up @@ -356,11 +356,11 @@ def mpfr_get_exp_max_max():
mpfr_set_exp_min(mpfr_get_emin_min())
mpfr_set_exp_max(mpfr_get_emax_max())

#*****************************************************************************
# *****************************************************************************
#
# Real Field
#
#*****************************************************************************
# *****************************************************************************
# The real field is in Cython, so mpfr elements will have access to
# their parent via direct C calls, which will be faster.

Expand Down Expand Up @@ -534,7 +534,7 @@ cdef class RealField_class(sage.rings.abc.RealField):
self.rnd_str = char_to_str(rnd_str + 5) # Strip "MPFR_"

from sage.categories.fields import Fields
ParentWithGens.__init__(self, self, tuple(), False, category=Fields().Infinite().Metric().Complete())
Ring.__init__(self, self, tuple(), False, category=Fields().Infinite().Metric().Complete())

# Initialize zero and one
cdef RealNumber rn
Expand Down

0 comments on commit 8278562

Please sign in to comment.