Skip to content

Commit 19724da

Browse files
author
Release Manager
committed
gh-38184: Deprecate `is_FreeAlgebraQuotientElement`, ... <!-- ^ 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: #38184 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents e57b899 + 9a04dcb commit 19724da

32 files changed

+209
-60
lines changed

src/sage/algebras/free_algebra_quotient_element.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def is_FreeAlgebraQuotientElement(x):
3838
3939
sage: H, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg(QQ)
4040
sage: sage.algebras.free_algebra_quotient_element.is_FreeAlgebraQuotientElement(i)
41+
doctest:warning...
42+
DeprecationWarning: The function is_FreeAlgebraQuotientElement is deprecated;
43+
use 'isinstance(..., FreeAlgebraQuotientElement)' instead.
44+
See https://github.com/sagemath/sage/issues/38184 for details.
4145
True
4246
4347
Of course this is testing the data type::
@@ -47,6 +51,10 @@ def is_FreeAlgebraQuotientElement(x):
4751
sage: sage.algebras.free_algebra_quotient_element.is_FreeAlgebraQuotientElement(H(1))
4852
True
4953
"""
54+
from sage.misc.superseded import deprecation
55+
deprecation(38184,
56+
"The function is_FreeAlgebraQuotientElement is deprecated; "
57+
"use 'isinstance(..., FreeAlgebraQuotientElement)' instead.")
5058
return isinstance(x, FreeAlgebraQuotientElement)
5159

5260

src/sage/categories/functor.pyx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ cdef class Functor(SageObject):
9696
Category of rings
9797
sage: F.codomain()
9898
Category of commutative additive groups
99-
sage: from sage.categories.functor import is_Functor
100-
sage: is_Functor(F)
99+
sage: from sage.categories.functor import Functor
100+
sage: isinstance(F, Functor)
101101
True
102102
sage: I = IdentityFunctor(abgrps)
103103
sage: I
104104
The identity functor on Category of commutative additive groups
105105
sage: I.domain()
106106
Category of commutative additive groups
107-
sage: is_Functor(I)
107+
sage: isinstance(I, Functor)
108108
True
109109
110110
Note that by default, an instance of the class Functor is coercion
@@ -422,12 +422,9 @@ cdef class Functor(SageObject):
422422

423423
def is_Functor(x):
424424
"""
425-
Test whether the argument is a functor
426-
427-
NOTE:
425+
Test whether the argument is a functor.
428426
429-
There is a deprecation warning when using it from top level.
430-
Therefore we import it in our doc test.
427+
This function is deprecated.
431428
432429
EXAMPLES::
433430
@@ -436,6 +433,10 @@ def is_Functor(x):
436433
sage: F1
437434
FractionField
438435
sage: is_Functor(F1)
436+
doctest:warning...
437+
DeprecationWarning: The function is_Functor is deprecated;
438+
use 'isinstance(..., Functor)' instead.
439+
See https://github.com/sagemath/sage/issues/38184 for details.
439440
True
440441
sage: is_Functor(FractionField)
441442
False
@@ -446,6 +447,10 @@ def is_Functor(x):
446447
True
447448
448449
"""
450+
from sage.misc.superseded import deprecation
451+
deprecation(38184,
452+
"The function is_Functor is deprecated; "
453+
"use 'isinstance(..., Functor)' instead.")
449454
return isinstance(x, Functor)
450455

451456

src/sage/groups/abelian_gps/abelian_group_element.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ def is_AbelianGroupElement(x):
5757
5858
sage: from sage.groups.abelian_gps.abelian_group_element import is_AbelianGroupElement
5959
sage: is_AbelianGroupElement(3)
60+
doctest:warning...
61+
DeprecationWarning: The function is_AbelianGroupElement is deprecated;
62+
use 'isinstance(..., AbelianGroupElement)' instead.
63+
See https://github.com/sagemath/sage/issues/38184 for details.
6064
False
6165
sage: F = AbelianGroup(5, [3,4,5,8,7], 'abcde')
6266
sage: is_AbelianGroupElement(F.0)
6367
True
6468
"""
69+
from sage.misc.superseded import deprecation
70+
deprecation(38184,
71+
"The function is_AbelianGroupElement is deprecated; "
72+
"use 'isinstance(..., AbelianGroupElement)' instead.")
6573
return isinstance(x, AbelianGroupElement)
6674

6775

src/sage/groups/abelian_gps/dual_abelian_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def __contains__(self, X):
345345
sage: A*B^2*D^7 in Fd
346346
True
347347
"""
348-
return X.parent() == self and is_DualAbelianGroupElement(X)
348+
return X.parent() == self and isinstance(X, DualAbelianGroupElement)
349349

350350
def order(self):
351351
"""

src/sage/groups/abelian_gps/dual_abelian_group_element.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,18 @@ def is_DualAbelianGroupElement(x) -> bool:
7171
sage: from sage.groups.abelian_gps.dual_abelian_group import is_DualAbelianGroupElement
7272
sage: F = AbelianGroup(5, [5,5,7,8,9], names=list("abcde")).dual_group()
7373
sage: is_DualAbelianGroupElement(F)
74+
doctest:warning...
75+
DeprecationWarning: The function is_DualAbelianGroupElement is deprecated;
76+
use 'isinstance(..., DualAbelianGroupElement)' instead.
77+
See https://github.com/sagemath/sage/issues/38184 for details.
7478
False
7579
sage: is_DualAbelianGroupElement(F.an_element())
7680
True
7781
"""
82+
from sage.misc.superseded import deprecation
83+
deprecation(38184,
84+
"The function is_DualAbelianGroupElement is deprecated; "
85+
"use 'isinstance(..., DualAbelianGroupElement)' instead.")
7886
return isinstance(x, DualAbelianGroupElement)
7987

8088

src/sage/groups/perm_gps/permgroup_element.pyx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,16 @@ def is_PermutationGroupElement(x):
211211
sage: p = PermutationGroupElement([(1,2),(3,4,5)])
212212
sage: from sage.groups.perm_gps.permgroup_element import is_PermutationGroupElement
213213
sage: is_PermutationGroupElement(p)
214+
doctest:warning...
215+
DeprecationWarning: The function is_PermutationGroupElement is deprecated;
216+
use 'isinstance(..., PermutationGroupElement)' instead.
217+
See https://github.com/sagemath/sage/issues/38184 for details.
214218
True
215219
"""
220+
from sage.misc.superseded import deprecation_cython
221+
deprecation_cython(38184,
222+
"The function is_PermutationGroupElement is deprecated; "
223+
"use 'isinstance(..., PermutationGroupElement)' instead.")
216224
return isinstance(x, PermutationGroupElement)
217225

218226

src/sage/homology/chain_complex_homspace.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,17 @@ def is_ChainComplexHomspace(x):
116116
sage: C = T.chain_complex(augmented=True, cochain=True)
117117
sage: G = Hom(C, C)
118118
sage: is_ChainComplexHomspace(G)
119+
doctest:warning...
120+
DeprecationWarning: The function is_ChainComplexHomspace is deprecated;
121+
use 'isinstance(..., ChainComplexHomspace)' instead.
122+
See https://github.com/sagemath/sage/issues/38184 for details.
119123
True
120124
121125
"""
126+
from sage.misc.superseded import deprecation
127+
deprecation(38184,
128+
"The function is_ChainComplexHomspace is deprecated; "
129+
"use 'isinstance(..., ChainComplexHomspace)' instead.")
122130
return isinstance(x, ChainComplexHomspace)
123131

124132

src/sage/matrix/matrix2.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ from sage.arith.numerical_approx cimport digits_to_bits
9999

100100
import sage.modules.free_module
101101
from sage.matrix import berlekamp_massey
102-
from sage.modules.free_module_element import is_FreeModuleElement
102+
from sage.modules.free_module_element import FreeModuleElement
103103
from sage.matrix.matrix_misc import permanental_minor_polynomial
104104

105105
from sage.misc.misc_c import prod
@@ -6153,7 +6153,7 @@ cdef class Matrix(Matrix1):
61536153
"""
61546154
if v == 0:
61556155
return []
6156-
if not is_FreeModuleElement(v):
6156+
if not isinstance(v, FreeModuleElement):
61576157
raise TypeError("v must be a FreeModuleElement")
61586158
VS = v.parent()
61596159
V = VS.span([v])

src/sage/misc/latex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ def png(x, filename, density=150, debug=False,
19341934
....: png(ZZ[x], f.name)
19351935
"""
19361936
import sage.plot.all
1937-
if sage.plot.graphics.is_Graphics(x):
1937+
if isinstance(x, sage.plot.graphics.Graphics):
19381938
x.save(filename)
19391939
return
19401940
# if not graphics: create a string of latex code to write in a file

src/sage/modular/dirichlet.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,18 @@ def is_DirichletCharacter(x) -> bool:
172172
173173
sage: from sage.modular.dirichlet import is_DirichletCharacter
174174
sage: is_DirichletCharacter(trivial_character(3))
175+
doctest:warning...
176+
DeprecationWarning: The function is_DirichletCharacter is deprecated;
177+
use 'isinstance(..., DirichletCharacter)' instead.
178+
See https://github.com/sagemath/sage/issues/38184 for details.
175179
True
176180
sage: is_DirichletCharacter([1])
177181
False
178182
"""
183+
from sage.misc.superseded import deprecation
184+
deprecation(38184,
185+
"The function is_DirichletCharacter is deprecated; "
186+
"use 'isinstance(..., DirichletCharacter)' instead.")
179187
return isinstance(x, DirichletCharacter)
180188

181189

@@ -262,7 +270,7 @@ def __init__(self, parent, x, check=True):
262270
orders = parent.integers_mod().unit_group().gens_orders()
263271
if len(x) != len(orders):
264272
raise ValueError("wrong number of values (= {}) on generators (want {})".format(x, len(orders)))
265-
if free_module_element.is_FreeModuleElement(x):
273+
if isinstance(x, free_module_element.FreeModuleElement):
266274
x = parent._module(x)
267275
if any(u * v for u, v in zip(x, orders)):
268276
raise ValueError("values (= {} modulo {}) must have additive orders dividing {}, respectively"
@@ -276,7 +284,7 @@ def __init__(self, parent, x, check=True):
276284
.format(x, orders))
277285
self.values_on_gens.set_cache(x)
278286
else:
279-
if free_module_element.is_FreeModuleElement(x):
287+
if isinstance(x, free_module_element.FreeModuleElement):
280288
self.element.set_cache(x)
281289
else:
282290
self.values_on_gens.set_cache(x)

0 commit comments

Comments
 (0)