Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sagemathgh-37895: `sage.modular.hecke`: Deprecate `is_Hecke...` functions
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Replacing the old-style `is_...` functions by just using `isinstance`.

Also some docstring/doctest cosmetics.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37895
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee, Travis Scrimshaw
  • Loading branch information
Release Manager committed May 23, 2024
2 parents c3719ba + 554bcc2 commit 4e30af0
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 82 deletions.
16 changes: 11 additions & 5 deletions src/sage/modular/hecke/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ def is_HeckeAlgebra(x) -> bool:
sage: from sage.modular.hecke.algebra import is_HeckeAlgebra
sage: is_HeckeAlgebra(CuspForms(1, 12).anemic_hecke_algebra())
doctest:warning...
DeprecationWarning: the function is_HeckeAlgebra is deprecated;
use 'isinstance(..., HeckeAlgebra_base)' instead
See https://github.com/sagemath/sage/issues/37895 for details.
True
sage: is_HeckeAlgebra(ZZ)
False
"""
from sage.misc.superseded import deprecation
deprecation(37895, "the function is_HeckeAlgebra is deprecated; use 'isinstance(..., HeckeAlgebra_base)' instead")
return isinstance(x, HeckeAlgebra_base)


Expand Down Expand Up @@ -177,8 +183,8 @@ def __init__(self, M) -> None:
"""
if isinstance(M, tuple):
M = M[0]
from . import module
if not module.is_HeckeModule(M):
from .module import HeckeModule_generic
if not isinstance(M, HeckeModule_generic):
msg = f"M (={M}) must be a HeckeModule"
raise TypeError(msg)
self.__M = M
Expand Down Expand Up @@ -246,7 +252,7 @@ def _element_constructor_(self, x, check=True):
TypeError: Don't know how to construct an element of Anemic Hecke algebra acting on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field from Hecke operator T_11 on Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field
"""
from .hecke_operator import HeckeAlgebraElement_matrix, HeckeOperator, is_HeckeOperator, is_HeckeAlgebraElement
from .hecke_operator import HeckeAlgebraElement_matrix, HeckeOperator, HeckeAlgebraElement

if not isinstance(x, Element):
x = self.base_ring()(x)
Expand All @@ -259,13 +265,13 @@ def _element_constructor_(self, x, check=True):
if parent is self:
return x

if is_HeckeOperator(x):
if isinstance(x, HeckeOperator):
if x.parent() == self \
or (not self.is_anemic() and x.parent() == self.anemic_subalgebra()) \
or (self.is_anemic() and x.parent().anemic_subalgebra() == self and gcd(x.index(), self.level()) == 1):
return HeckeOperator(self, x.index())

if is_HeckeAlgebraElement(x):
if isinstance(x, HeckeAlgebraElement):
if x.parent() == self or (not self.is_anemic() and x.parent() == self.anemic_subalgebra()):
if x.parent().module().basis_matrix() == self.module().basis_matrix():
return HeckeAlgebraElement_matrix(self, x.matrix())
Expand Down
Loading

0 comments on commit 4e30af0

Please sign in to comment.