Skip to content
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
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,11 +1462,11 @@ def _coerce_map_from_(self, S):
return self.has_coerce_map_from(MS)

try:
from sage.modular.arithgroup.arithgroup_generic import is_ArithmeticSubgroup
from sage.modular.arithgroup.arithgroup_generic import ArithmeticSubgroup
except ImportError:
pass
else:
if is_ArithmeticSubgroup(S):
if isinstance(S, ArithmeticSubgroup):
return self.has_coerce_map_from(MS)

return False
Expand Down
57 changes: 31 additions & 26 deletions src/sage/modular/abvar/abvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
from sage.matrix.special import block_diagonal_matrix, identity_matrix
from sage.misc.lazy_import import lazy_import
from sage.misc.misc_c import prod
from sage.modular.arithgroup.congroup_gamma0 import is_Gamma0
from sage.modular.arithgroup.congroup_gamma1 import is_Gamma1
from sage.modular.arithgroup.congroup_gammaH import is_GammaH
from sage.modular.arithgroup.congroup_generic import is_CongruenceSubgroup
from sage.modular.arithgroup.congroup_gamma0 import Gamma0_class
from sage.modular.arithgroup.congroup_gamma1 import Gamma1_class
from sage.modular.arithgroup.congroup_gammaH import GammaH_class
from sage.modular.arithgroup.congroup_generic import CongruenceSubgroupBase
from sage.modular.modform.constructor import Newform
from sage.modular.modsym.modsym import ModularSymbols
from sage.modular.modsym.space import ModularSymbolsSpace
Expand Down Expand Up @@ -91,6 +91,9 @@ def is_ModularAbelianVariety(x) -> bool:

sage: from sage.modular.abvar.abvar import is_ModularAbelianVariety
sage: is_ModularAbelianVariety(5)
doctest:warning...
DeprecationWarning: The function is_ModularAbelianVariety is deprecated; use 'isinstance(..., ModularAbelianVariety_abstract)' instead.
See https://github.com/sagemath/sage/issues/38035 for details.
False
sage: is_ModularAbelianVariety(J0(37))
True
Expand All @@ -101,6 +104,8 @@ def is_ModularAbelianVariety(x) -> bool:
sage: is_ModularAbelianVariety(EllipticCurve('37a'))
False
"""
from sage.misc.superseded import deprecation
deprecation(38035, "The function is_ModularAbelianVariety is deprecated; use 'isinstance(..., ModularAbelianVariety_abstract)' instead.")
return isinstance(x, ModularAbelianVariety_abstract)


Expand Down Expand Up @@ -161,7 +166,7 @@ def __init__(self, groups, base_field, is_simple=None, newform_level=None,
if not isinstance(groups, tuple):
raise TypeError("groups must be a tuple")
for G in groups:
if not is_CongruenceSubgroup(G):
if not isinstance(G, CongruenceSubgroupBase):
raise TypeError("each element of groups must be a congruence subgroup")
self.__groups = groups
if is_simple is not None:
Expand Down Expand Up @@ -215,7 +220,7 @@ def is_J0(self) -> bool:
sage: (J0(23) * J0(21)).is_J0()
False
"""
return len(self.groups()) == 1 and is_Gamma0(self.groups()[0]) \
return len(self.groups()) == 1 and isinstance(self.groups()[0], Gamma0_class) \
and self.is_ambient()

def is_J1(self) -> bool:
Expand All @@ -237,7 +242,7 @@ def is_J1(self) -> bool:
sage: J1(23)[0].is_J1()
False
"""
return len(self.groups()) == 1 and is_Gamma1(self.groups()[0]) \
return len(self.groups()) == 1 and isinstance(self.groups()[0], Gamma1_class) \
and self.is_ambient()

##########################################################################
Expand Down Expand Up @@ -605,11 +610,11 @@ def newform_label(self):
ValueError: self must be simple
"""
N, G = self.newform_level()
if is_Gamma0(G):
if isinstance(G, Gamma0_class):
group = ''
elif is_Gamma1(G):
elif isinstance(G, Gamma1_class):
group = 'G1'
elif is_GammaH(G):
elif isinstance(G, GammaH_class):
group = 'GH%s' % (str(G._generators_for_H()).replace(' ', ''))
return '%s%s%s' % (N, cremona_letter_code(self.isogeny_number()), group)

Expand Down Expand Up @@ -765,7 +770,7 @@ def _simple_isogeny(self, other):
...
NotImplementedError: _simple_isogeny only implemented when both abelian variety have the same ambient product Jacobian
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
raise TypeError("other must be a modular abelian variety")

if not self.is_simple():
Expand Down Expand Up @@ -832,7 +837,7 @@ def in_same_ambient_variety(self, other):
sage: A.in_same_ambient_variety(J0(11))
False
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
return False
if self.groups() != other.groups():
return False
Expand Down Expand Up @@ -1083,7 +1088,7 @@ def __add__(self, other):
sage: A+B # long time
Abelian subvariety of dimension 20 of J0(206)
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
if other == 0:
return self
raise TypeError("other must be a modular abelian variety")
Expand Down Expand Up @@ -1172,7 +1177,7 @@ def __mul__(self, other):
sage: d[0] * d[1] * J0(11)
Abelian subvariety of dimension 4 of J0(65) x J0(65) x J0(11)
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
raise TypeError("other must be a modular abelian variety")
if other.base_ring() != self.base_ring():
raise TypeError("self and other must have the same base ring")
Expand Down Expand Up @@ -1968,7 +1973,7 @@ def is_subvariety(self, other) -> bool:
sage: A.is_subvariety(J)
True
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
return False
if self is other:
return True
Expand Down Expand Up @@ -2104,11 +2109,11 @@ def _ambient_repr(self):
"""
v = []
for G in self.groups():
if is_Gamma0(G):
if isinstance(G, Gamma0_class):
v.append('J0(%s)' % G.level())
elif is_Gamma1(G):
elif isinstance(G, Gamma1_class):
v.append('J1(%s)' % G.level())
elif is_GammaH(G):
elif isinstance(G, GammaH_class):
v.append('JH(%s,%s)' % (G.level(), G._generators_for_H()))
return ' x '.join(v)

Expand All @@ -2125,11 +2130,11 @@ def _ambient_latex_repr(self):
"""
v = []
for G in self.groups():
if is_Gamma0(G):
if isinstance(G, Gamma0_class):
v.append('J_0(%s)' % G.level())
elif is_Gamma1(G):
elif isinstance(G, Gamma1_class):
v.append('J_1(%s)' % G.level())
elif is_GammaH(G):
elif isinstance(G, GammaH_class):
v.append('J_H(%s,%s)' % (G.level(), G._generators_for_H()))
return ' \\times '.join(v)

Expand Down Expand Up @@ -4099,7 +4104,7 @@ def __add__(self, other):
sage: sum(D, D[0]) == A
True
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
if other == 0:
return self
raise TypeError("sum not defined")
Expand Down Expand Up @@ -4397,7 +4402,7 @@ def is_subvariety(self, other):
sage: D[2].is_subvariety(D[0] + D[1])
False
"""
if not is_ModularAbelianVariety(other):
if not isinstance(other, ModularAbelianVariety_abstract):
return False
if not isinstance(other, ModularAbelianVariety_modsym_abstract):
return ModularAbelianVariety_abstract.is_subvariety(self, other)
Expand Down Expand Up @@ -4695,7 +4700,7 @@ def component_group_order(self, p):
self.__component_group[p] = (one, one, one)
return one
# Cases that we don't know how to handle yet.
if not is_Gamma0(self.group()):
if not isinstance(self.group(), Gamma0_class):
raise NotImplementedError("computation of component group not implemented when group isn't Gamma0")
if self.level() % (p * p) == 0:
raise NotImplementedError("computation of component group not implemented when p^2 divides the level")
Expand Down Expand Up @@ -4879,7 +4884,7 @@ def tamagawa_number_bounds(self, p):
mul = 1
elif N.valuation(p) == 1:
M = self.modular_symbols(sign=1)
if is_Gamma0(M.group()):
if isinstance(M.group(), Gamma0_class):
g = self.component_group_order(p)
W = M.atkin_lehner_operator(p).matrix()
if W == -1:
Expand Down Expand Up @@ -4941,7 +4946,7 @@ def brandt_module(self, p):
except KeyError:
pass
p = Integer(p)
if not is_Gamma0(self.group()):
if not isinstance(self.group(), Gamma0_class):
raise NotImplementedError("Brandt module only defined on Gamma0")
if not p.is_prime():
raise ValueError("p must be a prime integer")
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/abvar/abvar_ambient_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from sage.modular.modsym.modsym import ModularSymbols
from sage.modular.modform.constructor import Newforms
from sage.modular.arithgroup.all import is_Gamma0, is_Gamma1
from sage.modular.arithgroup.all import Gamma0_class, Gamma1_class
from . import morphism


Expand Down Expand Up @@ -414,7 +414,7 @@ def newform_decomposition(self, names=None):
if self.dimension() == 0:
return []
G = self.group()
if not (is_Gamma0(G) or is_Gamma1(G)):
if not (isinstance(G, Gamma0_class) or isinstance(G, Gamma1_class)):
return [S.newform(names=names) for S in self.decomposition()]
Gtype = G.parent()
N = G.level()
Expand Down
8 changes: 4 additions & 4 deletions src/sage/modular/abvar/abvar_newform.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sage.rings.rational_field import QQ

from sage.modular.modform.element import Newform
from sage.modular.arithgroup.all import is_Gamma0, is_Gamma1, is_GammaH
from sage.modular.arithgroup.all import Gamma0_class, Gamma1_class, GammaH_class

from .abvar import ModularAbelianVariety_modsym_abstract
from . import homspace
Expand Down Expand Up @@ -134,11 +134,11 @@ def label(self) -> str:
'43b'
"""
G = self.__f.group()
if is_Gamma0(G):
if isinstance(G, Gamma0_class):
group = ''
elif is_Gamma1(G):
elif isinstance(G, Gamma1_class):
group = 'G1'
elif is_GammaH(G):
elif isinstance(G, GammaH_class):
group = 'GH[' + ','.join(str(z) for z in G._generators_for_H()) + ']'
return '%s%s%s' % (self.level(), cremona_letter_code(self.factor_number()), group)

Expand Down
10 changes: 5 additions & 5 deletions src/sage/modular/abvar/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

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.arithgroup.all import CongruenceSubgroupBase, Gamma0
from sage.modular.modsym.space import ModularSymbolsSpace
from .abvar_newform import ModularAbelianVariety_newform
import sage.modular.modform.element
from . import abvar
Expand Down Expand Up @@ -172,7 +172,7 @@ def AbelianVariety(X):
"""
if isinstance(X, (int, Integer)):
X = Gamma0(X)
if is_CongruenceSubgroup(X):
if isinstance(X, CongruenceSubgroupBase):
X = X.modular_symbols().cuspidal_submodule()
elif isinstance(X, str):
from sage.modular.modform.constructor import Newform
Expand All @@ -181,10 +181,10 @@ 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):
if isinstance(X, (tuple,list)) and all(isinstance(G, CongruenceSubgroupBase) for G in X):
return abvar.ModularAbelianVariety(X)

raise TypeError("X must be an integer, string, newform, modsym space, congruence subgroup or tuple of congruence subgroups")
4 changes: 2 additions & 2 deletions src/sage/modular/abvar/cuspidal_subgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#*****************************************************************************

from sage.matrix.constructor import matrix
from sage.modular.arithgroup.all import is_Gamma0
from sage.modular.arithgroup.all import Gamma0_class
from sage.modular.cusps import Cusp
from sage.rings.infinity import infinity
from sage.rings.integer_ring import ZZ
Expand Down Expand Up @@ -172,7 +172,7 @@ def _compute_lattice(self, rational_only=False, rational_subgroup=False):

if rational_only:
# subgroup generated by differences of rational cusps
if not is_Gamma0(A.group()):
if not isinstance(A.group(), Gamma0_class):
raise NotImplementedError('computation of rational cusps only implemented in Gamma0 case.')
if not N.is_squarefree():
data = [n for n in N.coprime_integers(N) if n >= 2]
Expand Down
12 changes: 6 additions & 6 deletions src/sage/modular/abvar/finite_subgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def __init__(self, abvar, field_of_definition=QQ):
from sage.categories.fields import Fields
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets
from sage.categories.modules import Modules
from .abvar import is_ModularAbelianVariety
from .abvar import ModularAbelianVariety_abstract
if field_of_definition not in Fields():
raise TypeError("field_of_definition must be a field")
if not is_ModularAbelianVariety(abvar):
if not isinstance(abvar, ModularAbelianVariety_abstract):
raise TypeError("abvar must be a modular abelian variety")
category = Category.join((Modules(ZZ), FiniteEnumeratedSets()))
Module.__init__(self, ZZ, category=category)
Expand Down Expand Up @@ -410,9 +410,9 @@ def intersection(self, other):
Finite subgroup with invariants [3, 3] over QQ of
Abelian subvariety of dimension 2 of J0(33)
"""
from .abvar import is_ModularAbelianVariety
from .abvar import ModularAbelianVariety_abstract
A = self.abelian_variety()
if is_ModularAbelianVariety(other):
if isinstance(other, ModularAbelianVariety_abstract):
amb = other
B = other
M = B.lattice().scale(Integer(1)/self.exponent())
Expand Down Expand Up @@ -870,10 +870,10 @@ def __init__(self, abvar, lattice, field_of_definition=None, check=True):
if field_of_definition is None:
from sage.rings.qqbar import QQbar as field_of_definition
if check:
from .abvar import is_ModularAbelianVariety
from .abvar import ModularAbelianVariety_abstract
if not isinstance(lattice, FreeModule_generic) or lattice.base_ring() != ZZ:
raise TypeError("lattice must be a free module over ZZ")
if not is_ModularAbelianVariety(abvar):
if not isinstance(abvar, ModularAbelianVariety_abstract):
raise TypeError("abvar must be a modular abelian variety")
if not abvar.lattice().is_submodule(lattice):
lattice += abvar.lattice()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/modular/abvar/homspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ def __init__(self, domain, codomain, cat):
sage: H.homset_category()
Category of modular abelian varieties over Rational Field
"""
from .abvar import is_ModularAbelianVariety
if not is_ModularAbelianVariety(domain):
from .abvar import ModularAbelianVariety_abstract
if not isinstance(domain, ModularAbelianVariety_abstract):
raise TypeError("domain must be a modular abelian variety")
if not is_ModularAbelianVariety(codomain):
if not isinstance(codomain, ModularAbelianVariety_abstract):
raise TypeError("codomain must be a modular abelian variety")
self._gens = None
HomsetWithBase.__init__(self, domain, codomain, category=cat)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/modular/abvar/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ def __call__(self, X):
sage: t2(C)
Finite subgroup with invariants [2, 2] over QQ of Simple abelian subvariety 33a(1,33) of dimension 1 of J0(33)
"""
from .abvar import is_ModularAbelianVariety
from .abvar import ModularAbelianVariety_abstract
from .finite_subgroup import FiniteSubgroup
if isinstance(X, TorsionPoint):
return self._image_of_element(X)
elif is_ModularAbelianVariety(X):
elif isinstance(X, ModularAbelianVariety_abstract):
return self._image_of_abvar(X)
elif isinstance(X, FiniteSubgroup):
return self._image_of_finite_subgroup(X)
Expand Down Expand Up @@ -743,11 +743,11 @@ def __init__(self, abvar, n, side="left"):
sage: T2.parent()
Endomorphism ring of Abelian variety J0(37) of dimension 2
"""
from .abvar import is_ModularAbelianVariety
from .abvar import ModularAbelianVariety_abstract
n = ZZ(n)
if n <= 0:
raise ValueError("n must be positive")
if not is_ModularAbelianVariety(abvar):
if not isinstance(abvar, ModularAbelianVariety_abstract):
raise TypeError("abvar must be a modular abelian variety")
self.__abvar = abvar
self.__n = n
Expand Down
Loading