diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py index 8a0c5167b16..07ca7c7444e 100644 --- a/src/sage/groups/abelian_gps/abelian_group.py +++ b/src/sage/groups/abelian_gps/abelian_group.py @@ -458,10 +458,16 @@ def is_AbelianGroup(x): sage: F = AbelianGroup(5,[5,5,7,8,9], names=list("abcde")); F Multiplicative Abelian group isomorphic to C5 x C5 x C7 x C8 x C9 sage: is_AbelianGroup(F) + doctest:warning... + DeprecationWarning: the function is_AbelianGroup is deprecated; + use 'isinstance(..., AbelianGroup_class)' instead + See https://github.com/sagemath/sage/issues/37898 for details. True sage: is_AbelianGroup(AbelianGroup(7, [3]*7)) True """ + from sage.misc.superseded import deprecation + deprecation(37898, "the function is_AbelianGroup is deprecated; use 'isinstance(..., AbelianGroup_class)' instead") return isinstance(x, AbelianGroup_class) @@ -569,7 +575,7 @@ def is_isomorphic(left, right): sage: G1.is_isomorphic(G2) True """ - if not is_AbelianGroup(right): + if not isinstance(right, AbelianGroup_class): return False return left.elementary_divisors() == right.elementary_divisors() diff --git a/src/sage/groups/abelian_gps/dual_abelian_group.py b/src/sage/groups/abelian_gps/dual_abelian_group.py index 86966cf74d6..24c910d96d9 100644 --- a/src/sage/groups/abelian_gps/dual_abelian_group.py +++ b/src/sage/groups/abelian_gps/dual_abelian_group.py @@ -86,6 +86,10 @@ def is_DualAbelianGroup(x): sage: F = AbelianGroup(5,[3,5,7,8,9], names=list("abcde")) sage: Fd = F.dual_group() sage: is_DualAbelianGroup(Fd) + doctest:warning... + DeprecationWarning: the function is_DualAbelianGroup is deprecated; + use 'isinstance(..., DualAbelianGroup_class)' instead + See https://github.com/sagemath/sage/issues/37898 for details. True sage: F = AbelianGroup(3,[1,2,3], names='a') sage: Fd = F.dual_group() @@ -94,6 +98,8 @@ def is_DualAbelianGroup(x): sage: F.gens() (1, a1, a2) """ + from sage.misc.superseded import deprecation + deprecation(37898, "the function is_DualAbelianGroup is deprecated; use 'isinstance(..., DualAbelianGroup_class)' instead") return isinstance(x, DualAbelianGroup_class) diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py index 709a88a6d8e..ef05b55c190 100644 --- a/src/sage/groups/matrix_gps/matrix_group.py +++ b/src/sage/groups/matrix_gps/matrix_group.py @@ -78,6 +78,10 @@ def is_MatrixGroup(x): sage: from sage.groups.matrix_gps.matrix_group import is_MatrixGroup sage: is_MatrixGroup(MatrixSpace(QQ, 3)) + doctest:warning... + DeprecationWarning: the function is_MatrixGroup is deprecated; + use 'isinstance(..., MatrixGroup_base)' instead + See https://github.com/sagemath/sage/issues/37898 for details. False sage: is_MatrixGroup(Mat(QQ, 3)) False @@ -86,6 +90,8 @@ def is_MatrixGroup(x): sage: is_MatrixGroup(MatrixGroup([matrix(2, [1,1,0,1])])) True """ + from sage.misc.superseded import deprecation + deprecation(37898, "the function is_MatrixGroup is deprecated; use 'isinstance(..., MatrixGroup_base)' instead") return isinstance(x, MatrixGroup_base) ################################################################### @@ -499,7 +505,7 @@ def __richcmp__(self, other, op): sage: G != H False """ - if not is_MatrixGroup(other): + if not isinstance(other, MatrixGroup_base): return NotImplemented if self is other: diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 6683003b6f2..121d1eab053 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -58,6 +58,7 @@ from sage.features import PythonModule lazy_import('sage.matrix.matrix_gfpn_dense', ['Matrix_gfpn_dense'], feature=PythonModule('sage.matrix.matrix_gfpn_dense', spkg='meataxe')) +lazy_import('sage.groups.matrix_gps.matrix_group', ['MatrixGroup_base']) _Rings = Rings() _Fields = Fields() @@ -1392,14 +1393,8 @@ def _coerce_map_from_(self, S): pass else: MS = meth_matrix_space() - - try: - from sage.groups.matrix_gps.matrix_group import is_MatrixGroup - except ImportError: - pass - else: - if is_MatrixGroup(S): - return self.has_coerce_map_from(MS) + if isinstance(S, MatrixGroup_base): + return self.has_coerce_map_from(MS) try: from sage.modular.arithgroup.arithgroup_generic import is_ArithmeticSubgroup diff --git a/src/sage/modular/arithgroup/congroup_generic.py b/src/sage/modular/arithgroup/congroup_generic.py index 3fd60c06165..871275fdced 100644 --- a/src/sage/modular/arithgroup/congroup_generic.py +++ b/src/sage/modular/arithgroup/congroup_generic.py @@ -89,9 +89,9 @@ def CongruenceSubgroup_constructor(*args): TypeError: Ring of definition must be Z / NZ for some N """ from sage.groups.matrix_gps.finitely_generated import MatrixGroup - from sage.groups.matrix_gps.matrix_group import is_MatrixGroup + from sage.groups.matrix_gps.matrix_group import MatrixGroup_base - if is_MatrixGroup(args[0]): + if isinstance(args[0], MatrixGroup_base): G = args[0] elif isinstance(args[0], list):