Skip to content

Commit d1036f5

Browse files
author
Release Manager
committed
gh-38103: Deprecate `is_Map`, `is_...Morphism` <!-- ^ 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: #38103 Reported by: Matthias Köppe Reviewer(s): gmou3, grhkm21, Matthias Köppe
2 parents 7cfff49 + 3938568 commit d1036f5

15 files changed

+57
-22
lines changed

src/sage/categories/functor.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ cdef class Functor(SageObject):
386386
that is not in Category of rings.
387387
388388
"""
389-
from sage.categories.morphism import is_Morphism
390-
if is_Morphism(x):
389+
from sage.categories.morphism import Morphism
390+
if isinstance(x, Morphism):
391391
return self._apply_functor_to_morphism(x)
392392
y = self._apply_functor(self._coerce_into_domain(x))
393393
if not ((y in self.__codomain) or (y in self.__codomain.Homsets())):

src/sage/categories/map.pyx

+5
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,13 @@ def is_Map(x):
6363
sage: f = R.hom([x+y, x-y], R)
6464
sage: from sage.categories.map import is_Map
6565
sage: is_Map(f)
66+
doctest:warning...
67+
DeprecationWarning: The function is_Map is deprecated; use 'isinstance(..., Map)' instead.
68+
See https://github.com/sagemath/sage/issues/38103 for details.
6669
True
6770
"""
71+
from sage.misc.superseded import deprecation_cython
72+
deprecation_cython(38103, "The function is_Map is deprecated; use 'isinstance(..., Map)' instead.")
6873
return isinstance(x, Map)
6974

7075

src/sage/categories/morphism.pyx

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ from sage.structure.parent cimport Parent
4848

4949

5050
def is_Morphism(x):
51+
from sage.misc.superseded import deprecation_cython
52+
deprecation_cython(38103, "The function is_Morphism is deprecated; use 'isinstance(..., Morphism)' instead.")
5153
return isinstance(x, Morphism)
5254

5355

src/sage/groups/abelian_gps/abelian_group_morphism.py

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626

2727
def is_AbelianGroupMorphism(f):
28+
from sage.misc.superseded import deprecation
29+
deprecation(38103,
30+
"The function is_AbelianGroupMorphism is deprecated; "
31+
"use 'isinstance(..., AbelianGroupMorphism)' instead.")
2832
return isinstance(f, AbelianGroupMorphism)
2933

3034

src/sage/groups/perm_gps/permgroup_morphism.py

+8
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,14 @@ def is_PermutationGroupMorphism(f) -> bool:
321321
sage: H = DihedralGroup(4)
322322
sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens()))
323323
sage: is_PermutationGroupMorphism(phi)
324+
doctest:warning...
325+
DeprecationWarning: The function is_PermutationGroupMorphism is deprecated;
326+
use 'isinstance(..., PermutationGroupMorphism)' instead.
327+
See https://github.com/sagemath/sage/issues/38103 for details.
324328
True
325329
"""
330+
from sage.misc.superseded import deprecation
331+
deprecation(38103,
332+
"The function is_PermutationGroupMorphism is deprecated; "
333+
"use 'isinstance(..., PermutationGroupMorphism)' instead.")
326334
return isinstance(f, PermutationGroupMorphism)

src/sage/homology/chain_complex_morphism.py

+8
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,16 @@ def is_ChainComplexMorphism(x):
7878
From: Chain complex with at most 7 nonzero terms over Integer Ring
7979
To: Chain complex with at most 7 nonzero terms over Integer Ring
8080
sage: is_ChainComplexMorphism(x)
81+
doctest:warning...
82+
DeprecationWarning: The function is_ChainComplexMorphism is deprecated;
83+
use 'isinstance(..., ChainComplexMorphism)' instead.
84+
See https://github.com/sagemath/sage/issues/38103 for details.
8185
True
8286
"""
87+
from sage.misc.superseded import deprecation
88+
deprecation(38103,
89+
"The function is_ChainComplexMorphism is deprecated; "
90+
"use 'isinstance(..., ChainComplexMorphism)' instead.")
8391
return isinstance(x, ChainComplexMorphism)
8492

8593

src/sage/modules/fg_pid/fgp_morphism.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# https://www.gnu.org/licenses/
2121
# *************************************************************************
2222

23-
from sage.categories.morphism import Morphism, is_Morphism
23+
from sage.categories.morphism import Morphism
2424
from .fgp_module import DEBUG
2525
from sage.structure.richcmp import richcmp, op_NE
2626
from sage.misc.cachefunc import cached_method
@@ -101,7 +101,7 @@ def __init__(self, parent, phi, check=True):
101101
# input: phi is a morphism from MO = M.optimized().V() to N.V()
102102
# that sends MO.W() to N.W()
103103
if check:
104-
if not is_Morphism(phi) and M == N:
104+
if not isinstance(phi, Morphism) and M == N:
105105
A = M.optimized()[0].V()
106106
B = N.V()
107107
s = M.base_ring()(phi) * B.coordinate_module(A).basis_matrix()

src/sage/quivers/morphism.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ def __init__(self, domain, codomain, data={}):
267267
start_index += dim
268268

269269
# Get the coordinates of the vector
270-
from sage.categories.map import is_Map
270+
from sage.categories.map import Map
271271
vector = []
272272
for v in self._quiver:
273273
if v in maps_dict:
274-
if is_Map(maps_dict[v]):
274+
if isinstance(maps_dict[v], Map):
275275
try:
276276
m = maps_dict[v].matrix()
277277
except (AttributeError, ValueError):

src/sage/quivers/representation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def create_key(self, k, P, *args, **kwds):
710710
# Note that the first space is assigned to key[3] and the first
711711
# vertex is 1 so the space assigned to vertex v is key[2 + v]
712712
from sage.matrix.constructor import Matrix
713-
from sage.categories.morphism import is_Morphism
713+
from sage.categories.morphism import Morphism
714714
for x in P._sorted_edges:
715715
if x in maps:
716716
e = maps[x]
@@ -724,7 +724,7 @@ def create_key(self, k, P, *args, **kwds):
724724
# If a morphism is specified take it's matrix. Create one if
725725
# needed. Otherwise assume the Matrix function can convert the
726726
# object to a Matrix.
727-
if is_Morphism(e):
727+
if isinstance(e, Morphism):
728728
if hasattr(e, 'matrix'):
729729
key.append(e.matrix())
730730
else:

src/sage/rings/finite_rings/finite_field_base.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ cdef class FiniteField(Field):
12601260
return self.__vector_space
12611261

12621262
from sage.modules.free_module import VectorSpace
1263-
from sage.categories.morphism import is_Morphism
1263+
from sage.categories.morphism import Morphism
12641264

12651265
if base is None:
12661266
base = self.prime_subfield()
@@ -1269,7 +1269,7 @@ cdef class FiniteField(Field):
12691269
self.__vector_space = VectorSpace(base, s)
12701270
V = self.__vector_space
12711271
inclusion_map = None
1272-
elif is_Morphism(base):
1272+
elif isinstance(base, Morphism):
12731273
inclusion_map = base
12741274
base = inclusion_map.domain()
12751275
s = self.degree() // base.degree()

src/sage/rings/ideal.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ def apply_morphism(self, phi):
540540
sage: taus[1](B) # needs sage.rings.number_fields
541541
Fractional ideal (2, a + 1)
542542
"""
543-
from sage.categories.morphism import is_Morphism
544-
if not is_Morphism(phi):
543+
from sage.categories.morphism import Morphism
544+
if not isinstance(phi, Morphism):
545545
raise TypeError("phi must be a morphism")
546546
# delegate: morphisms know how to apply themselves to ideals
547547
return phi(self)

src/sage/rings/number_field/number_field.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1438,18 +1438,18 @@ def _convert_map_from_(self, other):
14381438
i - a
14391439
14401440
"""
1441-
from sage.categories.map import is_Map
1441+
from sage.categories.map import Map
14421442
if self._structure is not None:
14431443
structure = self.structure()
14441444
if len(structure) >= 2:
14451445
to_self = structure[1]
1446-
if is_Map(to_self) and to_self.domain() is other:
1446+
if isinstance(to_self, Map) and to_self.domain() is other:
14471447
return to_self
14481448
if isinstance(other, NumberField_generic) and other._structure is not None:
14491449
structure = other.structure()
14501450
if len(structure) >= 1:
14511451
from_other = structure[0]
1452-
if is_Map(from_other) and from_other.codomain() is self:
1452+
if isinstance(from_other, Map) and from_other.codomain() is self:
14531453
return from_other
14541454

14551455
@cached_method
@@ -9956,8 +9956,8 @@ def relativize(self, alpha, names, structure=None):
99569956
from sage.matrix.constructor import matrix
99579957
from sage.modules.free_module_element import vector
99589958

9959-
from sage.categories.map import is_Map
9960-
if is_Map(alpha):
9959+
from sage.categories.map import Map
9960+
if isinstance(alpha, Map):
99619961
# alpha better be a morphism with codomain self
99629962
if alpha.codomain() != self:
99639963
raise ValueError("Co-domain of morphism must be self")

src/sage/rings/number_field/number_field_rel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
import sage.libs.ntl.all as ntl
7979

80-
from sage.categories.map import is_Map
80+
from sage.categories.map import Map
8181
from sage.structure.sequence import Sequence
8282

8383
import sage.structure.parent_gens
@@ -2678,7 +2678,7 @@ def relativize(self, alpha, names):
26782678
K = self.absolute_field('a')
26792679
from_K, to_K = K.structure()
26802680

2681-
if is_Map(alpha):
2681+
if isinstance(alpha, Map):
26822682
# alpha is an embedding of a subfield into self; compose to get an
26832683
# embedding of a subfield into the absolute field
26842684
beta = to_K * alpha

src/sage/sets/image_set.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from typing import Iterator
2020

21-
from sage.categories.map import is_Map
21+
from sage.categories.map import Map
2222
from sage.categories.poor_man_map import PoorManMap
2323
from sage.categories.sets_cat import Sets
2424
from sage.categories.enumerated_sets import EnumeratedSets
@@ -86,7 +86,7 @@ def __init__(self, map, domain_subset, *, category=None, is_injective=None, inve
8686
from sage.sets.set import Set
8787
domain_subset = Set(domain_subset)
8888

89-
if not is_Map(map) and not isinstance(map, PoorManMap):
89+
if not isinstance(map, Map) and not isinstance(map, PoorManMap):
9090
map_name = f"The map {map}"
9191
if isinstance(map, Expression) and map.is_callable():
9292
domain = map.parent().base()
@@ -100,7 +100,7 @@ def map(arg):
100100
domain = domain_subset
101101
map = PoorManMap(map, domain, name=map_name)
102102

103-
if is_Map(map):
103+
if isinstance(map, Map):
104104
map_category = map.category_for()
105105
if is_injective is None:
106106
try:

src/sage/topology/simplicial_complex_morphism.py

+8
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,17 @@ def is_SimplicialComplexMorphism(x):
126126
sage: f = {0:0,1:1,3:3,4:4}
127127
sage: x = H(f)
128128
sage: is_SimplicialComplexMorphism(x)
129+
doctest:warning...
130+
DeprecationWarning: The function is_SimplicialComplexMorphism is deprecated;
131+
use 'isinstance(..., SimplicialComplexMorphism)' instead.
132+
See https://github.com/sagemath/sage/issues/38103 for details.
129133
True
130134
131135
"""
136+
from sage.misc.superseded import deprecation
137+
deprecation(38103,
138+
"The function is_SimplicialComplexMorphism is deprecated; "
139+
"use 'isinstance(..., SimplicialComplexMorphism)' instead.")
132140
return isinstance(x, SimplicialComplexMorphism)
133141

134142

0 commit comments

Comments
 (0)