summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2016-01-03 14:55:44 +0100
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2016-01-03 14:55:44 +0100
commit19caedb4d055887ad33ab2ab7b051d166bd58c90 (patch)
tree256c49e180adb550828a4f0a243f9080d1a26d9c
parentMerge branch 'public/manifolds/top_manif_basics' into Sage 7.0.beta2. (diff)
Revert to AbstractNamedObject without argument full_name; restore _repr_() in manifold classes
-rw-r--r--src/sage/manifolds/abstract.py27
-rw-r--r--src/sage/manifolds/manifold.py67
-rw-r--r--src/sage/manifolds/subset.py37
3 files changed, 82 insertions, 49 deletions
diff --git a/src/sage/manifolds/abstract.py b/src/sage/manifolds/abstract.py
index 7bab86e..44801d4 100644
--- a/src/sage/manifolds/abstract.py
+++ b/src/sage/manifolds/abstract.py
@@ -32,7 +32,7 @@ class AbstractNamedObject(object):
r"""
An abstract named object.
- This abstract class handles the outputs (text and LaTeX) of named objects
+ This abstract class handles the symbols (text and LaTeX) of named objects
(e.g. parent objects in manifold classes).
INPUT:
@@ -40,16 +40,13 @@ class AbstractNamedObject(object):
- ``name`` -- (short) string; name (symbol) given to the object
- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to
denote the object; if ``None``, the LaTeX symbol is set to ``name``
- - ``full_name`` -- (default: ``None``) string; short description of the
- object; if ``None``, the description is set to ``name``.
EXAMPLES::
sage: from sage.manifolds.abstract import AbstractNamedObject
- sage: a = AbstractNamedObject('A', latex_name=r'\mathcal{A}',
- ....: full_name='Object A')
+ sage: a = AbstractNamedObject('A', latex_name=r'\mathcal{A}')
sage: a._repr_()
- 'Object A'
+ 'A'
sage: a._latex_()
'\\mathcal{A}'
sage: latex(a)
@@ -66,7 +63,7 @@ class AbstractNamedObject(object):
A
"""
- def __init__(self, name, latex_name=None, full_name=None):
+ def __init__(self, name, latex_name=None):
"""
Initialize ``self``.
@@ -87,12 +84,6 @@ class AbstractNamedObject(object):
if not isinstance(latex_name, str):
raise TypeError("{} is not a string".format(latex_name))
self._latex_name = latex_name
- if full_name is None:
- self.__custom_name = self._name
- else:
- if not isinstance(full_name, str):
- raise TypeError("{} is not a string".format(full_name))
- self.__custom_name = full_name
def _repr_(self):
"""
@@ -106,7 +97,7 @@ class AbstractNamedObject(object):
'a'
"""
- return self.__custom_name
+ return self._name
def _latex_(self):
r"""
@@ -150,15 +141,12 @@ class AbstractSet(AbstractNamedObject, UniqueRepresentation, Parent):
- ``name`` -- (short) string; name (symbol) given to the object
- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to
denote the object; if ``None``, the LaTeX symbol is set to ``name``
- - ``full_name`` -- (default: ``None``) string; short description of the
- object; if ``None``, the description is set to ``name``.
- ``base`` -- (default: ``None``) base for the
:class:`~sage.structure.parent.Parent` constructor
- ``category`` -- (default: ``None``) category of the object
"""
- def __init__(self, name, latex_name=None, full_name=None, base=None,
- category=None):
+ def __init__(self, name, latex_name=None, base=None, category=None):
r"""
Initialize ``self``
@@ -169,8 +157,7 @@ class AbstractSet(AbstractNamedObject, UniqueRepresentation, Parent):
sage: A = M.subset('A'); A
Subset A of the 2-dimensional topological manifold M
"""
- AbstractNamedObject.__init__(self, name, latex_name=latex_name,
- full_name=full_name)
+ AbstractNamedObject.__init__(self, name, latex_name=latex_name)
category = Sets().or_subcategory(category)
Parent.__init__(self, base=base, category=category)
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 3c377c5..43dd572 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -336,9 +336,6 @@ class TopologicalManifold(AbstractSet):
:class:`~sage.manifolds.structure.RealTopologicalStructure`)
- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to
denote the manifold; if none is provided, it is set to ``name``
- - ``full_name`` -- (default: ``None``) string; short description of the
- manifold; if none is provided, it is formed from the field, dimension
- and structure
- ``start_index`` -- (default: 0) integer; lower value of the range of
indices used for "indexed objects" on the manifold, e.g., coordinates
in a chart
@@ -455,8 +452,7 @@ class TopologicalManifold(AbstractSet):
"""
def __init__(self, n, name, field, structure, latex_name=None,
- full_name=None, start_index=0, category=None,
- unique_tag=None):
+ start_index=0, category=None, unique_tag=None):
r"""
Construct a topological manifold.
@@ -496,29 +492,14 @@ class TopologicalManifold(AbstractSet):
self._structure = structure
category = Manifolds(self._field).or_subcategory(category)
category = self._structure.subcategory(category)
- # Full name:
- if full_name is None:
- if self._field_type == 'real':
- full_name = "{}-dimensional {} manifold {}".format(n,
- self._structure.name,
- name)
- elif self._field_type == 'complex':
- full_name = "Complex {}-dimensional {} manifold {}".format(n,
- self._structure.name,
- name)
- else:
- full_name = "{}-dimensional {} manifold {} over the {}".format(n,
- self._structure.name,
- name, self._field)
# Initialization as a manifold set:
AbstractSet.__init__(self, name, latex_name=latex_name,
- full_name=full_name, base=self._field,
- category=category)
-
+ base=self._field, category=category)
+ #
if not isinstance(start_index, (int, Integer)):
raise TypeError("the starting index must be an integer")
self._sindex = start_index
-
+ #
self._atlas = [] # list of charts defined on subsets of self
self._top_charts = [] # list of charts defined on subsets of self
# that are not subcharts of charts on larger subsets
@@ -533,6 +514,46 @@ class TopologicalManifold(AbstractSet):
self._covering_charts = []
self._open_covers.append([self]) # list of open covers of self
+ def _repr_(self):
+ r"""
+ Return a string representation of the manifold.
+
+ TESTS::
+
+ sage: M = Manifold(3, 'M', structure='topological')
+ sage: M._repr_()
+ '3-dimensional topological manifold M'
+ sage: repr(M) # indirect doctest
+ '3-dimensional topological manifold M'
+ sage: M # indirect doctest
+ 3-dimensional topological manifold M
+ sage: M = Manifold(3, 'M', structure='topological', field='complex')
+ sage: M._repr_()
+ 'Complex 3-dimensional topological manifold M'
+ sage: M = Manifold(3, 'M', structure='topological', field=QQ)
+ sage: M._repr_()
+ '3-dimensional topological manifold M over the Rational Field'
+
+ If the manifold is actually an open subset of a larger manifold, the
+ string representation is different::
+
+ sage: U = M.open_subset('U')
+ sage: U._repr_()
+ 'Open subset U of the 3-dimensional topological manifold M over the Rational Field'
+
+ """
+ if self._field_type == 'real':
+ return "{}-dimensional {} manifold {}".format(self._dim,
+ self._structure.name,
+ self._name)
+ elif self._field_type == 'complex':
+ return "Complex {}-dimensional {} manifold {}".format(self._dim,
+ self._structure.name,
+ self._name)
+ return "{}-dimensional {} manifold {} over the {}".format(self._dim,
+ self._structure.name, self._name,
+ self._field)
+
def _an_element_(self):
r"""
Construct some point on the manifold.
diff --git a/src/sage/manifolds/subset.py b/src/sage/manifolds/subset.py
index e3e72a4..56254d6 100644
--- a/src/sage/manifolds/subset.py
+++ b/src/sage/manifolds/subset.py
@@ -168,13 +168,28 @@ class ManifoldSubset(AbstractSet):
raise ValueError("the name '" + name +
"' is already used for another " +
"subset of the {}".format(manifold))
- full_name = "Subset {} of the {}".format(name, manifold)
category = Sets().Subobjects()
AbstractSet.__init__(self, name=name, latex_name=latex_name,
- full_name=full_name, category=category)
+ category=category)
self._manifold = manifold
manifold._subsets.add(self)
+ def _repr_(self):
+ r"""
+ String representation of the object.
+
+ TESTS::
+
+ sage: M = Manifold(2, 'M', structure='topological')
+ sage: A = M.subset('A')
+ sage: A._repr_()
+ 'Subset A of the 2-dimensional topological manifold M'
+ sage: repr(A) # indirect doctest
+ 'Subset A of the 2-dimensional topological manifold M'
+
+ """
+ return "Subset {} of the {}".format(self._name, self._manifold)
+
def manifold(self):
r"""
Return the manifold of which the current object is a subset.
@@ -575,7 +590,6 @@ class OpenTopologicalSubmanifold(ManifoldSubset, TopologicalManifold):
if not isinstance(ambient, TopologicalManifold):
raise TypeError("the argument 'ambient' must be " +
"a topological manifold")
- full_name = "Open subset {} of the {}".format(name, ambient)
# This is copied from ManifoldSubset to avoid twice
# initializing AbstractSet
self._manifold = ambient
@@ -585,15 +599,26 @@ class OpenTopologicalSubmanifold(ManifoldSubset, TopologicalManifold):
"' is already used for another " +
"subset of the {}".format(ambient))
ambient._subsets.add(self)
-
category = ambient.category().Subobjects()
-
TopologicalManifold.__init__(self, ambient.dim(), name, ambient._field,
ambient._structure, latex_name=latex_name,
- full_name=full_name,
start_index=ambient._sindex,
category=category)
+ def _repr_(self):
+ """
+ Return a string representation of ``self``.
+
+ TEST::
+
+ sage: M = Manifold(3, 'M', structure='topological')
+ sage: A = M.open_subset('A')
+ sage: A._repr_()
+ 'Open subset A of the 3-dimensional topological manifold M'
+
+ """
+ return "Open subset {} of the {}".format(self._name, self._manifold)
+
def superset(self, name, latex_name=None, is_open=False):
r"""
Create a superset of the current subset.