From b0a3d37cffe91f3489f11480b7f67e9e4805f3e4 Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Thu, 1 Sep 2016 08:43:42 +0200 Subject: [PATCH] Remove ParentWith*AbelianGens and Module_old --- src/sage/modules/module.pyx | 25 +----- src/sage/structure/all.py | 6 +- src/sage/structure/parent_gens.pxd | 7 -- src/sage/structure/parent_gens.pyx | 129 ----------------------------- 4 files changed, 3 insertions(+), 164 deletions(-) diff --git a/src/sage/modules/module.pyx b/src/sage/modules/module.pyx index 340d186534f..84e5e245515 100644 --- a/src/sage/modules/module.pyx +++ b/src/sage/modules/module.pyx @@ -1,11 +1,6 @@ """ Abstract base class for modules -Two classes for modules are defined here: :class:`.Module_old` and -:class:`.Module`. The former is a legacy class which should not be used for new -code anymore as it does not conform to the coercion model. Eventually all -occurences shall be ported to :class:`.Module`. - AUTHORS: - William Stein: initial version @@ -67,26 +62,8 @@ A minimal example of a module:: # http://www.gnu.org/licenses/ #***************************************************************************** -from sage.structure.parent_gens cimport ParentWithAdditiveAbelianGens from sage.structure.parent cimport Parent -cdef class Module_old(sage.structure.parent_gens.ParentWithAdditiveAbelianGens): - """ - Generic module class. - """ - def __init__(self, *args, **kwds): - """ - TESTS:: - - sage: sage.modules.module.Module_old(ZZ) - doctest:...: DeprecationWarning: the class Module_old is superseded by Module. - See http://trac.sagemath.org/17543 for details. - - """ - from sage.misc.superseded import deprecation - deprecation(17543, "the class Module_old is superseded by Module.") - ParentWithAdditiveAbelianGens.__init__(self, *args, **kwds) - cdef class Module(sage.structure.parent.Parent): """ @@ -297,7 +274,7 @@ def is_Module(x): False """ - return isinstance(x, Module) or isinstance(x, Module_old) + return isinstance(x, Module) def is_VectorSpace(x): """ diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py index 6907e79ee90..5be67ba9d08 100644 --- a/src/sage/structure/all.py +++ b/src/sage/structure/all.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from .factorization import Factorization from .sequence import Sequence, seq @@ -18,10 +19,7 @@ from .parent_base import ParentWithBase -from .parent_gens import (ParentWithGens, - ParentWithAdditiveAbelianGens, - ParentWithMultiplicativeAbelianGens, - localvars) +from .parent_gens import ParentWithGens, localvars from .proof import all as proof diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd index a80329611ca..6ec0e6e83f0 100644 --- a/src/sage/structure/parent_gens.pxd +++ b/src/sage/structure/parent_gens.pxd @@ -19,10 +19,3 @@ cdef class ParentWithGens(ParentWithBase): cdef public object _gens cdef public object _latex_names cdef public object _list - - -cdef class ParentWithMultiplicativeAbelianGens(ParentWithGens): - cdef public object _generator_orders - -cdef class ParentWithAdditiveAbelianGens(ParentWithGens): - cdef public object _generator_orders diff --git a/src/sage/structure/parent_gens.pyx b/src/sage/structure/parent_gens.pyx index dda0e5d2ff7..8fa46dc5b31 100644 --- a/src/sage/structure/parent_gens.pyx +++ b/src/sage/structure/parent_gens.pyx @@ -95,87 +95,6 @@ cdef inline check_old_coerce(parent.Parent p): if p._element_constructor is not None: raise RuntimeError("%s still using old coercion framework" % p) -def is_ParentWithGens(x): - """ - Return True if x is a parent object with generators, i.e., derives from - :class:`sage.structure.parent_gens.ParentWithGens` and False otherwise. - - EXAMPLES:: - - sage: from sage.structure.parent_gens import is_ParentWithGens - sage: is_ParentWithGens(QQ['x']) - doctest:...: DeprecationWarning: the function is_ParentWithGens() is deprecated - See http://trac.sagemath.org/18759 for details. - True - sage: is_ParentWithGens(CC) - True - sage: is_ParentWithGens(Primes()) - False - """ - from sage.misc.superseded import deprecation - deprecation(18759, "the function is_ParentWithGens() is deprecated") - return isinstance(x, ParentWithGens) - -def is_ParentWithAdditiveAbelianGens(x): - """ - Return True if x is a parent object with additive abelian generators, i.e., - derives from - :mod:`sage.structure.parent_gens.ParentWithAdditiveAbelianGens` and False - otherwise. - - EXAMPLES:: - - sage: from sage.structure.parent_gens import is_ParentWithAdditiveAbelianGens - sage: is_ParentWithAdditiveAbelianGens(QQ) - doctest:...: DeprecationWarning: the class ParentWithAdditiveAbelianGens is deprecated - See http://trac.sagemath.org/18759 for details. - False - """ - from sage.misc.superseded import deprecation - deprecation(18759, "the class ParentWithAdditiveAbelianGens is deprecated") - return isinstance(x, ParentWithAdditiveAbelianGens) - -def is_ParentWithMultiplicativeAbelianGens(x): - """ - Return True if x is a parent object with additive abelian generators, i.e., - derives from - :class:`sage.structure.parent_gens.ParentWithMultiplicativeAbelianGens` and - False otherwise. - - EXAMPLES:: - - sage: from sage.structure.parent_gens import is_ParentWithMultiplicativeAbelianGens - sage: is_ParentWithMultiplicativeAbelianGens(QQ) - doctest:...: DeprecationWarning: the class ParentWithMultiplicativeAbelianGens is deprecated - See http://trac.sagemath.org/18759 for details. - False - """ - from sage.misc.superseded import deprecation - deprecation(18759, "the class ParentWithMultiplicativeAbelianGens is deprecated") - return isinstance(x, ParentWithMultiplicativeAbelianGens) - - -# Classes that derive from ParentWithGens must define gen(i) and -# ngens() functions. It is also good if they define gens() to return -# all gens, but this is not necessary. - -## def make_parent_gens_v0(_class, _dict, -## base, has_coerce_map_from, names): -## """ -## This should work for any Python class deriving from this, as long -## as it doesn't implement some screwy __new__() method. -## """ -## cdef ParentWithGens new_object -## new_object = _class.__new__(_class) -## if base is None: -## new_object._base = new_object -## else: -## new_object._base = base -## new_object._has_coerce_map_from = has_coerce_map_from -## new_object._names = names -## if not _dict is None: -## new_object.__dict__ = _dict -## return new_object cdef class ParentWithGens(ParentWithBase): # Derived class *must* call __init__ and set the base! @@ -410,54 +329,6 @@ cdef class ParentWithGens(ParentWithBase): return self.Hom(codomain)(im_gens, check=check) -cdef class ParentWithMultiplicativeAbelianGens(ParentWithGens): - def __cinit__(self, *args, **kwds): - from sage.misc.superseded import deprecation - deprecation(18759, "the class ParentWithMultiplicativeAbelianGens is deprecated, use Parent instead") - - def generator_orders(self): - check_old_coerce(self) - if self._generator_orders is not None: - return self._generator_orders - else: - g = [] - for x in self.gens(): - g.append(x.multiplicative_order()) - self._generator_orders = g - return g - - def __iter__(self): - """ - Return an iterator over the elements in this object. - """ - return gens_py.multiplicative_iterator(self) - - -cdef class ParentWithAdditiveAbelianGens(ParentWithGens): - def __cinit__(self, *args, **kwds): - from sage.misc.superseded import deprecation - deprecation(18759, "the class ParentWithAdditiveAbelianGens is deprecated, use Parent instead") - - def generator_orders(self): - check_old_coerce(self) - if self._generator_orders is not None: - return self._generator_orders - else: - g = [] - for x in self.gens(): - g.append(x.additive_order()) - self._generator_orders = g - return g - - def __iter__(self): - """ - Return an iterator over the elements in this object. - """ - return gens_py.abelian_iterator(self) - - - - cdef class localvars: r""" Context manager for safely temporarily changing the variables