Skip to content

Commit

Permalink
Trac #20011: Deprecate rings/commutative_ring.py and friends
Browse files Browse the repository at this point in the history
The following modules contain only `is_...` functions and should be
removed:
{{{
sage/rings/commutative_ring.py
sage/rings/dedekind_domain.py
sage/rings/euclidean_domain.py
sage/rings/integral_domain.py
sage/rings/principal_ideal_domain.py
}}}

URL: http://trac.sagemath.org/20011
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Feb 5, 2016
2 parents b0f4ff0 + d200bac commit f36e7f6
Show file tree
Hide file tree
Showing 41 changed files with 170 additions and 182 deletions.
4 changes: 2 additions & 2 deletions src/sage/categories/commutative_algebra_ideals.py
Expand Up @@ -52,8 +52,8 @@ def __init__(self, A):
# TODO: replace by ``A in CommutativeAlgebras(*)`` once a
# suitable mantra has been implemented for this.
from sage.algebras.algebra import is_Algebra
from sage.rings.commutative_ring import is_CommutativeRing
if not (is_Algebra(A) and is_CommutativeRing(A)):
from sage.rings.ring import CommutativeRing
if not (is_Algebra(A) and isinstance(A, CommutativeRing)):
raise TypeError("A (=%s) must be a commutative algebra"%A)
Category_in_ambient.__init__(self, A)

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/schemes.py
Expand Up @@ -139,9 +139,9 @@ def _call_(self, x):
if is_SchemeMorphism(x):
return x
from sage.rings.morphism import is_RingHomomorphism
from sage.rings.commutative_ring import is_CommutativeRing
from sage.rings.ring import CommutativeRing
from sage.schemes.generic.spec import Spec
if is_CommutativeRing(x):
if isinstance(x, CommutativeRing):
return Spec(x)
elif is_RingHomomorphism(x):
A = Spec(x.codomain())
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/polyhedron/parent.py
Expand Up @@ -14,8 +14,7 @@
from sage.structure.unique_representation import UniqueRepresentation
from sage.modules.free_module import is_FreeModule
from sage.misc.cachefunc import cached_method
from sage.rings.commutative_ring import is_CommutativeRing
from sage.rings.all import ZZ, QQ, RDF
from sage.rings.all import ZZ, QQ, RDF, CommutativeRing
from sage.categories.fields import Fields

from sage.geometry.polyhedron.base import Polyhedron_base, is_Polyhedron
Expand Down Expand Up @@ -637,7 +636,7 @@ def _get_action_(self, other, op, self_is_left):
extended_self._internal_coerce_map_from(self).__copy__())
return action

if op is operator.mul and is_CommutativeRing(other):
if op is operator.mul and isinstance(other, CommutativeRing):
ring = self._coerce_base_ring(other)
if ring is self.base_ring():
return ActedUponAction(other, self, not self_is_left)
Expand Down
19 changes: 11 additions & 8 deletions src/sage/modular/abvar/homology.py
Expand Up @@ -40,16 +40,19 @@
Hecke operator T_7 on Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3
"""

###########################################################################
# Copyright (C) 2007 William Stein <wstein@gmail.com> #
# Distributed under the terms of the GNU General Public License (GPL) #
# http://www.gnu.org/licenses/ #
###########################################################################
#*****************************************************************************
# Copyright (C) 2007 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.
# http://www.gnu.org/licenses/
#*****************************************************************************


from sage.modular.hecke.all import HeckeModule_free_module
from sage.rings.all import Integer, ZZ, QQ
from sage.rings.commutative_ring import is_CommutativeRing
from sage.rings.all import Integer, ZZ, QQ, CommutativeRing

import abvar

Expand Down Expand Up @@ -109,7 +112,7 @@ def __init__(self, abvar, base):
sage: loads(dumps(H)) == H
True
"""
if not is_CommutativeRing(base):
if not isinstance(base, CommutativeRing):
raise TypeError("base ring must be a commutative ring")
HeckeModule_free_module.__init__(
self, base, abvar.level(), weight=2)
Expand Down
20 changes: 7 additions & 13 deletions src/sage/modular/hecke/module.py
Expand Up @@ -2,23 +2,17 @@
Hecke modules
"""

##########################################################################################
#*****************************************************************************
# Copyright (C) 2004,2005,2006 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/
##########################################################################################
#*****************************************************************************

import sage.rings.all
from sage.rings.commutative_ring import is_CommutativeRing
import sage.arith.all as arith
import sage.misc.misc as misc
import sage.modules.module
Expand Down Expand Up @@ -79,7 +73,7 @@ def __init__(self, base_ring, level, category=None):
sage: ModularForms(3, 3).category()
Category of Hecke modules over Rational Field
"""
if not is_CommutativeRing(base_ring):
if not isinstance(base_ring, sage.rings.all.CommutativeRing):
raise TypeError("base_ring must be commutative ring")

from sage.categories.hecke_modules import HeckeModules
Expand Down
16 changes: 8 additions & 8 deletions src/sage/modular/modform/constructor.py
Expand Up @@ -19,13 +19,15 @@
"""

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

import weakref
import re
Expand All @@ -34,8 +36,6 @@
import sage.modular.dirichlet as dirichlet
import sage.rings.all as rings

from sage.rings.commutative_ring import is_CommutativeRing

import ambient_eps
import ambient_g0
import ambient_g1
Expand Down Expand Up @@ -123,7 +123,7 @@ def canonical_parameters(group, level, weight, base_ring):
raise ValueError("group and level do not match.")
group = arithgroup.Gamma0(m)

if not is_CommutativeRing(base_ring):
if not isinstance(base_ring, rings.CommutativeRing):
raise TypeError("base_ring (=%s) must be a commutative ring"%base_ring)

# it is *very* important to include the level as part of the data
Expand Down
3 changes: 1 addition & 2 deletions src/sage/modular/modsym/modsym.py
Expand Up @@ -86,7 +86,6 @@
import sage.modular.dirichlet as dirichlet
import sage.rings.rational_field as rational_field
import sage.rings.all as rings
from sage.rings.commutative_ring import is_CommutativeRing


def canonical_parameters(group, weight, sign, base_ring):
Expand Down Expand Up @@ -129,7 +128,7 @@ def canonical_parameters(group, weight, sign, base_ring):
if base_ring is None:
base_ring = rational_field.RationalField()

if not is_CommutativeRing(base_ring):
if not isinstance(base_ring, rings.CommutativeRing):
raise TypeError("base_ring (=%s) must be a commutative ring"%base_ring)

if not base_ring.is_field():
Expand Down
6 changes: 2 additions & 4 deletions src/sage/modular/quatalg/brandt.py
Expand Up @@ -208,9 +208,7 @@ class if `I=aJ` for some `a \in A^*`. (Left `\mathcal{O}`-ideals are

# imports
from sage.misc.all import prod, verbose
from sage.rings.all import Integer, ZZ, QQ, PolynomialRing, GF

from sage.rings.commutative_ring import is_CommutativeRing
from sage.rings.all import Integer, ZZ, QQ, PolynomialRing, GF, CommutativeRing

from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra, basis_for_quaternion_lattice
from sage.algebras.quatalg.quaternion_algebra_cython import rational_matrix_from_rational_quaternions
Expand Down Expand Up @@ -297,7 +295,7 @@ def BrandtModule(N, M=1, weight=2, base_ring=QQ, use_cache=True):
raise ValueError("M must be coprime to N")
if weight < 2:
raise ValueError("weight must be at least 2")
if not is_CommutativeRing(base_ring):
if not isinstance(base_ring, CommutativeRing):
raise TypeError("base_ring must be a commutative ring")
key = (N, M, weight, base_ring)
if use_cache:
Expand Down
3 changes: 1 addition & 2 deletions src/sage/modules/free_module.py
Expand Up @@ -168,7 +168,6 @@

from sage.modules.module import Module
import sage.rings.finite_rings.finite_field_constructor as finite_field
import sage.rings.integral_domain as integral_domain
import sage.rings.ring as ring
import sage.rings.integer_ring
import sage.rings.rational_field
Expand Down Expand Up @@ -378,7 +377,7 @@ def create_object(self, version, key):
and base_ring.is_maximal() and base_ring.class_number() == 1:
return FreeModule_ambient_pid(base_ring, rank, sparse=sparse)

elif isinstance(base_ring, integral_domain.IntegralDomain) or base_ring.is_integral_domain():
elif isinstance(base_ring, ring.IntegralDomain) or base_ring.is_integral_domain():
return FreeModule_ambient_domain(base_ring, rank, sparse=sparse)

else:
Expand Down
24 changes: 7 additions & 17 deletions src/sage/modules/free_quadratic_module.py
Expand Up @@ -58,30 +58,20 @@
"""

#*****************************************************************************
# Copyright (C) 2008 David Kohel <kohel@iml.univ-mrs.fr>
#
# Copyright (C) 2008 David Kohel <kohel@iml.univ-mrs.fr>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# http://www.gnu.org/licenses/
#
# All rights granted to distribute under the GPL, version 2,
# or (at your option) any later version of the license.
#
# 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/
#*****************************************************************************

# Python imports
import weakref

# Sage imports


import sage.matrix.matrix_space

import sage.misc.latex as latex

import sage.rings.ring as ring
import sage.rings.integral_domain as integral_domain
import sage.rings.integer
from sage.categories.principal_ideal_domains import PrincipalIdealDomains
import free_module
Expand Down Expand Up @@ -180,7 +170,7 @@ def FreeQuadraticModule(
M = FreeQuadraticModule_ambient_pid(
base_ring, rank, sparse=sparse, inner_product_matrix=inner_product_matrix)

elif isinstance(base_ring, integral_domain.IntegralDomain) or base_ring.is_integral_domain():
elif isinstance(base_ring, ring.IntegralDomain) or base_ring.is_integral_domain():
M = FreeQuadraticModule_ambient_domain(
base_ring, rank, sparse=sparse, inner_product_matrix=inner_product_matrix)
else:
Expand Down
5 changes: 2 additions & 3 deletions src/sage/quadratic_forms/quadratic_form.py
Expand Up @@ -32,9 +32,8 @@
from sage.rings.ring import Ring
from sage.misc.functional import denominator, is_even, is_field
from sage.arith.all import GCD, LCM
from sage.rings.principal_ideal_domain import is_PrincipalIdealDomain
from sage.rings.all import Ideal
from sage.rings.ring import is_Ring
from sage.rings.ring import is_Ring, PrincipalIdealDomain
from sage.matrix.matrix import is_Matrix
from sage.structure.sage_object import SageObject
from sage.structure.element import is_Vector
Expand Down Expand Up @@ -1436,7 +1435,7 @@ def level(self):
except AttributeError:

## Check that the base ring is a PID
if not is_PrincipalIdealDomain(self.base_ring()):
if not isinstance(self.base_ring(), PrincipalIdealDomain):
raise TypeError("Oops! The level (as a number) is only defined over a Principal Ideal Domain. Try using level_ideal().")


Expand Down
8 changes: 2 additions & 6 deletions src/sage/rings/all.py
Expand Up @@ -13,12 +13,8 @@
#*****************************************************************************

# Ring base classes
from ring import Ring, Field
from commutative_ring import CommutativeRing
from integral_domain import IntegralDomain
from dedekind_domain import DedekindDomain
from principal_ideal_domain import PrincipalIdealDomain
from euclidean_domain import EuclideanDomain
from ring import (Ring, Field, CommutativeRing, IntegralDomain,
DedekindDomain, PrincipalIdealDomain, EuclideanDomain)

# Ring element base classes
from sage.structure.element import (CommutativeAlgebraElement,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/cfinite_sequence.py
Expand Up @@ -94,7 +94,7 @@

from sage.categories.fields import Fields
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
from sage.rings.commutative_ring import CommutativeRing
from sage.rings.ring import CommutativeRing
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
Expand Down
6 changes: 6 additions & 0 deletions src/sage/rings/commutative_ring.py
Expand Up @@ -17,6 +17,9 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.misc.superseded import deprecation
deprecation(20011, "the module sage.rings.commutative_ring is deprecated and will be removed")

from sage.rings.ring import CommutativeRing

def is_CommutativeRing(R):
Expand All @@ -25,6 +28,9 @@ def is_CommutativeRing(R):
EXAMPLES::
sage: import sage.rings.commutative_ring
doctest:...: DeprecationWarning: the module sage.rings.commutative_ring is deprecated and will be removed
See http://trac.sagemath.org/20011 for details.
sage: sage.rings.commutative_ring.is_CommutativeRing(ZZ)
True
"""
Expand Down
6 changes: 6 additions & 0 deletions src/sage/rings/dedekind_domain.py
Expand Up @@ -17,6 +17,9 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.misc.superseded import deprecation
deprecation(20011, "the module sage.rings.dedekind_domain is deprecated and will be removed")

from sage.rings.ring import DedekindDomain

def is_DedekindDomain(R):
Expand All @@ -25,6 +28,9 @@ def is_DedekindDomain(R):
EXAMPLES::
sage: import sage.rings.dedekind_domain
doctest:...: DeprecationWarning: the module sage.rings.dedekind_domain is deprecated and will be removed
See http://trac.sagemath.org/20011 for details.
sage: sage.rings.dedekind_domain.is_DedekindDomain(DedekindDomain(QQ))
True
"""
Expand Down
6 changes: 6 additions & 0 deletions src/sage/rings/euclidean_domain.py
Expand Up @@ -17,6 +17,9 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.misc.superseded import deprecation
deprecation(20011, "the module sage.rings.euclidean_domain is deprecated and will be removed")

from sage.rings.ring import EuclideanDomain

def is_EuclideanDomain(R):
Expand All @@ -25,6 +28,9 @@ def is_EuclideanDomain(R):
EXAMPLES::
sage: import sage.rings.euclidean_domain
doctest:...: DeprecationWarning: the module sage.rings.euclidean_domain is deprecated and will be removed
See http://trac.sagemath.org/20011 for details.
sage: sage.rings.euclidean_domain.is_EuclideanDomain(EuclideanDomain(ZZ))
True
"""
Expand Down
5 changes: 2 additions & 3 deletions src/sage/rings/finite_rings/integer_mod_ring.py
Expand Up @@ -62,7 +62,6 @@
import sage.misc.prandom as random

from sage.arith.all import factor, primitive_root, CRT_basis
import sage.rings.commutative_ring as commutative_ring
import sage.rings.ring as ring
import integer_mod
import sage.rings.integer as integer
Expand Down Expand Up @@ -1506,8 +1505,8 @@ def random_element(self, bound=None):
sage: R.random_element(2) in [R(16), R(17), R(0), R(1), R(2)]
True
"""
if not (bound is None):
return commutative_ring.CommutativeRing.random_element(self, bound)
if bound is not None:
return ring.CommutativeRing.random_element(self, bound)
a = random.randint(0,self.order()-1)
return self(a)

Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/ideal.py
Expand Up @@ -31,7 +31,6 @@

import sage.misc.latex as latex
import sage.rings.ring
import commutative_ring
from sage.structure.element import MonoidElement
from sage.interfaces.singular import singular as singular_default
import sage.rings.infinity
Expand Down Expand Up @@ -189,7 +188,7 @@ def Ideal(*args, **kwds):
R = first
gens = args[1:]

if not commutative_ring.is_CommutativeRing(R):
if not isinstance(R, sage.rings.ring.CommutativeRing):
raise TypeError("R must be a commutative ring")

return R.ideal(*gens, **kwds)
Expand Down

0 comments on commit f36e7f6

Please sign in to comment.