Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Remove redundant uses of ParentWithBase and ParentWithGens
Browse files Browse the repository at this point in the history
  • Loading branch information
jdemeyer committed Jan 21, 2016
1 parent 1961f94 commit 8a69e19
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 67 deletions.
1 change: 0 additions & 1 deletion src/sage/algebras/free_algebra_quotient.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
from sage.algebras.algebra import Algebra
from sage.algebras.free_algebra import is_FreeAlgebra
from sage.algebras.free_algebra_quotient_element import FreeAlgebraQuotientElement
from sage.structure.parent_gens import ParentWithGens
from sage.structure.unique_representation import UniqueRepresentation

class FreeAlgebraQuotient(UniqueRepresentation, Algebra, object):
Expand Down
1 change: 0 additions & 1 deletion src/sage/libs/singular/singular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ from sage.rings.finite_rings.finite_field_ntl_gf2e import FiniteField_ntl_gf2e
from sage.libs.pari.all import pari
from sage.libs.gmp.all cimport *

from sage.structure.parent_base cimport ParentWithBase
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular

_saved_options = (int(0),0,0)
Expand Down
3 changes: 1 addition & 2 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3038,8 +3038,7 @@ def _Hom_(self, Y, category):
Returns a homspace whose morphisms have this vector space as domain.
This is called by the general methods such as
:meth:`sage.structure.parent.Parent.Hom` and
:meth:`sage.structure.parent_base.ParentWithBase.Hom`.
:meth:`sage.structure.parent.Parent.Hom`.
INPUT:
Expand Down
2 changes: 0 additions & 2 deletions src/sage/rings/finite_rings/element_givaro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ from sage.libs.pari.all import pari
from sage.libs.pari.gen cimport gen

from sage.structure.parent cimport Parent
from sage.structure.parent_base cimport ParentWithBase
from sage.structure.parent_gens cimport ParentWithGens

from sage.misc.superseded import deprecated_function_alias

Expand Down
2 changes: 0 additions & 2 deletions src/sage/rings/finite_rings/element_ntl_gf2e.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ from sage.structure.sage_object cimport SageObject
from sage.structure.element cimport Element, ModuleElement, RingElement

from sage.structure.parent cimport Parent
from sage.structure.parent_base cimport ParentWithBase
from sage.structure.parent_gens cimport ParentWithGens

from sage.rings.ring cimport Ring

Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/finite_rings/integer_mod.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ cdef class IntegerMod_int(IntegerMod_abstract):
cdef int_fast32_t get_int_value(IntegerMod_int self)
cdef IntegerMod_int _new_c(self, int_fast32_t value)
cdef shift(IntegerMod_int self, int k)
#cdef Element _make_new_with_parent_c(self, ParentWithBase parent)

cdef class IntegerMod_int64(IntegerMod_abstract):
cdef int_fast64_t ivalue
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,7 @@ cdef class IntegerMod_int(IntegerMod_abstract):
z = sage.rings.integer_ring.Z(value)
self.set_from_mpz(z.value)

def _make_new_with_parent_c(self, parent): #ParentWithBase parent):
def _make_new_with_parent_c(self, parent):
cdef IntegerMod_int x = IntegerMod_int.__new__(IntegerMod_int)
x._parent = parent
x.__modulus = parent._pyx_order
Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/finite_rings/integer_mod_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
import sage.rings.integer as integer
import sage.rings.integer_ring as integer_ring
import sage.rings.quotient_ring as quotient_ring
from sage.structure.parent_gens import ParentWithGens

from sage.libs.pari.all import pari, PariError

Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/ideal_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

from commutative_ring import is_CommutativeRing
#from sage.structure.parent_base import ParentWithBase
from sage.structure.parent import Parent
import sage.rings.integer_ring
import ideal
Expand Down
3 changes: 0 additions & 3 deletions src/sage/rings/laurent_series_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import integral_domain
import ring

from sage.structure.parent_gens import ParentWithGens
from sage.libs.pari.all import pari_gen

from sage.structure.category_object import check_default_category
from sage.categories.fields import Fields
from sage.categories.complete_discrete_valuation import CompleteDiscreteValuationFields

Expand Down
18 changes: 4 additions & 14 deletions src/sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,13 @@ Two examples from the Mathematica documentation (done in Sage):
"""

#*****************************************************************************
#
# Sage: System for Algebra and Geometry Experimentation
#
# Copyright (C) 2007 Martin Albrecht <malb@informatik.uni-bremen.de>
# Copyright (C) 2007 William Stein <wstein@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# The full text of the GPL is available at:
#
# 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.
# http://www.gnu.org/licenses/
#*****************************************************************************

Expand All @@ -66,8 +58,6 @@ from sage.libs.singular.decl cimport OPT_REDTAIL, singular_options, kInterRed, t
from sage.libs.singular.decl cimport pp_Mult_nn, p_Delete, n_Delete
from sage.libs.singular.decl cimport rIsPluralRing

from sage.structure.parent_base cimport ParentWithBase

from sage.rings.polynomial.multi_polynomial_libsingular cimport new_MP
from sage.rings.polynomial.plural cimport new_NCP

Expand Down
14 changes: 6 additions & 8 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ from sage.arith.all import gcd
from sage.structure.element import coerce_binop

from sage.structure.parent cimport Parent
from sage.structure.parent_base cimport ParentWithBase
from sage.structure.parent_gens cimport ParentWithGens
from sage.structure.category_object cimport CategoryObject

from sage.structure.element cimport EuclideanDomainElement
Expand Down Expand Up @@ -1634,9 +1632,9 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_generic):
cdef number *n
cdef number *denom

if not <ParentWithBase>self is f._parent:
if self is not f._parent:
f = self._coerce_c(f)
if not <ParentWithBase>self is g._parent:
if self is not g._parent:
g = self._coerce_c(g)

if not f._poly:
Expand Down Expand Up @@ -1737,9 +1735,9 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_generic):
"""
cdef poly *m = p_ISet(1,self._ring)

if not <ParentWithBase>self is f._parent:
if self is not f._parent:
f = self._coerce_c(f)
if not <ParentWithBase>self is g._parent:
if self is not g._parent:
g = self._coerce_c(g)

if f._poly == NULL:
Expand Down Expand Up @@ -1939,7 +1937,7 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn
0
"""
self._poly = NULL
self._parent = <ParentWithBase>parent
self._parent = parent
self._parent_ring = singular_ring_reference(parent._ring)

def __dealloc__(self):
Expand Down Expand Up @@ -5402,7 +5400,7 @@ cdef inline MPolynomial_libsingular new_MP(MPolynomialRing_libsingular parent, p
Singular data structure is used elsewhere.
"""
cdef MPolynomial_libsingular p = MPolynomial_libsingular.__new__(MPolynomial_libsingular)
p._parent = <ParentWithBase>parent
p._parent = parent
p._parent_ring = singular_ring_reference(parent._ring)
p._poly = juice
p_Normalize(p._poly, p._parent_ring)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/multi_polynomial_ring_generic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ r"""
Base class for multivariate polynomial rings
"""

from sage.structure.parent_gens cimport ParentWithGens
import sage.misc.latex
import multi_polynomial_ideal
from sage.structure.parent cimport Parent
from term_order import TermOrder
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polydict import PolyDict
Expand Down Expand Up @@ -332,7 +332,7 @@ cdef class MPolynomialRing_generic(sage.rings.ring.CommutativeRing):
return D

def __richcmp__(left, right, int op):
return (<ParentWithGens>left)._richcmp(right, op)
return (<Parent>left)._richcmp(right, op)

cpdef int _cmp_(left, right) except -2:
if not is_MPolynomialRing(right):
Expand Down
3 changes: 0 additions & 3 deletions src/sage/rings/polynomial/pbori.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@

from sage.structure.parent_base cimport ParentWithBase
from sage.structure.parent_gens cimport ParentWithGens
from sage.rings.polynomial.multi_polynomial_ring_generic cimport \
MPolynomialRing_generic
from sage.rings.polynomial.multi_polynomial cimport MPolynomial
Expand Down
7 changes: 2 additions & 5 deletions src/sage/rings/polynomial/pbori.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ def get_var_mapping(ring, other):
"""

my_names = list(ring._names) # we need .index(.)
if isinstance(other, (ParentWithGens,BooleanMonomialMonoid)):
if isinstance(other, (Parent, BooleanMonomialMonoid)):
indices = range(other.ngens())
ovar_names = other._names
else:
Expand Down Expand Up @@ -2196,8 +2196,6 @@ cdef class BooleanMonomial(MonoidElement):
See class documentation for parameters.
"""

_parent = <ParentWithBase>parent
self._ring = parent._ring
self._pbmonom = PBMonom_Constructor((<BooleanPolynomialRing>self._ring)._pbring)

Expand Down Expand Up @@ -2898,10 +2896,9 @@ cdef class BooleanPolynomial(MPolynomial):
use the appropriate ``__call__`` method in the parent.
"""
def __init__(self, parent):
self._parent = <ParentWithBase>parent
self._parent = parent
self._pbpoly = PBPoly_Constructor_ring((<BooleanPolynomialRing>parent)._pbring)


def _repr_(self):
"""
EXAMPLE::
Expand Down
15 changes: 7 additions & 8 deletions src/sage/rings/polynomial/plural.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ from sage.rings.ring import check_default_category
from sage.structure.element cimport CommutativeRingElement, Element, ModuleElement
from sage.structure.factory import UniqueFactory
from sage.structure.parent cimport Parent
from sage.structure.parent_base cimport ParentWithBase
from sage.structure.parent_gens cimport ParentWithGens
from sage.rings.polynomial.term_order import TermOrder

Expand Down Expand Up @@ -977,9 +976,9 @@ cdef class NCPolynomialRing_plural(Ring):
cdef number *n
cdef number *denom

if not <ParentWithBase>self is f._parent:
if self is not f._parent:
f = self._coerce_c(f)
if not <ParentWithBase>self is g._parent:
if self is not g._parent:
g = self._coerce_c(g)

if(r != currRing): rChangeCurrRing(r)
Expand Down Expand Up @@ -1106,9 +1105,9 @@ cdef class NCPolynomialRing_plural(Ring):
"""
cdef poly *m = p_ISet(1,self._ring)

if not <ParentWithBase>self is f._parent:
if self is not f._parent:
f = self._coerce_c(f)
if not <ParentWithBase>self is g._parent:
if self is not g._parent:
g = self._coerce_c(g)

if f._poly == NULL:
Expand Down Expand Up @@ -1363,12 +1362,12 @@ cdef class NCPolynomial_plural(RingElement):
0
"""
self._poly = NULL
self._parent = <ParentWithBase>parent
self._parent = parent

def __dealloc__(self):
# TODO: Warn otherwise!
# for some mysterious reason, various things may be NULL in some cases
if self._parent is not <ParentWithBase>None and (<NCPolynomialRing_plural>self._parent)._ring != NULL and self._poly != NULL:
if self._parent is not None and (<NCPolynomialRing_plural>self._parent)._ring != NULL and self._poly != NULL:
p_Delete(&self._poly, (<NCPolynomialRing_plural>self._parent)._ring)

# def __call__(self, *x, **kwds): # ?
Expand Down Expand Up @@ -2673,7 +2672,7 @@ cdef inline NCPolynomial_plural new_NCP(NCPolynomialRing_plural parent,
"""
cdef NCPolynomial_plural p = NCPolynomial_plural.__new__(NCPolynomial_plural)
p._parent = <ParentWithBase>parent
p._parent = parent
p._poly = juice
p_Normalize(p._poly, parent._ring)
return p
Expand Down
5 changes: 2 additions & 3 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ from sage.rings.padics.generic_nodes import is_pAdicRing, is_pAdicField

from sage.rings.integral_domain import is_IntegralDomain
from sage.structure.category_object cimport normalize_names
from sage.structure.parent_gens cimport ParentWithGens

from sage.misc.derivative import multi_derivative

Expand Down Expand Up @@ -806,7 +805,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
['push 0.0']
"""
from sage.ext.fast_eval import fast_float_arg, fast_float_constant
var = (<ParentWithGens>self._parent)._names[0]
var = self._parent._names[0]
if len(vars) == 0:
x = fast_float_arg(0)
elif var in vars:
Expand Down Expand Up @@ -1020,7 +1019,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
for i from 0<= i <= self.degree():
if i == 1:
# we delay the hashing until now to not waste it on a constant poly
var_name_hash = hash((<ParentWithGens>self._parent)._names[0])
var_name_hash = hash(self._parent._names[0])
# I'm assuming (incorrectly) that hashes of zero indicate that the element is 0.
# This assumption is not true, but I think it is true enough for the purposes and it
# it allows us to write fast code that omits terms with 0 coefficients. This is
Expand Down
14 changes: 8 additions & 6 deletions src/sage/rings/polynomial/polynomial_quotient_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
True
"""

################################################################################
#*****************************************************************************
# Copyright (C) 2005, 2006 William Stein <wstein@gmail.com>
# Distributed under the terms of the GNU General Public License (GPL)
# The full text of the GPL is available at:
#
# 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.
# http://www.gnu.org/licenses/
################################################################################
#*****************************************************************************

import six
import sage.rings.number_field.all
Expand All @@ -40,11 +43,10 @@
from sage.categories.commutative_algebras import CommutativeAlgebras

from sage.structure.category_object import normalize_names
from sage.structure.parent_gens import ParentWithGens

from sage.rings.polynomial.infinite_polynomial_ring import GenDictWithBasering
from sage.all import sage_eval, parent
from sage.structure.element import Element


def PolynomialQuotientRing(ring, polynomial, names=None):
r"""
Expand Down
2 changes: 0 additions & 2 deletions src/sage/rings/qqbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,13 @@
import sage.rings.ring
from sage.misc.fast_methods import Singleton
from sage.structure.sage_object import SageObject
from sage.structure.parent_gens import ParentWithGens
from sage.rings.real_mpfr import RR
from sage.rings.real_mpfi import RealIntervalField, RIF, is_RealIntervalFieldElement
from sage.rings.complex_field import ComplexField
from sage.rings.complex_interval_field import ComplexIntervalField, is_ComplexIntervalField
from sage.rings.complex_interval import is_ComplexIntervalFieldElement
from sage.rings.polynomial.all import PolynomialRing
from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.multi_polynomial import is_MPolynomial
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.number_field.number_field import NumberField, QuadraticField, CyclotomicField
Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ AUTHORS:
from sage.misc.cachefunc import cached_method

from sage.structure.element cimport coercion_model
from sage.structure.parent_gens cimport ParentWithGens
from sage.structure.parent cimport Parent
from sage.structure.category_object import check_default_category
from sage.misc.prandom import randint
Expand Down

0 comments on commit 8a69e19

Please sign in to comment.