Skip to content

Commit 2627932

Browse files
author
Release Manager
committed
gh-37898: Deprecate `is_AbelianGroup`, `is_DualAbelianGroup`, `is_MatrixGroup` <!-- ^ 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 #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 #12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] 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, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37898 Reported by: Matthias Köppe Reviewer(s): Martin Rubey, Matthias Köppe, Vincent Delecroix
2 parents 8dfb15d + ec586f2 commit 2627932

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

src/sage/groups/abelian_gps/abelian_group.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,16 @@ def is_AbelianGroup(x):
458458
sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F
459459
Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9
460460
sage: is_AbelianGroup(F)
461+
doctest:warning...
462+
DeprecationWarning: the function is_AbelianGroup is deprecated;
463+
use 'isinstance(..., AbelianGroup_class)' instead
464+
See https://github.com/sagemath/sage/issues/37898 for details.
461465
True
462466
sage: is_AbelianGroup(AbelianGroup(7, [3]*7))
463467
True
464468
"""
469+
from sage.misc.superseded import deprecation
470+
deprecation(37898, "the function is_AbelianGroup is deprecated; use 'isinstance(..., AbelianGroup_class)' instead")
465471
return isinstance(x, AbelianGroup_class)
466472

467473

@@ -569,7 +575,7 @@ def is_isomorphic(left, right):
569575
sage: G1.is_isomorphic(G2)
570576
True
571577
"""
572-
if not is_AbelianGroup(right):
578+
if not isinstance(right, AbelianGroup_class):
573579
return False
574580
return left.elementary_divisors() == right.elementary_divisors()
575581

src/sage/groups/abelian_gps/dual_abelian_group.py

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def is_DualAbelianGroup(x):
8686
sage: F = AbelianGroup(5,[3,5,7,8,9], names=list("abcde"))
8787
sage: Fd = F.dual_group()
8888
sage: is_DualAbelianGroup(Fd)
89+
doctest:warning...
90+
DeprecationWarning: the function is_DualAbelianGroup is deprecated;
91+
use 'isinstance(..., DualAbelianGroup_class)' instead
92+
See https://github.com/sagemath/sage/issues/37898 for details.
8993
True
9094
sage: F = AbelianGroup(3,[1,2,3], names='a')
9195
sage: Fd = F.dual_group()
@@ -94,6 +98,8 @@ def is_DualAbelianGroup(x):
9498
sage: F.gens()
9599
(1, a1, a2)
96100
"""
101+
from sage.misc.superseded import deprecation
102+
deprecation(37898, "the function is_DualAbelianGroup is deprecated; use 'isinstance(..., DualAbelianGroup_class)' instead")
97103
return isinstance(x, DualAbelianGroup_class)
98104

99105

src/sage/groups/matrix_gps/matrix_group.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def is_MatrixGroup(x):
7878
7979
sage: from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
8080
sage: is_MatrixGroup(MatrixSpace(QQ, 3))
81+
doctest:warning...
82+
DeprecationWarning: the function is_MatrixGroup is deprecated;
83+
use 'isinstance(..., MatrixGroup_base)' instead
84+
See https://github.com/sagemath/sage/issues/37898 for details.
8185
False
8286
sage: is_MatrixGroup(Mat(QQ, 3))
8387
False
@@ -86,6 +90,8 @@ def is_MatrixGroup(x):
8690
sage: is_MatrixGroup(MatrixGroup([matrix(2, [1,1,0,1])]))
8791
True
8892
"""
93+
from sage.misc.superseded import deprecation
94+
deprecation(37898, "the function is_MatrixGroup is deprecated; use 'isinstance(..., MatrixGroup_base)' instead")
8995
return isinstance(x, MatrixGroup_base)
9096

9197
###################################################################
@@ -499,7 +505,7 @@ def __richcmp__(self, other, op):
499505
sage: G != H
500506
False
501507
"""
502-
if not is_MatrixGroup(other):
508+
if not isinstance(other, MatrixGroup_base):
503509
return NotImplemented
504510

505511
if self is other:

src/sage/matrix/matrix_space.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
from sage.features import PythonModule
5959
lazy_import('sage.matrix.matrix_gfpn_dense', ['Matrix_gfpn_dense'],
6060
feature=PythonModule('sage.matrix.matrix_gfpn_dense', spkg='meataxe'))
61+
lazy_import('sage.groups.matrix_gps.matrix_group', ['MatrixGroup_base'])
6162

6263
_Rings = Rings()
6364
_Fields = Fields()
@@ -1451,14 +1452,8 @@ def _coerce_map_from_(self, S):
14511452
pass
14521453
else:
14531454
MS = meth_matrix_space()
1454-
1455-
try:
1456-
from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
1457-
except ImportError:
1458-
pass
1459-
else:
1460-
if is_MatrixGroup(S):
1461-
return self.has_coerce_map_from(MS)
1455+
if isinstance(S, MatrixGroup_base):
1456+
return self.has_coerce_map_from(MS)
14621457

14631458
try:
14641459
from sage.modular.arithgroup.arithgroup_generic import is_ArithmeticSubgroup

src/sage/modular/arithgroup/congroup_generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def CongruenceSubgroup_constructor(*args):
8989
TypeError: Ring of definition must be Z / NZ for some N
9090
"""
9191
from sage.groups.matrix_gps.finitely_generated import MatrixGroup
92-
from sage.groups.matrix_gps.matrix_group import is_MatrixGroup
92+
from sage.groups.matrix_gps.matrix_group import MatrixGroup_base
9393

94-
if is_MatrixGroup(args[0]):
94+
if isinstance(args[0], MatrixGroup_base):
9595
G = args[0]
9696

9797
elif isinstance(args[0], list):

0 commit comments

Comments
 (0)