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

fixing some mypy suggestions in algebras and abvar #38647

Merged
merged 1 commit into from
Sep 22, 2024
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
7 changes: 4 additions & 3 deletions src/sage/algebras/cluster_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
# ****************************************************************************

from copy import copy
from typing import Any

from sage.arith.misc import binomial
from sage.categories.homset import Hom
Expand Down Expand Up @@ -562,7 +563,7 @@ def homogeneous_components(self) -> dict:
"""
deg_matrix = block_matrix([[identity_matrix(self.parent().rank()),
-self.parent().b_matrix()]])
components = {}
components: dict[tuple, Any] = {}
x = self.lift()
monomials = x.monomials()
for m in monomials:
Expand Down Expand Up @@ -1432,11 +1433,11 @@ def _repr_(self) -> str:
and coefficients y0, y1 over Integer Ring
"""
var_names = self.initial_cluster_variable_names()
var_names = (" " if len(var_names) == 1 else "s ") + ", ".join(var_names)
var_names_str = (" " if len(var_names) == 1 else "s ") + ", ".join(var_names)
coeff_names = self.coefficient_names()
coeff_prefix = " and" + (" " if len(coeff_names) > 0 else " no ") + "coefficient"
coeff = coeff_prefix + (" " if len(coeff_names) == 1 else "s ") + ", ".join(coeff_names) + (" " if len(coeff_names) > 0 else "")
return "A Cluster Algebra with cluster variable" + var_names + coeff + "over " + repr(self.scalars())
return "A Cluster Algebra with cluster variable" + var_names_str + coeff + "over " + repr(self.scalars())

def _an_element_(self):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/iwahori_hecke_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ def __init__(self, algebra, prefix=None):

# This **must** match the name of the class in order for
# specialize_to() to work
_basis_name = None
_basis_name = 'B'

def _repr_term(self, t):
r"""
Expand Down
17 changes: 3 additions & 14 deletions src/sage/algebras/lie_conformal_algebras/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
- Reimundo Heluani (2020-06-15): Initial implementation.
"""

#******************************************************************************
# *****************************************************************************
# Copyright (C) 2020 Reimundo Heluani <heluani@potuz.net>
#
# 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/
#*****************************************************************************
# https://www.gnu.org/licenses/
# ****************************************************************************

from .abelian_lie_conformal_algebra import AbelianLieConformalAlgebra as Abelian
from .affine_lie_conformal_algebra import AffineLieConformalAlgebra as Affine
Expand All @@ -40,14 +40,3 @@
from .neveu_schwarz_lie_conformal_algebra import NeveuSchwarzLieConformalAlgebra as NeveuSchwarz
from .virasoro_lie_conformal_algebra import VirasoroLieConformalAlgebra as Virasoro
from .weyl_lie_conformal_algebra import WeylLieConformalAlgebra as Weyl

assert Abelian
assert Affine
assert BosonicGhosts
assert FermionicGhosts
assert FreeBosons
assert FreeFermions
assert N2
assert NeveuSchwarz
assert Virasoro
assert Weyl
22 changes: 6 additions & 16 deletions src/sage/modular/abvar/abvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from sage.categories.modular_abelian_varieties import ModularAbelianVarieties
from sage.matrix.constructor import matrix
from sage.matrix.special import block_diagonal_matrix, identity_matrix
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_import import lazy_import
from sage.misc.misc_c import prod
from sage.modular.arithgroup.congroup_gamma0 import Gamma0_class
Expand Down Expand Up @@ -69,8 +70,7 @@
['cremona_letter_code', 'CremonaDatabase'])


from . import homspace
from . import lseries
from sage.modular.abvar import homspace, lseries
from .morphism import HeckeOperator, Morphism, DegeneracyMap
from .torsion_subgroup import RationalTorsionSubgroup, QQbarTorsionSubgroup
from .finite_subgroup import (FiniteSubgroup_lattice, FiniteSubgroup,
Expand Down Expand Up @@ -1728,6 +1728,7 @@ def ambient_morphism(self):
self.__ambient_morphism = phi
return phi

@cached_method
def is_ambient(self) -> bool:
"""
Return ``True`` if ``self`` equals the ambient product Jacobian.
Expand All @@ -1746,13 +1747,8 @@ def is_ambient(self) -> bool:
sage: (A+B+C).is_ambient()
True
"""
try:
return self.__is_ambient
except AttributeError:
pass
L = self.lattice()
self.__is_ambient = (self.lattice() == ZZ**L.degree())
return self.__is_ambient
return self.lattice() == ZZ**L.degree()

def dimension(self):
"""
Expand Down Expand Up @@ -1890,6 +1886,7 @@ def sturm_bound(self):
self.__sturm_bound = B
return B

@cached_method
def is_hecke_stable(self) -> bool:
"""
Return ``True`` if ``self`` is stable under the Hecke operators of its
Expand All @@ -1908,11 +1905,6 @@ def is_hecke_stable(self) -> bool:
sage: (J0(33)[0] + J0(33)[1]).is_hecke_stable()
True
"""
try:
return self._is_hecke_stable
except AttributeError:
pass

# b = self.modular_symbols().sturm_bound()
b = max([m.sturm_bound()
for m in self._ambient_modular_symbols_spaces()])
Expand All @@ -1924,10 +1916,8 @@ def is_hecke_stable(self) -> bool:
Tn_matrix = J.hecke_operator(n).matrix()
for v in B:
if v * Tn_matrix not in L:
self._is_hecke_stable = False
return False

self._is_hecke_stable = True
return True

def is_subvariety(self, other) -> bool:
Expand Down Expand Up @@ -2467,7 +2457,7 @@ def homology(self, base_ring=ZZ):
sage: J0(389).homology(ZZ)
Integral Homology of Abelian variety J0(389) of dimension 32
"""
from . import homology
from sage.modular.abvar import homology
try:
return self._homology[base_ring]
except AttributeError:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/abvar/abvar_ambient_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sage.modular.modsym.modsym import ModularSymbols
from sage.modular.modform.constructor import Newforms
from sage.modular.arithgroup.all import Gamma0_class, Gamma1_class
from . import morphism
from sage.modular.abvar import morphism


_cache = {}
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/abvar/abvar_newform.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from sage.modular.arithgroup.all import Gamma0_class, Gamma1_class, GammaH_class

from .abvar import ModularAbelianVariety_modsym_abstract
from . import homspace
from sage.modular.abvar import homspace
lazy_import('sage.databases.cremona', 'cremona_letter_code')


Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/abvar/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sage.modular.modsym.space import ModularSymbolsSpace
from .abvar_newform import ModularAbelianVariety_newform
import sage.modular.modform.element
from . import abvar
from sage.modular.abvar import abvar

_cache = {}

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/abvar/homspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
from sage.misc.lazy_attribute import lazy_attribute


from . import morphism
from sage.modular.abvar import morphism

from sage.rings.infinity import Infinity

Expand Down
Loading