diff --git a/src/sage/categories/functor.pyx b/src/sage/categories/functor.pyx index f548adfc664..08b0d966f2b 100644 --- a/src/sage/categories/functor.pyx +++ b/src/sage/categories/functor.pyx @@ -385,8 +385,8 @@ cdef class Functor(SageObject): that is not in Category of rings. """ - from sage.categories.morphism import is_Morphism - if is_Morphism(x): + from sage.categories.morphism import Morphism + if isinstance(x, Morphism): return self._apply_functor_to_morphism(x) y = self._apply_functor(self._coerce_into_domain(x)) if not ((y in self.__codomain) or (y in self.__codomain.Homsets())): diff --git a/src/sage/categories/map.pyx b/src/sage/categories/map.pyx index 134b88ef1ba..67331807ec1 100644 --- a/src/sage/categories/map.pyx +++ b/src/sage/categories/map.pyx @@ -62,8 +62,13 @@ def is_Map(x): sage: f = R.hom([x+y, x-y], R) sage: from sage.categories.map import is_Map sage: is_Map(f) + doctest:warning... + DeprecationWarning: The function is_Map is deprecated; use 'isinstance(..., Map)' instead. + See https://github.com/sagemath/sage/issues/38103 for details. True """ + from sage.misc.superseded import deprecation_cython + deprecation_cython(38103, "The function is_Map is deprecated; use 'isinstance(..., Map)' instead.") return isinstance(x, Map) diff --git a/src/sage/categories/morphism.pyx b/src/sage/categories/morphism.pyx index 57e00943eda..3666492a794 100644 --- a/src/sage/categories/morphism.pyx +++ b/src/sage/categories/morphism.pyx @@ -47,6 +47,8 @@ from sage.structure.parent cimport Parent def is_Morphism(x): + from sage.misc.superseded import deprecation_cython + deprecation_cython(38103, "The function is_Morphism is deprecated; use 'isinstance(..., Morphism)' instead.") return isinstance(x, Morphism) diff --git a/src/sage/groups/abelian_gps/abelian_group_morphism.py b/src/sage/groups/abelian_gps/abelian_group_morphism.py index a44abb83df9..eb41400065a 100644 --- a/src/sage/groups/abelian_gps/abelian_group_morphism.py +++ b/src/sage/groups/abelian_gps/abelian_group_morphism.py @@ -25,6 +25,10 @@ def is_AbelianGroupMorphism(f): + from sage.misc.superseded import deprecation + deprecation(38103, + "The function is_AbelianGroupMorphism is deprecated; " + "use 'isinstance(..., AbelianGroupMorphism)' instead.") return isinstance(f, AbelianGroupMorphism) diff --git a/src/sage/groups/perm_gps/permgroup_morphism.py b/src/sage/groups/perm_gps/permgroup_morphism.py index 206828b4e1a..c0596d94b85 100644 --- a/src/sage/groups/perm_gps/permgroup_morphism.py +++ b/src/sage/groups/perm_gps/permgroup_morphism.py @@ -321,6 +321,14 @@ def is_PermutationGroupMorphism(f) -> bool: sage: H = DihedralGroup(4) sage: phi = PermutationGroupMorphism_im_gens(G, H, map(H, G.gens())) sage: is_PermutationGroupMorphism(phi) + doctest:warning... + DeprecationWarning: The function is_PermutationGroupMorphism is deprecated; + use 'isinstance(..., PermutationGroupMorphism)' instead. + See https://github.com/sagemath/sage/issues/38103 for details. True """ + from sage.misc.superseded import deprecation + deprecation(38103, + "The function is_PermutationGroupMorphism is deprecated; " + "use 'isinstance(..., PermutationGroupMorphism)' instead.") return isinstance(f, PermutationGroupMorphism) diff --git a/src/sage/homology/chain_complex_morphism.py b/src/sage/homology/chain_complex_morphism.py index e1bddf920e4..af68bf0c906 100644 --- a/src/sage/homology/chain_complex_morphism.py +++ b/src/sage/homology/chain_complex_morphism.py @@ -78,8 +78,16 @@ def is_ChainComplexMorphism(x): From: Chain complex with at most 7 nonzero terms over Integer Ring To: Chain complex with at most 7 nonzero terms over Integer Ring sage: is_ChainComplexMorphism(x) + doctest:warning... + DeprecationWarning: The function is_ChainComplexMorphism is deprecated; + use 'isinstance(..., ChainComplexMorphism)' instead. + See https://github.com/sagemath/sage/issues/38103 for details. True """ + from sage.misc.superseded import deprecation + deprecation(38103, + "The function is_ChainComplexMorphism is deprecated; " + "use 'isinstance(..., ChainComplexMorphism)' instead.") return isinstance(x, ChainComplexMorphism) diff --git a/src/sage/modules/fg_pid/fgp_morphism.py b/src/sage/modules/fg_pid/fgp_morphism.py index ae8309d6d87..4be28f43be1 100644 --- a/src/sage/modules/fg_pid/fgp_morphism.py +++ b/src/sage/modules/fg_pid/fgp_morphism.py @@ -20,7 +20,7 @@ # https://www.gnu.org/licenses/ # ************************************************************************* -from sage.categories.morphism import Morphism, is_Morphism +from sage.categories.morphism import Morphism from .fgp_module import DEBUG from sage.structure.richcmp import richcmp, op_NE from sage.misc.cachefunc import cached_method @@ -101,7 +101,7 @@ def __init__(self, parent, phi, check=True): # input: phi is a morphism from MO = M.optimized().V() to N.V() # that sends MO.W() to N.W() if check: - if not is_Morphism(phi) and M == N: + if not isinstance(phi, Morphism) and M == N: A = M.optimized()[0].V() B = N.V() s = M.base_ring()(phi) * B.coordinate_module(A).basis_matrix() diff --git a/src/sage/quivers/morphism.py b/src/sage/quivers/morphism.py index a1afbe79d1c..f6c2ca180a6 100644 --- a/src/sage/quivers/morphism.py +++ b/src/sage/quivers/morphism.py @@ -267,11 +267,11 @@ def __init__(self, domain, codomain, data={}): start_index += dim # Get the coordinates of the vector - from sage.categories.map import is_Map + from sage.categories.map import Map vector = [] for v in self._quiver: if v in maps_dict: - if is_Map(maps_dict[v]): + if isinstance(maps_dict[v], Map): try: m = maps_dict[v].matrix() except (AttributeError, ValueError): diff --git a/src/sage/quivers/representation.py b/src/sage/quivers/representation.py index 0d5aa2aa396..be58c37fd70 100644 --- a/src/sage/quivers/representation.py +++ b/src/sage/quivers/representation.py @@ -710,7 +710,7 @@ def create_key(self, k, P, *args, **kwds): # Note that the first space is assigned to key[3] and the first # vertex is 1 so the space assigned to vertex v is key[2 + v] from sage.matrix.constructor import Matrix - from sage.categories.morphism import is_Morphism + from sage.categories.morphism import Morphism for x in P._sorted_edges: if x in maps: e = maps[x] @@ -724,7 +724,7 @@ def create_key(self, k, P, *args, **kwds): # If a morphism is specified take it's matrix. Create one if # needed. Otherwise assume the Matrix function can convert the # object to a Matrix. - if is_Morphism(e): + if isinstance(e, Morphism): if hasattr(e, 'matrix'): key.append(e.matrix()) else: diff --git a/src/sage/rings/finite_rings/finite_field_base.pyx b/src/sage/rings/finite_rings/finite_field_base.pyx index 2c49f3bc9ae..661b2ba08e6 100644 --- a/src/sage/rings/finite_rings/finite_field_base.pyx +++ b/src/sage/rings/finite_rings/finite_field_base.pyx @@ -1260,7 +1260,7 @@ cdef class FiniteField(Field): return self.__vector_space from sage.modules.free_module import VectorSpace - from sage.categories.morphism import is_Morphism + from sage.categories.morphism import Morphism if base is None: base = self.prime_subfield() @@ -1269,7 +1269,7 @@ cdef class FiniteField(Field): self.__vector_space = VectorSpace(base, s) V = self.__vector_space inclusion_map = None - elif is_Morphism(base): + elif isinstance(base, Morphism): inclusion_map = base base = inclusion_map.domain() s = self.degree() // base.degree() diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index e4b41b438a5..96bd7d71380 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -539,8 +539,8 @@ def apply_morphism(self, phi): sage: taus[1](B) # needs sage.rings.number_fields Fractional ideal (2, a + 1) """ - from sage.categories.morphism import is_Morphism - if not is_Morphism(phi): + from sage.categories.morphism import Morphism + if not isinstance(phi, Morphism): raise TypeError("phi must be a morphism") # delegate: morphisms know how to apply themselves to ideals return phi(self) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index e13806ad619..5787b1196b2 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -1438,18 +1438,18 @@ def _convert_map_from_(self, other): i - a """ - from sage.categories.map import is_Map + from sage.categories.map import Map if self._structure is not None: structure = self.structure() if len(structure) >= 2: to_self = structure[1] - if is_Map(to_self) and to_self.domain() is other: + if isinstance(to_self, Map) and to_self.domain() is other: return to_self if isinstance(other, NumberField_generic) and other._structure is not None: structure = other.structure() if len(structure) >= 1: from_other = structure[0] - if is_Map(from_other) and from_other.codomain() is self: + if isinstance(from_other, Map) and from_other.codomain() is self: return from_other @cached_method @@ -9956,8 +9956,8 @@ def relativize(self, alpha, names, structure=None): from sage.matrix.constructor import matrix from sage.modules.free_module_element import vector - from sage.categories.map import is_Map - if is_Map(alpha): + from sage.categories.map import Map + if isinstance(alpha, Map): # alpha better be a morphism with codomain self if alpha.codomain() != self: raise ValueError("Co-domain of morphism must be self") diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py index 7d7c150d9d0..8516d628f04 100644 --- a/src/sage/rings/number_field/number_field_rel.py +++ b/src/sage/rings/number_field/number_field_rel.py @@ -77,7 +77,7 @@ import sage.libs.ntl.all as ntl -from sage.categories.map import is_Map +from sage.categories.map import Map from sage.structure.sequence import Sequence import sage.structure.parent_gens @@ -2678,7 +2678,7 @@ def relativize(self, alpha, names): K = self.absolute_field('a') from_K, to_K = K.structure() - if is_Map(alpha): + if isinstance(alpha, Map): # alpha is an embedding of a subfield into self; compose to get an # embedding of a subfield into the absolute field beta = to_K * alpha diff --git a/src/sage/sets/image_set.py b/src/sage/sets/image_set.py index 07ef2de695d..e2780d523c8 100644 --- a/src/sage/sets/image_set.py +++ b/src/sage/sets/image_set.py @@ -18,7 +18,7 @@ from typing import Iterator -from sage.categories.map import is_Map +from sage.categories.map import Map from sage.categories.poor_man_map import PoorManMap from sage.categories.sets_cat import Sets from sage.categories.enumerated_sets import EnumeratedSets @@ -86,7 +86,7 @@ def __init__(self, map, domain_subset, *, category=None, is_injective=None, inve from sage.sets.set import Set domain_subset = Set(domain_subset) - if not is_Map(map) and not isinstance(map, PoorManMap): + if not isinstance(map, Map) and not isinstance(map, PoorManMap): map_name = f"The map {map}" if isinstance(map, Expression) and map.is_callable(): domain = map.parent().base() @@ -100,7 +100,7 @@ def map(arg): domain = domain_subset map = PoorManMap(map, domain, name=map_name) - if is_Map(map): + if isinstance(map, Map): map_category = map.category_for() if is_injective is None: try: diff --git a/src/sage/topology/simplicial_complex_morphism.py b/src/sage/topology/simplicial_complex_morphism.py index c39bba0d355..e1f87f3ddd2 100644 --- a/src/sage/topology/simplicial_complex_morphism.py +++ b/src/sage/topology/simplicial_complex_morphism.py @@ -126,9 +126,17 @@ def is_SimplicialComplexMorphism(x): sage: f = {0:0,1:1,3:3,4:4} sage: x = H(f) sage: is_SimplicialComplexMorphism(x) + doctest:warning... + DeprecationWarning: The function is_SimplicialComplexMorphism is deprecated; + use 'isinstance(..., SimplicialComplexMorphism)' instead. + See https://github.com/sagemath/sage/issues/38103 for details. True """ + from sage.misc.superseded import deprecation + deprecation(38103, + "The function is_SimplicialComplexMorphism is deprecated; " + "use 'isinstance(..., SimplicialComplexMorphism)' instead.") return isinstance(x, SimplicialComplexMorphism)