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

Commit 00d265c

Browse files
committed
Set verbose=False as the default in CoordChange.set_inverse; change "coord" to "coordinates" in names of ManifoldPoint methods.
1 parent 0c9d7fa commit 00d265c

File tree

3 files changed

+69
-47
lines changed

3 files changed

+69
-47
lines changed

src/sage/manifolds/chart.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class Chart(UniqueRepresentation, SageObject):
6565
the coordinate symbols (this is guaranteed if the shortcut operator
6666
``<,>`` is used)
6767
68-
The coordiniate string has the space ``' '`` as a separator and each
69-
item has at most two fields, separated by ``:``:
68+
The string ``coordinates`` has the space ``' '`` as a separator and each
69+
item has at most two fields, separated by a colon (``:``):
7070
7171
1. the coordinate symbol (a letter or a few letters);
7272
2. (optional) the LaTeX spelling of the coordinate, if not provided the
@@ -850,8 +850,8 @@ class RealChart(Chart):
850850
the coordinate symbols (this is guaranteed if the shortcut operator
851851
``<,>`` is used)
852852
853-
The coordinates are a string, with ``' '`` (whitespace) as a separator.
854-
Each item has at most three fields, separated by ``':'``:
853+
The string ``coordinates`` has the space ``' '`` as a separator and each
854+
item has at most three fields, separated by a colon (``:``):
855855
856856
1. The coordinate symbol (a letter or a few letters).
857857
2. (optional) The interval `I` defining the coordinate range: if not
@@ -1907,10 +1907,10 @@ def set_inverse(self, *transformations, **kwds):
19071907
- ``transformations`` -- the inverse transformations expressed as a
19081908
list of the expressions of the "old" coordinates in terms of the
19091909
"new" ones
1910-
- ``kwds`` -- keyword arguments: only ``verbose=True`` (default) or
1911-
``verbose=False`` are meaningful; it determines whether the provided
1912-
transformations are checked to be indeed the inverse coordinate
1913-
transformations
1910+
- ``kwds`` -- keyword arguments: only ``verbose=True`` or
1911+
``verbose=False`` (default) are meaningful; it determines whether
1912+
the provided transformations are checked to be indeed the inverse
1913+
coordinate transformations
19141914
19151915
EXAMPLES:
19161916
@@ -1922,30 +1922,29 @@ def set_inverse(self, *transformations, **kwds):
19221922
sage: c_spher.<r,ph> = U.chart(r'r:(0,+oo) ph:(0,2*pi):\phi')
19231923
sage: spher_to_cart = c_spher.transition_map(c_cart, [r*cos(ph), r*sin(ph)])
19241924
sage: spher_to_cart.set_inverse(sqrt(x^2+y^2), atan2(y,x))
1925-
Check of the inverse coordinate transformation:
1926-
r == r
1927-
ph == arctan2(r*sin(ph), r*cos(ph))
1928-
x == x
1929-
y == y
19301925
sage: spher_to_cart.inverse()
19311926
Change of coordinates from Chart (U, (x, y)) to Chart (U, (r, ph))
1927+
sage: spher_to_cart.inverse().display()
1928+
r = sqrt(x^2 + y^2)
1929+
ph = arctan2(y, x)
19321930
sage: M.coord_changes() # random (dictionary output)
19331931
{(Chart (U, (r, ph)),
19341932
Chart (U, (x, y))): Change of coordinates from Chart (U, (r, ph)) to Chart (U, (x, y)),
19351933
(Chart (U, (x, y)),
19361934
Chart (U, (r, ph))): Change of coordinates from Chart (U, (x, y)) to Chart (U, (r, ph))}
19371935
1938-
Introducing a wrong inverse transformation is revealed by the check::
1936+
Introducing a wrong inverse transformation (note the ``x^3`` typo) is
1937+
revealed by setting ``verbose`` to ``True``::
19391938
1940-
sage: spher_to_cart.set_inverse(sqrt(x^3+y^2), atan2(y,x)) # note the x^3 typo
1939+
sage: spher_to_cart.set_inverse(sqrt(x^3+y^2), atan2(y,x), verbose=True)
19411940
Check of the inverse coordinate transformation:
19421941
r == sqrt(r^3*cos(ph)^3 + r^2*sin(ph)^2)
19431942
ph == arctan2(r*sin(ph), r*cos(ph))
19441943
x == sqrt(x^3 + y^2)*x/sqrt(x^2 + y^2)
19451944
y == sqrt(x^3 + y^2)*y/sqrt(x^2 + y^2)
19461945
19471946
"""
1948-
verbose = kwds.get('verbose', True)
1947+
verbose = kwds.get('verbose', False)
19491948
self._inverse = type(self)(self._chart2, self._chart1,
19501949
*transformations)
19511950
if verbose:

src/sage/manifolds/manifold.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,15 +1376,16 @@ def chart(self, coordinates='', names=None):
13761376
13771377
INPUT:
13781378
1379-
- ``coordinates`` -- (default: ``'``' (empty string)) string
1379+
- ``coordinates`` -- (default: ``''`` (empty string)) string
13801380
defining the coordinate symbols and ranges, see below
13811381
- ``names`` -- (default: ``None``) unused argument, except if
13821382
``coordinates`` is not provided; it must then be a tuple containing
13831383
the coordinate symbols (this is guaranteed if the shortcut operator
13841384
``<,>`` is used)
13851385
1386-
The coordinates are separated by ``' '`` (space) and each
1387-
coordinate has at most three fields, separated by ``':'``:
1386+
The coordinates declared in the string ``coordinates`` are
1387+
separated by ``' '`` (whitespace) and each coordinate has at most three
1388+
fields, separated by a colon (``':'``):
13881389
13891390
1. The coordinate symbol (a letter or a few letters).
13901391
2. (optional, only for manifolds over `\RR`) The interval `I`

src/sage/manifolds/point.py

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
Open subset U of the 3-dimensional topological manifold R^3
4242
sage: c_spher(p)
4343
(1, 1/2*pi, pi)
44-
sage: p.coord(c_spher) # equivalent to above
44+
sage: p.coordinates(c_spher) # equivalent to above
4545
(1, 1/2*pi, pi)
4646
4747
Computing the coordinates of ``p`` in a new chart::
@@ -108,7 +108,7 @@ class ManifoldPoint(Element):
108108
sage: (a, b) = var('a b') # generic coordinates for the point
109109
sage: p = M.point((a, b), name='P'); p
110110
Point P on the 2-dimensional topological manifold M
111-
sage: p.coord() # coordinates of P in the subset's default chart
111+
sage: p.coordinates() # coordinates of P in the subset's default chart
112112
(a, b)
113113
114114
Since points are Sage *elements*, the *parent* of which being the
@@ -245,16 +245,16 @@ def _latex_(self):
245245
return r'\mbox{' + str(self) + r'}'
246246
return self._latex_name
247247

248-
def coord(self, chart=None, old_chart=None):
248+
def coordinates(self, chart=None, old_chart=None):
249249
r"""
250250
Return the point coordinates in the specified chart.
251251
252252
If these coordinates are not already known, they are computed from
253253
known ones by means of change-of-chart formulas.
254254
255255
An equivalent way to get the coordinates of a point is to let the
256-
chart acting of the point, i.e. if ``X`` is a chart and ``p`` a
257-
point, one has ``p.coord(chart=X) == X(p)``.
256+
chart acting on the point, i.e. if ``X`` is a chart and ``p`` a
257+
point, one has ``p.coordinates(chart=X) == X(p)``.
258258
259259
INPUT:
260260
@@ -273,14 +273,13 @@ def coord(self, chart=None, old_chart=None):
273273
sage: M = Manifold(3, 'M', structure='topological')
274274
sage: c_spher.<r,th,ph> = M.chart(r'r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi') # spherical coordinates
275275
sage: p = M.point((1, pi/2, pi))
276-
sage: p.coord() # coordinates on the manifold's default chart
276+
sage: p.coordinates() # coordinates in the manifold's default chart
277277
(1, 1/2*pi, pi)
278278
279-
We now give ``p`` in the coordinates of the chart ``c_spher``
280-
explicitly specified. However this is same result as above
281-
since this is the default chart)::
279+
Since the default chart of ``M`` is ``c_spher``, it is equivalent to
280+
write::
282281
283-
sage: p.coord(c_spher)
282+
sage: p.coordinates(c_spher)
284283
(1, 1/2*pi, pi)
285284
286285
An alternative way to get the coordinates is to let the chart act
@@ -289,6 +288,11 @@ def coord(self, chart=None, old_chart=None):
289288
sage: c_spher(p)
290289
(1, 1/2*pi, pi)
291290
291+
A shortcut for ``coordinates`` is ``coord``::
292+
293+
sage: p.coord()
294+
(1, 1/2*pi, pi)
295+
292296
Computing the Cartesian coordinates from the spherical ones::
293297
294298
sage: c_cart.<x,y,z> = M.chart() # Cartesian coordinates
@@ -327,7 +331,7 @@ def coord(self, chart=None, old_chart=None):
327331
328332
sage: c_wz.<w,z> = M.chart()
329333
sage: ch_uv_wz = c_uv.transition_map(c_wz, [u^3, v^3])
330-
sage: p.coord(c_wz, old_chart=c_uv)
334+
sage: P.coord(c_wz, old_chart=c_uv)
331335
(a^3 - 3*a^2*b + 3*a*b^2 - b^3, a^3 + 3*a^2*b + 3*a*b^2 + b^3)
332336
333337
Actually, in the present case, it is not necessary to specify
@@ -409,7 +413,9 @@ def coord(self, chart=None, old_chart=None):
409413
self._coordinates[chart] = chcoord(*self._coordinates[old_chart])
410414
return self._coordinates[chart]
411415

412-
def set_coord(self, coords, chart=None):
416+
coord = coordinates
417+
418+
def set_coordinates(self, coords, chart=None):
413419
r"""
414420
Sets the point coordinates in the specified chart.
415421
@@ -432,21 +438,27 @@ def set_coord(self, coords, chart=None):
432438
sage: X.<x,y> = M.chart()
433439
sage: p = M.point()
434440
435-
We set the coordinates on the manifold's default chart::
441+
We set the coordinates in the manifold's default chart::
436442
437-
sage: p.set_coord((2,-3))
438-
sage: p.coord()
443+
sage: p.set_coordinates((2,-3))
444+
sage: p.coordinates()
439445
(2, -3)
440446
sage: X(p)
441447
(2, -3)
442448
449+
A shortcut for ``set_coordinates`` is ``set_coord``::
450+
451+
sage: p.set_coord((2,-3))
452+
sage: p.coord()
453+
(2, -3)
454+
443455
Let us introduce a second chart on the manifold::
444456
445457
sage: Y.<u,v> = M.chart()
446458
sage: X_to_Y = X.transition_map(Y, [x+y, x-y])
447459
448-
If we set the coordinates of ``p`` in the chart ``Y``, those
449-
in the chart ``X`` are lost::
460+
If we set the coordinates of ``p`` in chart ``Y``, those in chart ``X``
461+
are lost::
450462
451463
sage: Y(p)
452464
(-1, 5)
@@ -458,7 +470,9 @@ def set_coord(self, coords, chart=None):
458470
self._coordinates.clear()
459471
self.add_coord(coords, chart)
460472

461-
def add_coord(self, coords, chart=None):
473+
set_coord = set_coordinates
474+
475+
def add_coordinates(self, coords, chart=None):
462476
r"""
463477
Adds some coordinates in the specified chart.
464478
@@ -486,30 +500,36 @@ def add_coord(self, coords, chart=None):
486500
sage: X.<x,y> = M.chart()
487501
sage: p = M.point()
488502
489-
We give the point the coordinates on the manifold's default chart::
503+
We give the point some coordinates in the manifold's default chart::
490504
491-
sage: p.add_coord((2,-3))
492-
sage: p.coord()
505+
sage: p.add_coordinates((2,-3))
506+
sage: p.coordinates()
493507
(2, -3)
494508
sage: X(p)
495509
(2, -3)
496510
511+
A shortcut for ``add_coordinates`` is ``add_coord``::
512+
513+
sage: p.add_coord((2,-3))
514+
sage: p.coord()
515+
(2, -3)
516+
497517
Let us introduce a second chart on the manifold::
498518
499519
sage: Y.<u,v> = M.chart()
500520
sage: X_to_Y = X.transition_map(Y, [x+y, x-y])
501521
502-
If we add the coordinates of p in the chart Y, those in the chart X
522+
If we add coordinates for ``p`` in chart ``Y``, those in chart ``X``
503523
are kept::
504524
505-
sage: p.add_coord((-1,5), chart=Y)
525+
sage: p.add_coordinates((-1,5), chart=Y)
506526
sage: p._coordinates # random (dictionary output)
507527
{Chart (M, (u, v)): (-1, 5), Chart (M, (x, y)): (2, -3)}
508528
509-
On the contrary, with the method :meth:`set_coord`, the coordinates
510-
in charts different from Y would be lost::
529+
On the contrary, with the method :meth:`set_coordinates`, the
530+
coordinates in charts different from ``Y`` would be lost::
511531
512-
sage: p.set_coord((-1,5), chart=Y)
532+
sage: p.set_coordinates((-1,5), chart=Y)
513533
sage: p._coordinates
514534
{Chart (M, (u, v)): (-1, 5)}
515535
@@ -525,6 +545,8 @@ def add_coord(self, coords, chart=None):
525545
"defined on the {}".format(self.parent()))
526546
self._coordinates[chart] = coords
527547

548+
add_coord = add_coordinates
549+
528550
def __eq__(self, other):
529551
r"""
530552
Compares the current point with another one.
@@ -594,7 +616,7 @@ def __eq__(self, other):
594616
# transformation:
595617
for chart in self._coordinates:
596618
try:
597-
other.coord(chart)
619+
other.coordinates(chart)
598620
common_chart = chart
599621
break
600622
except ValueError:
@@ -603,7 +625,7 @@ def __eq__(self, other):
603625
# Attempt a coordinate transformation in the reverse way:
604626
for chart in other._coordinates:
605627
try:
606-
self.coord(chart)
628+
self.coordinates(chart)
607629
common_chart = chart
608630
break
609631
except ValueError:

0 commit comments

Comments
 (0)