Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate is_FreeAlgebraQuotientElement, ... #38184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/sage/algebras/free_algebra_quotient_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def is_FreeAlgebraQuotientElement(x):

sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(QQ)
sage: sage.algebras.free_algebra_quotient_element.is_FreeAlgebraQuotientElement(i)
doctest:warning...
DeprecationWarning: The function is_FreeAlgebraQuotientElement is deprecated;
use 'isinstance(..., FreeAlgebraQuotientElement)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
True

Of course this is testing the data type::
Expand All @@ -47,6 +51,10 @@ def is_FreeAlgebraQuotientElement(x):
sage: sage.algebras.free_algebra_quotient_element.is_FreeAlgebraQuotientElement(H(1))
True
"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_FreeAlgebraQuotientElement is deprecated; "
"use 'isinstance(..., FreeAlgebraQuotientElement)' instead.")
return isinstance(x, FreeAlgebraQuotientElement)


Expand Down
21 changes: 13 additions & 8 deletions src/sage/categories/functor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,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 @@ -422,12 +422,9 @@ cdef class Functor(SageObject):

def is_Functor(x):
"""
Test whether the argument is a functor

NOTE:
Test whether the argument is a functor.

There is a deprecation warning when using it from top level.
Therefore we import it in our doc test.
This function is deprecated.

EXAMPLES::

Expand All @@ -436,6 +433,10 @@ def is_Functor(x):
sage: F1
FractionField
sage: is_Functor(F1)
doctest:warning...
DeprecationWarning: The function is_Functor is deprecated;
use 'isinstance(..., Functor)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
True
sage: is_Functor(FractionField)
False
Expand All @@ -446,6 +447,10 @@ def is_Functor(x):
True

"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_Functor is deprecated; "
"use 'isinstance(..., Functor)' instead.")
return isinstance(x, Functor)


Expand Down
8 changes: 8 additions & 0 deletions src/sage/groups/abelian_gps/abelian_group_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ def is_AbelianGroupElement(x):

sage: from sage.groups.abelian_gps.abelian_group_element import is_AbelianGroupElement
sage: is_AbelianGroupElement(3)
doctest:warning...
DeprecationWarning: The function is_AbelianGroupElement is deprecated;
use 'isinstance(..., AbelianGroupElement)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
False
sage: F = AbelianGroup(5, [3,4,5,8,7], 'abcde')
sage: is_AbelianGroupElement(F.0)
True
"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_AbelianGroupElement is deprecated; "
"use 'isinstance(..., AbelianGroupElement)' instead.")
return isinstance(x, AbelianGroupElement)


Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/abelian_gps/dual_abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def __contains__(self, X):
sage: A*B^2*D^7 in Fd
True
"""
return X.parent() == self and is_DualAbelianGroupElement(X)
return X.parent() == self and isinstance(X, DualAbelianGroupElement)

def order(self):
"""
Expand Down
8 changes: 8 additions & 0 deletions src/sage/groups/abelian_gps/dual_abelian_group_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ def is_DualAbelianGroupElement(x) -> bool:
sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroupElement
sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group()
sage: is_DualAbelianGroupElement(F)
doctest:warning...
DeprecationWarning: The function is_DualAbelianGroupElement is deprecated;
use 'isinstance(..., DualAbelianGroupElement)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
False
sage: is_DualAbelianGroupElement(F.an_element())
True
"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_DualAbelianGroupElement is deprecated; "
"use 'isinstance(..., DualAbelianGroupElement)' instead.")
return isinstance(x, DualAbelianGroupElement)


Expand Down
8 changes: 8 additions & 0 deletions src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,16 @@ def is_PermutationGroupElement(x):
sage: p = PermutationGroupElement([(1,2),(3,4,5)])
sage: from sage.groups.perm_gps.permgroup_element import is_PermutationGroupElement
sage: is_PermutationGroupElement(p)
doctest:warning...
DeprecationWarning: The function is_PermutationGroupElement is deprecated;
use 'isinstance(..., PermutationGroupElement)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
True
"""
from sage.misc.superseded import deprecation_cython
deprecation_cython(38184,
"The function is_PermutationGroupElement is deprecated; "
"use 'isinstance(..., PermutationGroupElement)' instead.")
return isinstance(x, PermutationGroupElement)


Expand Down
8 changes: 8 additions & 0 deletions src/sage/homology/chain_complex_homspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,17 @@ def is_ChainComplexHomspace(x):
sage: C = T.chain_complex(augmented=True, cochain=True)
sage: G = Hom(C, C)
sage: is_ChainComplexHomspace(G)
doctest:warning...
DeprecationWarning: The function is_ChainComplexHomspace is deprecated;
use 'isinstance(..., ChainComplexHomspace)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
True

"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_ChainComplexHomspace is deprecated; "
"use 'isinstance(..., ChainComplexHomspace)' instead.")
return isinstance(x, ChainComplexHomspace)


Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ from sage.arith.numerical_approx cimport digits_to_bits

import sage.modules.free_module
from sage.matrix import berlekamp_massey
from sage.modules.free_module_element import is_FreeModuleElement
from sage.modules.free_module_element import FreeModuleElement
from sage.matrix.matrix_misc import permanental_minor_polynomial

from sage.misc.misc_c import prod
Expand Down Expand Up @@ -6017,7 +6017,7 @@ cdef class Matrix(Matrix1):
"""
if v == 0:
return []
if not is_FreeModuleElement(v):
if not isinstance(v, FreeModuleElement):
raise TypeError("v must be a FreeModuleElement")
VS = v.parent()
V = VS.span([v])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@
....: png(ZZ[x], f.name)
"""
import sage.plot.all
if sage.plot.graphics.is_Graphics(x):
if isinstance(x, sage.plot.graphics.Graphics):

Check warning on line 1937 in src/sage/misc/latex.py

View check run for this annotation

Codecov / codecov/patch

src/sage/misc/latex.py#L1937

Added line #L1937 was not covered by tests
x.save(filename)
return
# if not graphics: create a string of latex code to write in a file
Expand Down
12 changes: 10 additions & 2 deletions src/sage/modular/dirichlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,18 @@ def is_DirichletCharacter(x) -> bool:

sage: from sage.modular.dirichlet import is_DirichletCharacter
sage: is_DirichletCharacter(trivial_character(3))
doctest:warning...
DeprecationWarning: The function is_DirichletCharacter is deprecated;
use 'isinstance(..., DirichletCharacter)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
True
sage: is_DirichletCharacter([1])
False
"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_DirichletCharacter is deprecated; "
"use 'isinstance(..., DirichletCharacter)' instead.")
return isinstance(x, DirichletCharacter)


Expand Down Expand Up @@ -262,7 +270,7 @@ def __init__(self, parent, x, check=True):
orders = parent.integers_mod().unit_group().gens_orders()
if len(x) != len(orders):
raise ValueError("wrong number of values (= {}) on generators (want {})".format(x, len(orders)))
if free_module_element.is_FreeModuleElement(x):
if isinstance(x, free_module_element.FreeModuleElement):
x = parent._module(x)
if any(u * v for u, v in zip(x, orders)):
raise ValueError("values (= {} modulo {}) must have additive orders dividing {}, respectively"
Expand All @@ -276,7 +284,7 @@ def __init__(self, parent, x, check=True):
.format(x, orders))
self.values_on_gens.set_cache(x)
else:
if free_module_element.is_FreeModuleElement(x):
if isinstance(x, free_module_element.FreeModuleElement):
self.element.set_cache(x)
else:
self.values_on_gens.set_cache(x)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/modform/ambient_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __init__(self, character, weight=2, base_ring=None, eis_only=False):
sage: type(m)
<class 'sage.modular.modform.ambient_eps.ModularFormsAmbient_eps_with_category'>
"""
if not dirichlet.is_DirichletCharacter(character):
if not isinstance(character, dirichlet.DirichletCharacter):
raise TypeError("character (=%s) must be a Dirichlet character" % character)
if base_ring is None:
base_ring = character.base_ring()
Expand Down
12 changes: 10 additions & 2 deletions src/sage/modular/modform/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,18 @@ def is_ModularFormElement(x):

sage: from sage.modular.modform.element import is_ModularFormElement
sage: is_ModularFormElement(5)
doctest:warning...
DeprecationWarning: The function is_ModularFormElement is deprecated;
use 'isinstance(..., ModularFormElement)' instead.
See https://github.com/sagemath/sage/issues/38184 for details.
False
sage: is_ModularFormElement(ModularForms(11).0)
True
"""
from sage.misc.superseded import deprecation
deprecation(38184,
"The function is_ModularFormElement is deprecated; "
"use 'isinstance(..., ModularFormElement)' instead.")
return isinstance(x, ModularFormElement)


Expand Down Expand Up @@ -3265,7 +3273,7 @@ def __init__(self, parent, forms_datum):
k = ZZ(k)
if k == 0:
forms_dictionary[k] = parent.base_ring().coerce(f)
elif is_ModularFormElement(f):
elif isinstance(f, ModularFormElement):
if f.weight() == k:
if parent.group().is_subgroup(f.group()) and parent.base_ring().has_coerce_map_from(f.base_ring()):
M = parent.modular_forms_of_weight(f.weight()).change_ring(parent.base_ring())
Expand All @@ -3280,7 +3288,7 @@ def __init__(self, parent, forms_datum):
raise ValueError('at least one key (%s) of the defining dictionary is not an integer' % (k))
elif isinstance(forms_datum, list):
for f in forms_datum:
if is_ModularFormElement(f):
if isinstance(f, ModularFormElement):
chi = f.character(compute=False)
if (chi is not None) and (not chi.is_trivial()):
raise NotImplementedError("graded modular forms for non-trivial characters is not yet implemented")
Expand Down
12 changes: 6 additions & 6 deletions src/sage/modular/modform/hecke_operator_on_qexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

lazy_import('sage.rings.number_field.number_field', 'CyclotomicField')

from sage.modular.dirichlet import DirichletGroup, is_DirichletCharacter
from .element import is_ModularFormElement
from sage.modular.dirichlet import DirichletGroup, DirichletCharacter
from .element import ModularFormElement

def hecke_operator_on_qexp(f, n, k, eps=None,
prec=None, check=True, _return_list=False):
Expand Down Expand Up @@ -87,16 +87,16 @@ def hecke_operator_on_qexp(f, n, k, eps=None,
# ZZ can coerce to GF(p), but QQ can't.
eps = DirichletGroup(1, base_ring=ZZ)[0]
if check:
if not (is_PowerSeries(f) or is_ModularFormElement(f)):
if not (is_PowerSeries(f) or isinstance(f, ModularFormElement)):
raise TypeError("f (=%s) must be a power series or modular form" % f)
if not is_DirichletCharacter(eps):
if not isinstance(eps, DirichletCharacter):
raise TypeError("eps (=%s) must be a Dirichlet character" % eps)
k = Integer(k)
n = Integer(n)
v = []

if prec is None:
if is_ModularFormElement(f):
if isinstance(f, ModularFormElement):
# always want at least three coefficients, but not too many, unless
# requested
pr = max(f.prec(), f.parent().prec(), (n+1)*3)
Expand All @@ -123,7 +123,7 @@ def hecke_operator_on_qexp(f, n, k, eps=None,
v.append(am)
if _return_list:
return v
if is_ModularFormElement(f):
if isinstance(f, ModularFormElement):
R = f.parent()._q_expansion_ring()
else:
R = f.parent()
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/modform/ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from sage.structure.richcmp import richcmp_method, richcmp

from .constructor import ModularForms
from .element import is_ModularFormElement, GradedModularFormElement
from .element import ModularFormElement, GradedModularFormElement
from .space import ModularFormsSpace


Expand Down Expand Up @@ -517,7 +517,7 @@ def _element_constructor_(self, forms_datum):
forms_dictionary = forms_datum
elif isinstance(forms_datum, self.element_class):
forms_dictionary = forms_datum._forms_dictionary
elif is_ModularFormElement(forms_datum):
elif isinstance(forms_datum, ModularFormElement):
if self.group().is_subgroup(forms_datum.group()) and self.base_ring().has_coerce_map_from(forms_datum.base_ring()):
forms_dictionary = {forms_datum.weight(): forms_datum}
else:
Expand Down
6 changes: 3 additions & 3 deletions src/sage/modular/modform_hecketriangle/abstract_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sage.matrix.constructor import matrix
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_import import lazy_import
from sage.modules.free_module_element import is_FreeModuleElement
from sage.modules.free_module_element import FreeModuleElement
from sage.modules.free_module_element import vector
from sage.rings.infinity import infinity
from sage.rings.integer import Integer
Expand Down Expand Up @@ -262,9 +262,9 @@ def _element_constructor_(self, el):
return self.construct_form(el)
else:
return self.construct_quasi_form(el)
if is_FreeModuleElement(el) and (self.module() is P or self.ambient_module() is P):
if isinstance(el, FreeModuleElement) and (self.module() is P or self.ambient_module() is P):
return self.element_from_ambient_coordinates(el)
if (not self.is_ambient()) and (isinstance(el, list) or isinstance(el, tuple) or is_FreeModuleElement(el)) and len(el) == self.rank():
if (not self.is_ambient()) and (isinstance(el, list) or isinstance(el, tuple) or isinstance(el, FreeModuleElement)) and len(el) == self.rank():
try:
return self.element_from_coordinates(el)
except (ArithmeticError, TypeError):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/modsym/ambient.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ``ModularSymbolsAmbient``, derived from
from sage.misc.latex import latex
from sage.misc.verbose import verbose
from sage.modular.arithgroup.arithgroup_element import M2Z
from sage.modular.dirichlet import TrivialCharacter, is_DirichletCharacter
from sage.modular.dirichlet import DirichletCharacter, TrivialCharacter
from sage.modular.hecke.ambient_module import AmbientHeckeModule
from sage.modular.cusps import Cusp
from sage.modular.modsym.apply import apply_to_monomial
Expand Down Expand Up @@ -2171,7 +2171,7 @@ def twisted_winding_element(self, i, eps):
sage: M.twisted_winding_element(0,eps)
2*(1,23) - 2*(1,32) + 2*(1,34)
"""
if not is_DirichletCharacter(eps):
if not isinstance(eps, DirichletCharacter):
raise TypeError("eps must be a Dirichlet character.")
if (i < 0) or (i > self.weight() - 2):
raise ValueError("i must be between 0 and k-2.")
Expand Down
6 changes: 3 additions & 3 deletions src/sage/modular/modsym/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
from sage.structure.richcmp import richcmp_method, richcmp

import sage.modules.free_module as free_module
from sage.modules.free_module_element import is_FreeModuleElement
from sage.modules.free_module_element import FreeModuleElement

import sage.modular.arithgroup.all as arithgroup
import sage.modular.cusps as cusps
Expand Down Expand Up @@ -554,7 +554,7 @@ def __call__(self, x):
elif isinstance(x, ManinSymbol):
return self._coerce_in_manin_symbol(x)

elif element.is_ModularSymbolsElement(x):
elif isinstance(x, element.ModularSymbolsElement):
M = x.parent()
if not isinstance(M, ModularSymbolsAmbient):
raise TypeError("x (=%s) must be an element of a space of modular symbols of type ModularSymbolsAmbient" % x)
Expand All @@ -566,7 +566,7 @@ def __call__(self, x):
return self(0)
return sum([c * self._coerce_in_manin_symbol(v) for c, v in S])

elif is_FreeModuleElement(x):
elif isinstance(x, FreeModuleElement):
y = dict(enumerate(x))
return BoundarySpaceElement(self, y)

Expand Down
Loading
Loading