summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2016-01-24 20:56:13 +0100
committerEric Gourgoulhon <eric.gourgoulhon@obspm.fr>2016-01-24 20:56:13 +0100
commit00d265cf2855121dba914868264da6ea3a9c42af (patch)
treefe2ff5906172c4686e2dc53ebadbcc5ade18d39b
parentMerge branch 'public/manifolds/top_manif_basics' into Sage 7.1.beta0. (diff)
Set verbose=False as the default in CoordChange.set_inverse; change "coord" to "coordinates" in names of ManifoldPoint methods.public/manifolds/top_manif_basics
-rw-r--r--src/sage/manifolds/chart.py31
-rw-r--r--src/sage/manifolds/manifold.py7
-rw-r--r--src/sage/manifolds/point.py78
3 files changed, 69 insertions, 47 deletions
diff --git a/src/sage/manifolds/chart.py b/src/sage/manifolds/chart.py
index a1130f3..6a6194b 100644
--- a/src/sage/manifolds/chart.py
+++ b/src/sage/manifolds/chart.py
@@ -65,8 +65,8 @@ class Chart(UniqueRepresentation, SageObject):
the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used)
- The coordiniate string has the space ``' '`` as a separator and each
- item has at most two fields, separated by ``:``:
+ The string ``coordinates`` has the space ``' '`` as a separator and each
+ item has at most two fields, separated by a colon (``:``):
1. the coordinate symbol (a letter or a few letters);
2. (optional) the LaTeX spelling of the coordinate, if not provided the
@@ -850,8 +850,8 @@ class RealChart(Chart):
the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used)
- The coordinates are a string, with ``' '`` (whitespace) as a separator.
- Each item has at most three fields, separated by ``':'``:
+ The string ``coordinates`` has the space ``' '`` as a separator and each
+ item has at most three fields, separated by a colon (``:``):
1. The coordinate symbol (a letter or a few letters).
2. (optional) The interval `I` defining the coordinate range: if not
@@ -1907,10 +1907,10 @@ class CoordChange(SageObject):
- ``transformations`` -- the inverse transformations expressed as a
list of the expressions of the "old" coordinates in terms of the
"new" ones
- - ``kwds`` -- keyword arguments: only ``verbose=True`` (default) or
- ``verbose=False`` are meaningful; it determines whether the provided
- transformations are checked to be indeed the inverse coordinate
- transformations
+ - ``kwds`` -- keyword arguments: only ``verbose=True`` or
+ ``verbose=False`` (default) are meaningful; it determines whether
+ the provided transformations are checked to be indeed the inverse
+ coordinate transformations
EXAMPLES:
@@ -1922,22 +1922,21 @@ class CoordChange(SageObject):
sage: c_spher.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi')
sage: spher_to_cart = c_spher.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
sage: spher_to_cart.set_inverse(sqrt(x^2+y^2), atan2(y,x))
- Check of the inverse coordinate transformation:
- r == r
- ph == arctan2(r*sin(ph), r*cos(ph))
- x == x
- y == y
sage: spher_to_cart.inverse()
Change of coordinates from Chart (U, (x, y)) to Chart (U, (r, ph))
+ sage: spher_to_cart.inverse().display()
+ r = sqrt(x^2 + y^2)
+ ph = arctan2(y, x)
sage: M.coord_changes() # random (dictionary output)
{(Chart (U, (r, ph)),
Chart (U, (x, y))): Change of coordinates from Chart (U, (r, ph)) to Chart (U, (x, y)),
(Chart (U, (x, y)),
Chart (U, (r, ph))): Change of coordinates from Chart (U, (x, y)) to Chart (U, (r, ph))}
- Introducing a wrong inverse transformation is revealed by the check::
+ Introducing a wrong inverse transformation (note the ``x^3`` typo) is
+ revealed by setting ``verbose`` to ``True``::
- sage: spher_to_cart.set_inverse(sqrt(x^3+y^2), atan2(y,x)) # note the x^3 typo
+ sage: spher_to_cart.set_inverse(sqrt(x^3+y^2), atan2(y,x), verbose=True)
Check of the inverse coordinate transformation:
r == sqrt(r^3*cos(ph)^3 + r^2*sin(ph)^2)
ph == arctan2(r*sin(ph), r*cos(ph))
@@ -1945,7 +1944,7 @@ class CoordChange(SageObject):
y == sqrt(x^3 + y^2)*y/sqrt(x^2 + y^2)
"""
- verbose = kwds.get('verbose', True)
+ verbose = kwds.get('verbose', False)
self._inverse = type(self)(self._chart2, self._chart1,
*transformations)
if verbose:
diff --git a/src/sage/manifolds/manifold.py b/src/sage/manifolds/manifold.py
index 7a638ee..218c54f 100644
--- a/src/sage/manifolds/manifold.py
+++ b/src/sage/manifolds/manifold.py
@@ -1376,15 +1376,16 @@ class TopologicalManifold(ManifoldSubset):
INPUT:
- - ``coordinates`` -- (default: ``'``' (empty string)) string
+ - ``coordinates`` -- (default: ``''`` (empty string)) string
defining the coordinate symbols and ranges, see below
- ``names`` -- (default: ``None``) unused argument, except if
``coordinates`` is not provided; it must then be a tuple containing
the coordinate symbols (this is guaranteed if the shortcut operator
``<,>`` is used)
- The coordinates are separated by ``' '`` (space) and each
- coordinate has at most three fields, separated by ``':'``:
+ The coordinates declared in the string ``coordinates`` are
+ separated by ``' '`` (whitespace) and each coordinate has at most three
+ fields, separated by a colon (``':'``):
1. The coordinate symbol (a letter or a few letters).
2. (optional, only for manifolds over `\RR`) The interval `I`
diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py
index 05ce5f3..8fdb6d4 100644
--- a/src/sage/manifolds/point.py
+++ b/src/sage/manifolds/point.py
@@ -41,7 +41,7 @@ We construct the point in the coordinates in the default chart of ``U``
Open subset U of the 3-dimensional topological manifold R^3
sage: c_spher(p)
(1, 1/2*pi, pi)
- sage: p.coord(c_spher) # equivalent to above
+ sage: p.coordinates(c_spher) # equivalent to above
(1, 1/2*pi, pi)
Computing the coordinates of ``p`` in a new chart::
@@ -108,7 +108,7 @@ class ManifoldPoint(Element):
sage: (a, b) = var('a b') # generic coordinates for the point
sage: p = M.point((a, b), name='P'); p
Point P on the 2-dimensional topological manifold M
- sage: p.coord() # coordinates of P in the subset's default chart
+ sage: p.coordinates() # coordinates of P in the subset's default chart
(a, b)
Since points are Sage *elements*, the *parent* of which being the
@@ -245,7 +245,7 @@ class ManifoldPoint(Element):
return r'\mbox{' + str(self) + r'}'
return self._latex_name
- def coord(self, chart=None, old_chart=None):
+ def coordinates(self, chart=None, old_chart=None):
r"""
Return the point coordinates in the specified chart.
@@ -253,8 +253,8 @@ class ManifoldPoint(Element):
known ones by means of change-of-chart formulas.
An equivalent way to get the coordinates of a point is to let the
- chart acting of the point, i.e. if ``X`` is a chart and ``p`` a
- point, one has ``p.coord(chart=X) == X(p)``.
+ chart acting on the point, i.e. if ``X`` is a chart and ``p`` a
+ point, one has ``p.coordinates(chart=X) == X(p)``.
INPUT:
@@ -273,14 +273,13 @@ class ManifoldPoint(Element):
sage: M = Manifold(3, 'M', structure='topological')
sage: c_spher.<r,th,ph> = M.chart(r'r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi') # spherical coordinates
sage: p = M.point((1, pi/2, pi))
- sage: p.coord() # coordinates on the manifold's default chart
+ sage: p.coordinates() # coordinates in the manifold's default chart
(1, 1/2*pi, pi)
- We now give ``p`` in the coordinates of the chart ``c_spher``
- explicitly specified. However this is same result as above
- since this is the default chart)::
+ Since the default chart of ``M`` is ``c_spher``, it is equivalent to
+ write::
- sage: p.coord(c_spher)
+ sage: p.coordinates(c_spher)
(1, 1/2*pi, pi)
An alternative way to get the coordinates is to let the chart act
@@ -289,6 +288,11 @@ class ManifoldPoint(Element):
sage: c_spher(p)
(1, 1/2*pi, pi)
+ A shortcut for ``coordinates`` is ``coord``::
+
+ sage: p.coord()
+ (1, 1/2*pi, pi)
+
Computing the Cartesian coordinates from the spherical ones::
sage: c_cart.<x,y,z> = M.chart() # Cartesian coordinates
@@ -327,7 +331,7 @@ class ManifoldPoint(Element):
sage: c_wz.<w,z> = M.chart()
sage: ch_uv_wz = c_uv.transition_map(c_wz, [u^3, v^3])
- sage: p.coord(c_wz, old_chart=c_uv)
+ sage: P.coord(c_wz, old_chart=c_uv)
(a^3 - 3*a^2*b + 3*a*b^2 - b^3, a^3 + 3*a^2*b + 3*a*b^2 + b^3)
Actually, in the present case, it is not necessary to specify
@@ -409,7 +413,9 @@ class ManifoldPoint(Element):
self._coordinates[chart] = chcoord(*self._coordinates[old_chart])
return self._coordinates[chart]
- def set_coord(self, coords, chart=None):
+ coord = coordinates
+
+ def set_coordinates(self, coords, chart=None):
r"""
Sets the point coordinates in the specified chart.
@@ -432,21 +438,27 @@ class ManifoldPoint(Element):
sage: X.<x,y> = M.chart()
sage: p = M.point()
- We set the coordinates on the manifold's default chart::
+ We set the coordinates in the manifold's default chart::
- sage: p.set_coord((2,-3))
- sage: p.coord()
+ sage: p.set_coordinates((2,-3))
+ sage: p.coordinates()
(2, -3)
sage: X(p)
(2, -3)
+ A shortcut for ``set_coordinates`` is ``set_coord``::
+
+ sage: p.set_coord((2,-3))
+ sage: p.coord()
+ (2, -3)
+
Let us introduce a second chart on the manifold::
sage: Y.<u,v> = M.chart()
sage: X_to_Y = X.transition_map(Y, [x+y, x-y])
- If we set the coordinates of ``p`` in the chart ``Y``, those
- in the chart ``X`` are lost::
+ If we set the coordinates of ``p`` in chart ``Y``, those in chart ``X``
+ are lost::
sage: Y(p)
(-1, 5)
@@ -458,7 +470,9 @@ class ManifoldPoint(Element):
self._coordinates.clear()
self.add_coord(coords, chart)
- def add_coord(self, coords, chart=None):
+ set_coord = set_coordinates
+
+ def add_coordinates(self, coords, chart=None):
r"""
Adds some coordinates in the specified chart.
@@ -486,30 +500,36 @@ class ManifoldPoint(Element):
sage: X.<x,y> = M.chart()
sage: p = M.point()
- We give the point the coordinates on the manifold's default chart::
+ We give the point some coordinates in the manifold's default chart::
- sage: p.add_coord((2,-3))
- sage: p.coord()
+ sage: p.add_coordinates((2,-3))
+ sage: p.coordinates()
(2, -3)
sage: X(p)
(2, -3)
+ A shortcut for ``add_coordinates`` is ``add_coord``::
+
+ sage: p.add_coord((2,-3))
+ sage: p.coord()
+ (2, -3)
+
Let us introduce a second chart on the manifold::
sage: Y.<u,v> = M.chart()
sage: X_to_Y = X.transition_map(Y, [x+y, x-y])
- If we add the coordinates of p in the chart Y, those in the chart X
+ If we add coordinates for ``p`` in chart ``Y``, those in chart ``X``
are kept::
- sage: p.add_coord((-1,5), chart=Y)
+ sage: p.add_coordinates((-1,5), chart=Y)
sage: p._coordinates # random (dictionary output)
{Chart (M, (u, v)): (-1, 5), Chart (M, (x, y)): (2, -3)}
- On the contrary, with the method :meth:`set_coord`, the coordinates
- in charts different from Y would be lost::
+ On the contrary, with the method :meth:`set_coordinates`, the
+ coordinates in charts different from ``Y`` would be lost::
- sage: p.set_coord((-1,5), chart=Y)
+ sage: p.set_coordinates((-1,5), chart=Y)
sage: p._coordinates
{Chart (M, (u, v)): (-1, 5)}
@@ -525,6 +545,8 @@ class ManifoldPoint(Element):
"defined on the {}".format(self.parent()))
self._coordinates[chart] = coords
+ add_coord = add_coordinates
+
def __eq__(self, other):
r"""
Compares the current point with another one.
@@ -594,7 +616,7 @@ class ManifoldPoint(Element):
# transformation:
for chart in self._coordinates:
try:
- other.coord(chart)
+ other.coordinates(chart)
common_chart = chart
break
except ValueError:
@@ -603,7 +625,7 @@ class ManifoldPoint(Element):
# Attempt a coordinate transformation in the reverse way:
for chart in other._coordinates:
try:
- self.coord(chart)
+ self.coordinates(chart)
common_chart = chart
break
except ValueError: