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

Commit

Permalink
12824: Delete some deprecated is_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
JStarx authored and rwst committed Sep 3, 2014
1 parent a86cf93 commit 4236760
Show file tree
Hide file tree
Showing 91 changed files with 169 additions and 552 deletions.
14 changes: 7 additions & 7 deletions src/sage/categories/functor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ cdef class Functor(SageObject):
Category of rings
sage: F.codomain()
Category of commutative additive groups
sage: from sage.categories.functor import is_Functor
sage: is_Functor(F)
sage: from sage.categories.functor import Functor
sage: isinstance(F, Functor)
True
sage: I = IdentityFunctor(abgrps)
sage: I
The identity functor on Category of commutative additive groups
sage: I.domain()
Category of commutative additive groups
sage: is_Functor(I)
sage: isinstance(I, Functor)
True
Note that by default, an instance of the class Functor is coercion
Expand Down Expand Up @@ -174,9 +174,9 @@ cdef class Functor(SageObject):
Finite Field of size 2
"""
if not category.is_Category(domain):
if not isinstance(domain, category.Category):
raise TypeError, "domain (=%s) must be a category"%domain
if not category.is_Category(codomain):
if not isinstance(codomain, category.Category):
raise TypeError, "codomain (=%s) must be a category"%codomain
self.__domain = domain
self.__codomain = codomain
Expand Down Expand Up @@ -365,8 +365,8 @@ cdef class Functor(SageObject):
TypeError: Functor from Category of rings to Category of rings is ill-defined, since it sends x (=Rational Field) to something that is not in Category of rings.
"""
from sage.categories.morphism import is_Morphism
if is_Morphism(x):
from sage.categories.morphism import Morphism
if isinstance(x, Morphism):
return self._apply_functor_to_morphism(x)
y = self._apply_functor(self._coerce_into_domain(x))
if not ((y in self.__codomain) or (y in self.__codomain.hom_category())):
Expand Down
3 changes: 0 additions & 3 deletions src/sage/categories/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ def make_morphism(_class, parent, _dict, _slots):
mor.__dict__ = _dict
return mor

def is_Morphism(x):
return isinstance(x, Morphism)

cdef class Morphism(Map):

def _repr_(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/kazhdan_lusztig.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, W, q, trace=False):
self._trace = trace
self._one = W.one()
self._base_ring = q.parent()
if is_Polynomial(q):
if isinstance(q, Polynomial):
self._base_ring_type = "polynomial"
elif isinstance(q, LaurentPolynomial_generic):
self._base_ring_type = "laurent"
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/sf/sfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -4684,7 +4684,7 @@ def _nonnegative_coefficients(x):
sage: _nonnegative_coefficients(x^2-4)
False
"""
if is_Polynomial(x) or is_MPolynomial(x):
if isinstance(x, Polynomial) or is_MPolynomial(x):
return all([ c >= 0 for c in x.coeffs() ])
else:
return x >= 0
Expand Down
4 changes: 2 additions & 2 deletions src/sage/crypto/boolean_function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from sage.rings.finite_rings.constructor import GF
from sage.rings.polynomial.pbori import BooleanPolynomial
from sage.rings.finite_rings.constructor import is_FiniteField
from sage.rings.finite_rings.finite_field_givaro import FiniteField_givaro
from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.polynomial_element import Polynomial

include "sage/misc/bitset.pxi"
from cpython.string cimport *
Expand Down Expand Up @@ -322,7 +322,7 @@ cdef class BooleanFunction(SageObject):
bitset_init(self._truth_table,(1<<self._nvariables))
bitset_zero(self._truth_table)

elif is_Polynomial(x):
elif isinstance(x, Polynomial):
K = x.base_ring()
if is_FiniteField(K) and K.characteristic() == 2:
self._nvariables = K.degree()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/crypto/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sage.rings.arith import power_mod
from sage.rings.finite_rings.constructor import FiniteField
from sage.rings.finite_rings.integer_mod_ring import IntegerModFactory
from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing

IntegerModRing = IntegerModFactory("IntegerModRing")
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/toric_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@
#*****************************************************************************


from sage.geometry.toric_lattice_element import (ToricLatticeElement,
is_ToricLatticeElement)
from sage.geometry.toric_lattice_element import ToricLatticeElement
from sage.geometry.toric_plotter import ToricPlotter
from sage.misc.all import latex, parent
from sage.modules.fg_pid.fgp_element import FGP_Element
Expand Down Expand Up @@ -456,7 +455,7 @@ def __call__(self, *args, **kwds):
coordinates = map(ZZ, args)
except TypeError:
# Prohibit conversion of elements of other lattices
if (is_ToricLatticeElement(args[0])
if (isinstance(args[0], ToricLatticeElement)
and args[0].parent().ambient_module()
is not self.ambient_module()):
raise TypeError("%s cannot be converted to %s!"
Expand Down
31 changes: 2 additions & 29 deletions src/sage/geometry/toric_lattice_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,6 @@ from sage.structure.element cimport Element, Vector
from sage.rings.integer cimport Integer


def is_ToricLatticeElement(x):
r"""
Check if ``x`` is an element of a toric lattice.
INPUT:
- ``x`` -- anything.
OUTPUT:
- ``True`` if ``x`` is an element of a toric lattice, ``False`` otherwise.
EXAMPLES::
sage: from sage.geometry.toric_lattice_element import (
... is_ToricLatticeElement)
sage: is_ToricLatticeElement(1)
False
sage: e = ToricLattice(3).an_element()
sage: e
N(1, 0, 0)
sage: is_ToricLatticeElement(e)
True
"""
return isinstance(x, ToricLatticeElement)


# Why do we need a special class:
# - customize output to include lattice name
# - prohibit operations mixing "wrong" lattices
Expand Down Expand Up @@ -291,7 +264,7 @@ cdef class ToricLatticeElement(Vector_integer_dense):
"""
Ns = self.parent()
# We try to deal only with the case of two lattice elements...
if is_ToricLatticeElement(other):
if isinstance(other, ToricLatticeElement):
if other.parent().ambient_module() is Ns.ambient_module().dual():
# Our own _dot_product_ is disabled
return Vector_integer_dense._dot_product_(self, other)
Expand All @@ -305,7 +278,7 @@ cdef class ToricLatticeElement(Vector_integer_dense):
# We also allow action on elements of lattice quotients
try:
lift = other.lift()
if is_ToricLatticeElement(lift):
if isinstance(lift, ToricLatticeElement):
if other.parent().W().is_submodule(Ns.dual().W()):
return Vector_integer_dense._dot_product_(self, lift)
raise CoercionException("only elements of dual toric lattices "
Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def PermutationGroup(gens=None, gap_group=None, domain=None, canonicalize=True,
...
TypeError: gens must be a tuple, list, or GapElement
"""
if not is_ExpectElement(gens) and hasattr(gens, '_permgroup_'):
if not isinstance(gens, ExpectElement) and hasattr(gens, '_permgroup_'):
return gens._permgroup_()
if gens is not None and not isinstance(gens, (tuple, list, GapElement)):
raise TypeError("gens must be a tuple, list, or GapElement")
Expand Down
4 changes: 2 additions & 2 deletions src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ include "sage/ext/interrupt.pxi"
from cpython.list cimport *

from sage.rings.all import ZZ, Integer
from sage.rings.polynomial.polynomial_element import is_Polynomial
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.rings.polynomial.multi_polynomial import is_MPolynomial
from sage.matrix.matrix import is_Matrix
from sage.matrix.all import MatrixSpace
Expand Down Expand Up @@ -837,7 +837,7 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
"""
if not self_on_left:
left = x
if is_Polynomial(left):
if isinstance(left, Polynomial):
if self != 1:
raise ValueError, "%s does not act on %s"%(self, left.parent())
return left
Expand Down
4 changes: 2 additions & 2 deletions src/sage/gsl/dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
from sage.rings.number_field.number_field import CyclotomicField
from sage.plot.all import polygon, line, text
from sage.groups.abelian_gps.abelian_group import AbelianGroup
from sage.groups.perm_gps.permgroup_element import is_PermutationGroupElement
from sage.groups.perm_gps.permgroup_element import PermutationGroupElement
from sage.rings.integer_ring import ZZ
from sage.rings.integer import Integer
from sage.rings.arith import factor
Expand Down Expand Up @@ -333,7 +333,7 @@ def dft(self, chi = lambda x: x):
zeta = CyclotomicField(N).gen()
FT = [sum([S[i]*chi(zeta**(i*j)) for i in J]) for j in J]
elif not(J[0] in ZZ) and G.is_abelian() and F == ZZ or (F.is_field() and F.base_ring()==QQ):
if is_PermutationGroupElement(J[0]):
if isinstance(J[0], PermutationGroupElement):
## J is a CyclicPermGp
n = G.order()
a = list(factor(n))
Expand Down
3 changes: 0 additions & 3 deletions src/sage/interfaces/expect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,9 +1287,6 @@ class FunctionElement(InterfaceFunctionElement):
pass


def is_ExpectElement(x):
return isinstance(x, ExpectElement)

class ExpectElement(InterfaceElement):
"""
Expect element.
Expand Down
3 changes: 0 additions & 3 deletions src/sage/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,6 @@ def _sage_doc_(self):



def is_InterfaceElement(x):
return isinstance(x, InterfaceElement)

class InterfaceElement(RingElement):
"""
Interface element.
Expand Down
3 changes: 0 additions & 3 deletions src/sage/interfaces/kash.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,6 @@ def __repr__(self):
return '\n'.join(self)


def is_KashElement(x):
return isinstance(x, KashElement)

############

###########
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interfaces/macaulay2.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
-- William Stein (2006-02-09): fixed bug in reading from file and
improved output cleaning.
-- Kiran Kedlaya (2006-02-12): added ring and ideal constructors,
list delimiters, is_Macaulay2Element, sage_polystring,
list delimiters, Macaulay2Element, sage_polystring,
__floordiv__, __mod__, __iter__, __len__; stripped extra
leading space and trailing newline from output.
Expand Down
6 changes: 3 additions & 3 deletions src/sage/matrix/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ AUTHOR:

import operator

from matrix_space import MatrixSpace, is_MatrixSpace
from matrix_space import MatrixSpace
from sage.modules.free_module import FreeModule, is_FreeModule


cdef class MatrixMulAction(Action):
def __init__(self, G, S, is_left):
if not is_MatrixSpace(G):
if not isinstance(G, MatrixSpace):
raise TypeError, "Not a matrix space: %s" % G
if G.base_ring() is not S.base_ring():
from sage.categories.pushout import pushout
Expand Down Expand Up @@ -136,7 +136,7 @@ cdef class MatrixMatrixAction(MatrixMulAction):
example is good practice.
"""
if not is_MatrixSpace(S):
if not isinstance(S, MatrixSpace):
raise TypeError, "Not a matrix space: %s" % S
MatrixMulAction.__init__(self, G, S, True)

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ def elementary_matrix(arg0, arg1=None, **kwds):
R = arg0
arg0 = arg1
elif scale is not None:
if not sage.structure.element.is_RingElement(scale):
if not isinstance(scale, sage.structure.element.RingElement):
raise TypeError('scale must be an element of some ring, not {0}'.format(scale))
R = scale.parent()
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_integer_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from sage.modules.vector_integer_dense cimport Vector_integer_dense
from sage.misc.misc import verbose, get_verbose, cputime

from sage.rings.arith import previous_prime
from sage.structure.element import is_Element
from sage.structure.element import Element
from sage.structure.proof.proof import get_flag as get_proof_flag

from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense
Expand Down Expand Up @@ -394,7 +394,7 @@ cdef class Matrix_integer_dense(matrix_dense.Matrix_dense): # dense or sparse
if entries is None:
x = ZZ(0)
is_list = 0
elif isinstance(entries, (int,long)) or is_Element(entries):
elif isinstance(entries, (int,long)) or isinstance(entries, Element):
try:
x = ZZ(entries)
except TypeError:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,9 +1459,9 @@ def numerical_approx(x, prec=None, digits=None, algorithm=None):
try:
return x._numerical_approx(prec, algorithm=algorithm)
except AttributeError:
from sage.rings.complex_double import is_ComplexDoubleElement
from sage.rings.complex_double import ComplexDoubleElement
from sage.rings.complex_number import is_ComplexNumber
if not (is_ComplexNumber(x) or is_ComplexDoubleElement(x)):
if not (is_ComplexNumber(x) or isinstance(x, ComplexDoubleElement)):
try:
return sage.rings.real_mpfr.RealField(prec)(x)
# Trac 10761: now catches ValueErrors as well as TypeErrors
Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/sage_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3290,8 +3290,8 @@ def verify_same(a, b):
assert(a.parent() == b.parent())
AssertionError
"""
from sage.structure.element import is_Element
if is_Element(a):
from sage.structure.element import Element
if isinstance(a, Element):
assert(a.parent() == b.parent())
else:
assert(isinstance(a, type(b)))
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/abvar/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sage.rings.integer import Integer

from sage.modular.arithgroup.all import is_CongruenceSubgroup, Gamma0
from sage.modular.modsym.space import is_ModularSymbolsSpace
from sage.modular.modsym.space import ModularSymbolsSpace
from abvar_newform import ModularAbelianVariety_newform
import sage.modular.modform.element
import abvar
Expand Down Expand Up @@ -182,7 +182,7 @@ def AbelianVariety(X):
elif isinstance(X, sage.modular.modform.element.Newform):
return ModularAbelianVariety_newform(X)

if is_ModularSymbolsSpace(X):
if isinstance(X, ModularSymbolsSpace):
return abvar.ModularAbelianVariety_modsym(X)

if isinstance(X, (tuple,list)) and all([is_CongruenceSubgroup(G) for G in X]):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/arithgroup/all.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Note: the is_xxx functions are imported to here, but not from here up to sage.modular.all, so
# they are invisible to the user but easy to import all in one go by other code that needs them.

from arithgroup_generic import is_ArithmeticSubgroup
from arithgroup_generic import ArithmeticSubgroup
from congroup_generic import is_CongruenceSubgroup, CongruenceSubgroup_constructor as CongruenceSubgroup
from congroup_gammaH import GammaH_constructor as GammaH, is_GammaH
from congroup_gamma1 import Gamma1_constructor as Gamma1, is_Gamma1
Expand Down
16 changes: 0 additions & 16 deletions src/sage/modular/arithgroup/arithgroup_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,6 @@

from arithgroup_element import ArithmeticSubgroupElement

def is_ArithmeticSubgroup(x):
r"""
Return True if x is of type ArithmeticSubgroup.
EXAMPLE::
sage: from sage.modular.arithgroup.all import is_ArithmeticSubgroup
sage: is_ArithmeticSubgroup(GL(2, GF(7)))
False
sage: is_ArithmeticSubgroup(Gamma0(4))
True
"""

return isinstance(x, ArithmeticSubgroup)


class ArithmeticSubgroup(group.Group):
r"""
Base class for arithmetic subgroups of `{\rm SL}_2(\ZZ)`. Not
Expand Down
Loading

0 comments on commit 4236760

Please sign in to comment.