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

Commit 923196a

Browse files
committed
#31923: initialize the inverse of the inverse to self
1 parent 30ee8d6 commit 923196a

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/sage/manifolds/chart.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,7 +3123,11 @@ def __call__(self, *coords):
31233123

31243124
def inverse(self):
31253125
r"""
3126-
Compute the inverse coordinate transformation.
3126+
Return the inverse coordinate transformation.
3127+
3128+
If the inverse is not already known, it is computed here. If the
3129+
computation fails, the inverse can be set by hand via the method
3130+
:meth:`set_inverse`.
31273131
31283132
OUTPUT:
31293133
@@ -3156,6 +3160,16 @@ def inverse(self):
31563160
(Chart (M, (x, y)),
31573161
Chart (M, (u, v))): Change of coordinates from Chart (M, (x, y)) to Chart (M, (u, v))}
31583162
3163+
The result is cached::
3164+
3165+
sage: xy_to_uv.inverse() is uv_to_xy
3166+
True
3167+
3168+
We have as well::
3169+
3170+
sage: uv_to_xy.inverse() is xy_to_uv
3171+
True
3172+
31593173
"""
31603174
from sage.symbolic.relation import solve
31613175
from sage.symbolic.assumptions import assumptions
@@ -3236,6 +3250,7 @@ def inverse(self):
32363250
"manually")
32373251
x2_to_x1 = list_x2_to_x1[0]
32383252
self._inverse = type(self)(self._chart2, self._chart1, *x2_to_x1)
3253+
self._inverse._inverse = self
32393254
# Some cleaning: the local symbolic variables (xxxx0, xxxx1, ...) are
32403255
# removed from the list of assumptions
32413256
for asm in assumptions():
@@ -3338,7 +3353,14 @@ def set_inverse(self, *transformations, **kwds):
33383353
u == u *passed*
33393354
v == v *passed*
33403355
3341-
TESTS::
3356+
TESTS:
3357+
3358+
Check that :trac:`31923` is fixed::
3359+
3360+
sage: X1_to_X2.inverse().inverse() is X1_to_X2
3361+
True
3362+
3363+
Check of keyword arguments::
33423364
33433365
sage: X1_to_X2.set_inverse((u+v)/2, (u-v)/2, bla=3)
33443366
Traceback (most recent call last):
@@ -3353,6 +3375,7 @@ def set_inverse(self, *transformations, **kwds):
33533375
"argument".format(unknown_key))
33543376
self._inverse = type(self)(self._chart2, self._chart1,
33553377
*transformations)
3378+
self._inverse._inverse = self
33563379
if check:
33573380
infos = ["Check of the inverse coordinate transformation:"]
33583381
x1 = self._chart1._xx

0 commit comments

Comments
 (0)