Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Remove identity_map duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jun 4, 2020
1 parent 23b6012 commit ca06162
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 42 deletions.
40 changes: 0 additions & 40 deletions src/sage/manifolds/differentiable/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -3940,43 +3940,3 @@ class :class:`~sage.manifolds.differentiable.diff_map.DiffMap`
else:
signat = 2 - dim
return vmodule.metric(name, signature=signat, latex_name=latex_name)

@cached_method
def identity_map(self) -> DiffMap:
r"""
Identity map of ``self``.
The identity map of a differentiable manifold `M` is the trivial
diffeomorphism:
.. MATH::
\begin{array}{cccc}
\mathrm{Id}_M: & M & \longrightarrow & M \\
& p & \longmapsto & p
\end{array}
OUTPUT:
- the identity map
EXAMPLES:
Identity map of a differentiable manifold::
sage: M = Manifold(2, 'M', structure='differentiable')
sage: id = M.identity_map(); id
Identity map Id_M of the 2-dimensional differentiable manifold M
sage: id.display()
Id_M: M --> M
sage: isinstance(id, DiffMap)
True
Identity map of a topological manifold is not smooth::
sage: M = Manifold(2, 'M', structure='topological')
sage: isinstance(M.identity_map(), DiffMap)
False
"""
return Hom(self, self).one()
24 changes: 22 additions & 2 deletions src/sage/manifolds/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@
from sage.manifolds.structure import(
TopologicalStructure, RealTopologicalStructure,
DifferentialStructure, RealDifferentialStructure)
from typing import Union, TYPE_CHECKING, Optional
from typing import Union, TYPE_CHECKING, Optional, overload
if TYPE_CHECKING:
from sage.manifolds.manifold import TopologicalManifold
from sage.manifolds.differentiable.manifold import DifferentiableManifold
from sage.manifolds.continuous_map import ContinuousMap
from sage.manifolds.differentiable.diff_map import DiffMap


#############################################################################
Expand Down Expand Up @@ -2146,8 +2148,12 @@ def homeomorphism(self, codomain, coord_functions=None, chart1=None,
return homset(coord_functions, name=name, latex_name=latex_name,
is_isomorphism=True)

@overload
def identity_map(self: 'DifferentiableManifold') -> 'DiffMap': ...
@overload
def identity_map(self: 'TopologicalManifold') -> 'ContinuousMap': ...
@cached_method
def identity_map(self) -> 'ContinuousMap':
def identity_map(self):
r"""
Identity map of ``self``.
Expand Down Expand Up @@ -2191,6 +2197,20 @@ def identity_map(self) -> 'ContinuousMap':
sage: id(p) == p
True
Identity map of a differentiable manifold::
sage: M = Manifold(2, 'M', structure='differentiable')
sage: id = M.identity_map(); id
Identity map Id_M of the 2-dimensional differentiable manifold M
sage: isinstance(id, DiffMap)
True
Identity map of a topological manifold is not smooth::
sage: M = Manifold(2, 'M', structure='topological')
sage: isinstance(M.identity_map(), DiffMap)
False
.. SEEALSO::
See :class:`~sage.manifolds.continuous_map.ContinuousMap`
Expand Down

0 comments on commit ca06162

Please sign in to comment.