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

Commit c89c697

Browse files
author
Matthias Koeppe
committed
Merge #32102
2 parents 1ceafd0 + 141ccb5 commit c89c697

16 files changed

+432
-216
lines changed

src/sage/manifolds/chart.py

Lines changed: 294 additions & 132 deletions
Large diffs are not rendered by default.

src/sage/manifolds/chart_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ def derivative(self, coord):
10661066
# NB: for efficiency, we access directly to the "private" attributes
10671067
# of other classes. A more conventional OOP writing would be
10681068
# coordsi = coord - self._chart.domain().start_index()
1069-
coordsi = coord - self._chart._domain._sindex
1069+
coordsi = coord - self._chart.domain()._sindex
10701070
if coordsi < 0 or coordsi >= self._nc:
10711071
raise ValueError("coordinate index out of range")
10721072
return self._der[coordsi]

src/sage/manifolds/continuous_map.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,7 @@ def image(self, subset=None, inverse=None):
837837
sage: M = Manifold(2, 'M', structure="topological")
838838
sage: N = Manifold(1, 'N', ambient=M, structure="topological")
839839
sage: CM.<x,y> = M.chart()
840-
sage: CN.<u> = N.chart()
841-
sage: CN.add_restrictions([u > -1, u < 1])
840+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
842841
sage: Phi = N.continuous_map(M, {(CN,CM): [u, u^2]}, name='Phi')
843842
sage: Phi.image()
844843
Image of the Continuous map Phi

src/sage/manifolds/continuous_map_image.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def __init__(self, map, inverse=None, name=None, latex_name=None, domain_subset=
4848
sage: M = Manifold(2, 'M', structure="topological")
4949
sage: N = Manifold(1, 'N', ambient=M, structure="topological")
5050
sage: CM.<x,y> = M.chart()
51-
sage: CN.<u> = N.chart()
52-
sage: CN.add_restrictions([u > -1, u < 1])
51+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
5352
sage: Phi = N.continuous_map(M, {(CN,CM): [u, 1 + u^2]}, name='Phi')
5453
sage: Phi_inv = M.continuous_map(N, {(CM, CN): [x]}, name='Phi_inv')
5554
sage: Phi_N = Phi.image(inverse=Phi_inv)
@@ -81,8 +80,7 @@ def _repr_(self):
8180
sage: M = Manifold(2, 'M', structure="topological")
8281
sage: N = Manifold(1, 'N', ambient=M, structure="topological")
8382
sage: CM.<x,y> = M.chart()
84-
sage: CN.<u> = N.chart()
85-
sage: CN.add_restrictions([u > -1, u < 1])
83+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
8684
sage: Phi = N.continuous_map(M, {(CN,CM): [u, 1 + u^2]}, name='Phi')
8785
sage: Phi.image() # indirect doctest
8886
Image of the Continuous map Phi
@@ -114,8 +112,7 @@ def _an_element_(self):
114112
sage: M = Manifold(2, 'M', structure="topological")
115113
sage: N = Manifold(1, 'N', ambient=M, structure="topological")
116114
sage: CM.<x,y> = M.chart()
117-
sage: CN.<u> = N.chart()
118-
sage: CN.add_restrictions([u > -1, u < 1])
115+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
119116
sage: Phi = N.continuous_map(M, {(CN,CM): [u, 1 + u^2]}, name='Phi')
120117
sage: Phi_N = Phi.image()
121118
sage: p = Phi_N.an_element(); p # indirect doctest
@@ -134,8 +131,7 @@ def __contains__(self, point):
134131
sage: M = Manifold(2, 'M', structure="topological")
135132
sage: N = Manifold(1, 'N', ambient=M, structure="topological")
136133
sage: CM.<x,y> = M.chart()
137-
sage: CN.<u> = N.chart()
138-
sage: CN.add_restrictions([u > -1, u < 1])
134+
sage: CN.<u> = N.chart(coord_restrictions=lambda u: [u > -1, u < 1])
139135
sage: Phi = N.continuous_map(M, {(CN,CM): [u, 1 + u^2]}, name='Phi')
140136
sage: Phi_inv = M.continuous_map(N, {(CM, CN): [x]}, name='Phi_inv')
141137
sage: Phi_N = Phi.image(inverse=Phi_inv)

src/sage/manifolds/differentiable/chart.py

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ class DiffChart(Chart):
7272
If no period and no LaTeX spelling are to be set for any coordinate, the
7373
argument ``coordinates`` can be omitted when the shortcut operator
7474
``<,>`` is used to declare the chart (see examples below).
75-
- ``names`` -- (default: ``None``) unused argument, except if
76-
``coordinates`` is not provided; it must then be a tuple containing
77-
the coordinate symbols (this is guaranteed if the shortcut operator
78-
``<,>`` is used).
7975
- ``calc_method`` -- (default: ``None``) string defining the calculus
8076
method for computations involving coordinates of the chart; must be
8177
one of
@@ -85,6 +81,27 @@ class DiffChart(Chart):
8581
- ``None``: the default of
8682
:class:`~sage.manifolds.calculus_method.CalculusMethod` will be
8783
used
84+
- ``names`` -- (default: ``None``) unused argument, except if
85+
``coordinates`` is not provided; it must then be a tuple containing
86+
the coordinate symbols (this is guaranteed if the shortcut operator
87+
``<,>`` is used).
88+
- ``coord_restrictions``: Additional restrictions on the coordinates.
89+
A restriction can be any symbolic equality or inequality involving
90+
the coordinates, such as ``x > y`` or ``x^2 + y^2 != 0``. The items
91+
of the list (or set or frozenset) ``coord_restrictions`` are combined
92+
with the ``and`` operator; if some restrictions are to be combined with
93+
the ``or`` operator instead, they have to be passed as a tuple in some
94+
single item of the list (or set or frozenset) ``coord_restrictions``.
95+
For example::
96+
97+
coord_restrictions=[x > y, (x != 0, y != 0), z^2 < x]
98+
99+
means ``(x > y) and ((x != 0) or (y != 0)) and (z^2 < x)``.
100+
If the list ``coord_restrictions`` contains only one item, this
101+
item can be passed as such, i.e. writing ``x > y`` instead
102+
of the single element list ``[x > y]``. If the chart variables have
103+
not been declared as variables yet, ``coord_restrictions`` must
104+
be ``lambda``-quoted.
88105
89106
EXAMPLES:
90107
@@ -259,7 +276,7 @@ class DiffChart(Chart):
259276
on differentiable manifolds over `\RR`.
260277
261278
"""
262-
def __init__(self, domain, coordinates='', names=None, calc_method=None):
279+
def __init__(self, domain, coordinates, calc_method=None, periods=None, coord_restrictions=None):
263280
r"""
264281
Construct a chart.
265282
@@ -276,8 +293,8 @@ def __init__(self, domain, coordinates='', names=None, calc_method=None):
276293
sage: TestSuite(X).run()
277294
278295
"""
279-
Chart.__init__(self, domain, coordinates=coordinates, names=names,
280-
calc_method=calc_method)
296+
super().__init__(domain, coordinates, calc_method=calc_method,
297+
periods=periods, coord_restrictions=coord_restrictions)
281298
# Construction of the coordinate frame associated to the chart:
282299
self._frame = CoordFrame(self)
283300
self._coframe = self._frame._coframe
@@ -391,8 +408,8 @@ def transition_map(self, other, transformations, intersection_name=None,
391408
[Chart (R^2, (x, y)), Chart (U, (r, phi)), Chart (U, (x, y))]
392409
393410
"""
394-
dom1 = self._domain
395-
dom2 = other._domain
411+
dom1 = self.domain()
412+
dom2 = other.domain()
396413
dom = dom1.intersection(dom2, name=intersection_name)
397414
if dom is dom1:
398415
chart1 = self
@@ -548,7 +565,7 @@ def restrict(self, subset, restrictions=None):
548565
Chart (B, (z1, z2))
549566
550567
"""
551-
if subset == self._domain:
568+
if subset == self.domain():
552569
return self
553570
if subset not in self._dom_restrict:
554571
resu = Chart.restrict(self, subset, restrictions=restrictions)
@@ -558,8 +575,8 @@ def restrict(self, subset, restrictions=None):
558575
sframe._subframes.add(resu._frame)
559576
sframe._restrictions[subset] = resu._frame
560577
# The subchart frame is not a "top frame" in the supersets
561-
# (including self._domain):
562-
for dom in self._domain.open_supersets():
578+
# (including self.domain()):
579+
for dom in self.domain().open_supersets():
563580
if resu._frame in dom._top_frames:
564581
# it was added by the Chart constructor invoked in
565582
# Chart.restrict above
@@ -709,10 +726,6 @@ class RealDiffChart(DiffChart, RealChart):
709726
If interval range, no period and no LaTeX spelling are to be set for any
710727
coordinate, the argument ``coordinates`` can be omitted when the shortcut
711728
operator ``<,>`` is used to declare the chart (see examples below).
712-
- ``names`` -- (default: ``None``) unused argument, except if
713-
``coordinates`` is not provided; it must then be a tuple containing
714-
the coordinate symbols (this is guaranteed if the shortcut operator
715-
``<,>`` is used).
716729
- ``calc_method`` -- (default: ``None``) string defining the calculus
717730
method for computations involving coordinates of the chart; must be
718731
one of
@@ -722,6 +735,27 @@ class RealDiffChart(DiffChart, RealChart):
722735
- ``None``: the default of
723736
:class:`~sage.manifolds.calculus_method.CalculusMethod` will be
724737
used
738+
- ``names`` -- (default: ``None``) unused argument, except if
739+
``coordinates`` is not provided; it must then be a tuple containing
740+
the coordinate symbols (this is guaranteed if the shortcut operator
741+
``<,>`` is used).
742+
- ``coord_restrictions``: Additional restrictions on the coordinates.
743+
A restriction can be any symbolic equality or inequality involving
744+
the coordinates, such as ``x > y`` or ``x^2 + y^2 != 0``. The items
745+
of the list (or set or frozenset) ``coord_restrictions`` are combined
746+
with the ``and`` operator; if some restrictions are to be combined with
747+
the ``or`` operator instead, they have to be passed as a tuple in some
748+
single item of the list (or set or frozenset) ``coord_restrictions``.
749+
For example::
750+
751+
coord_restrictions=[x > y, (x != 0, y != 0), z^2 < x]
752+
753+
means ``(x > y) and ((x != 0) or (y != 0)) and (z^2 < x)``.
754+
If the list ``coord_restrictions`` contains only one item, this
755+
item can be passed as such, i.e. writing ``x > y`` instead
756+
of the single element list ``[x > y]``. If the chart variables have
757+
not been declared as variables yet, ``coord_restrictions`` must
758+
be ``lambda``-quoted.
725759
726760
EXAMPLES:
727761
@@ -908,9 +942,9 @@ class RealDiffChart(DiffChart, RealChart):
908942
`\{y=0, x\geq 0\}`, we must have `y\not=0` or `x<0` on U. Accordingly,
909943
we set::
910944
911-
sage: c_cartU.<x,y,z> = U.chart()
912-
sage: c_cartU.add_restrictions((y!=0, x<0)) # the tuple (y!=0, x<0) means y!=0 or x<0
913-
sage: # c_cartU.add_restrictions([y!=0, x<0]) would have meant y!=0 AND x<0
945+
sage: c_cartU.<x,y,z> = U.chart(coord_restrictions=lambda x,y,z: (y!=0, x<0))
946+
....: # the tuple (y!=0, x<0) means y!=0 or x<0
947+
....: # [y!=0, x<0] would have meant y!=0 AND x<0
914948
sage: U.atlas()
915949
[Chart (U, (r, th, ph)), Chart (U, (x, y, z))]
916950
sage: M.atlas()
@@ -942,7 +976,8 @@ class RealDiffChart(DiffChart, RealChart):
942976
:meth:`~sage.manifolds.chart.RealChart.plot`.
943977
944978
"""
945-
def __init__(self, domain, coordinates='', names=None, calc_method=None):
979+
def __init__(self, domain, coordinates, calc_method=None,
980+
bounds=None, periods=None, coord_restrictions=None):
946981
r"""
947982
Construct a chart on a real differentiable manifold.
948983
@@ -960,8 +995,8 @@ def __init__(self, domain, coordinates='', names=None, calc_method=None):
960995
sage: TestSuite(X).run()
961996
962997
"""
963-
RealChart.__init__(self, domain, coordinates=coordinates, names=names,
964-
calc_method = calc_method)
998+
RealChart.__init__(self, domain, coordinates, calc_method=calc_method,
999+
bounds=bounds, periods=periods, coord_restrictions=coord_restrictions)
9651000
# Construction of the coordinate frame associated to the chart:
9661001
self._frame = CoordFrame(self)
9671002
self._coframe = self._frame._coframe
@@ -1031,7 +1066,7 @@ def restrict(self, subset, restrictions=None):
10311066
True
10321067
10331068
"""
1034-
if subset == self._domain:
1069+
if subset == self.domain():
10351070
return self
10361071
if subset not in self._dom_restrict:
10371072
resu = RealChart.restrict(self, subset, restrictions=restrictions)
@@ -1041,8 +1076,8 @@ def restrict(self, subset, restrictions=None):
10411076
sframe._subframes.add(resu._frame)
10421077
sframe._restrictions[subset] = resu._frame
10431078
# The subchart frame is not a "top frame" in the supersets
1044-
# (including self._domain):
1045-
for dom in self._domain.open_supersets():
1079+
# (including self.domain()):
1080+
for dom in self.domain().open_supersets():
10461081
if resu._frame in dom._top_frames:
10471082
# it was added by the Chart constructor invoked in
10481083
# Chart.restrict above
@@ -1125,8 +1160,8 @@ def __init__(self, chart1, chart2, *transformations):
11251160
self._jacobian = self._transf.jacobian()
11261161
# If the two charts are on the same open subset, the Jacobian matrix is
11271162
# added to the dictionary of changes of frame:
1128-
if chart1._domain == chart2._domain:
1129-
domain = chart1._domain
1163+
if chart1.domain() == chart2.domain():
1164+
domain = chart1.domain()
11301165
frame1 = chart1._frame
11311166
frame2 = chart2._frame
11321167
vf_module = domain.vector_field_module()

src/sage/manifolds/differentiable/diff_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,9 @@ def paral_comp(tcomp, chart1, chart2, coord2_1, jacob,
10801080
coord1 = chart1._xx
10811081
ff = tensor._express[chart2]
10821082
resu_fc.append( chart1.function(ff(*(phi(*coord1)))) )
1083-
dom_resu = resu_fc[0].parent()._chart._domain
1083+
dom_resu = resu_fc[0].parent()._chart.domain()
10841084
for fc in resu_fc[1:]:
1085-
dom_resu = dom_resu.union(fc.parent()._chart._domain)
1085+
dom_resu = dom_resu.union(fc.parent()._chart.domain())
10861086
resu = dom_resu.scalar_field(name=resu_name,
10871087
latex_name=resu_latex_name)
10881088
for fc in resu_fc:

src/sage/manifolds/differentiable/examples/real_line.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ def __init__(self, lower, upper, ambient_interval=None,
368368
coordinate = 't'
369369
else:
370370
coordinate = names[0]
371-
self._canon_chart = self.chart(coordinates=coordinate)
372-
t = self._canon_chart[start_index]
373371
else:
374372
if lower < ambient_interval.lower_bound():
375373
raise ValueError("the lower bound is smaller than that of "
@@ -379,20 +377,19 @@ def __init__(self, lower, upper, ambient_interval=None,
379377
+ "the containing interval")
380378
self.declare_subset(ambient_interval)
381379
ambient_interval._top_subsets.add(self)
382-
t = ambient_interval.canonical_coordinate()
383380
if lower != minus_infinity:
384381
if upper != infinity:
385-
restrictions = [t > lower, t < upper]
382+
restrictions = lambda t: [t > lower, t < upper]
386383
else:
387-
restrictions = t > lower
384+
restrictions = lambda t: t > lower
388385
else:
389386
if upper != infinity:
390-
restrictions = t < upper
387+
restrictions = lambda t: t < upper
391388
else:
392389
restrictions = None
393390
if ambient_interval is None:
394-
if restrictions is not None:
395-
self._canon_chart.add_restrictions(restrictions)
391+
self._canon_chart = self.chart(coordinates=coordinate,
392+
coord_restrictions=restrictions)
396393
else:
397394
self._canon_chart = ambient_interval.canonical_chart().restrict(self,
398395
restrictions=restrictions)

src/sage/manifolds/differentiable/integrated_curve.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,17 +1469,13 @@ def solve_across_charts(self, charts=None, step=None, solution_key=None,
14691469
maps::
14701470
14711471
sage: M = Manifold(2, 'M', structure="Riemannian")
1472-
sage: C.<x,y> = M.chart()
1473-
sage: P.<r,th> = M.chart()
1472+
sage: C.<x,y> = M.chart(coord_restrictions=lambda x,y: x**2+y**2 < 3**2)
1473+
sage: P.<r,th> = M.chart(coord_restrictions=lambda r, th: r > 2)
14741474
sage: P_to_C = P.transition_map(C,(r*cos(th), r*sin(th)))
14751475
sage: C_to_P = C.transition_map(P,(sqrt(x**2+y**2), atan2(y,x)))
14761476
1477-
Let us also add restrictions on those charts, to avoid any
1478-
singularity. We have to make sure that the charts still intersect.
1479-
Here the intersection is the donut region `2 < r < 3`::
1480-
1481-
sage: P.add_restrictions(r > 2)
1482-
sage: C.add_restrictions(x**2+y**2 < 3**2)
1477+
Here we added restrictions on those charts, to avoid any
1478+
singularity. The intersection is the donut region `2 < r < 3`.
14831479
14841480
We still have to define the metric. This is done in the Cartesian
14851481
frame. The metric in the polar frame is computed automatically::
@@ -1574,14 +1570,12 @@ def solve_across_charts(self, charts=None, step=None, solution_key=None,
15741570
.. PLOT::
15751571
15761572
M = Manifold(2, 'M', structure="Riemannian")
1577-
C= M.chart(names = ("x", "y"))
1573+
C= M.chart(names = ("x", "y"), coord_restrictions=lambda x,y: x**2+y**2 < 3**2)
15781574
x, y = C[:]
1579-
P = M.chart(names = ("r", "ph"))
1575+
P = M.chart(names = ("r", "th"), coord_restrictions=lambda r,th: r > 2)
15801576
r, th = P[:]
15811577
P_to_C = P.transition_map(C,(r*cos(th), r*sin(th)))
15821578
C_to_P = C.transition_map(P,(sqrt(x**2+y**2), atan2(y,x)))
1583-
P.add_restrictions(r > 2)
1584-
C.add_restrictions(x**2+y**2 < 3**2)
15851579
g = M.metric()
15861580
g[0,0,C] = 1
15871581
g[1,1,C] = 1

src/sage/manifolds/differentiable/levi_civita_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,8 @@ def riemann(self, name=None, latex_name=None):
628628
metric of the hyperbolic plane (Poincaré disk model)::
629629
630630
sage: M = Manifold(2, 'M', start_index=1)
631-
sage: X.<x,y> = M.chart('x:(-1,1) y:(-1,1)') # Cartesian coord. on the Poincaré disk
632-
sage: X.add_restrictions(x^2+y^2<1)
631+
sage: X.<x,y> = M.chart('x:(-1,1) y:(-1,1)', coord_restrictions=lambda x,y: x^2+y^2<1)
632+
....: # Cartesian coord. on the Poincaré disk
633633
sage: g = M.metric('g')
634634
sage: g[1,1], g[2,2] = 4/(1-x^2-y^2)^2, 4/(1-x^2-y^2)^2
635635
sage: nab = g.connection()

src/sage/manifolds/differentiable/manifold.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,8 @@ def diffeomorphism(self, codomain=None, coord_functions=None, chart1=None,
10171017
10181018
sage: M = Manifold(2, 'M') # the open unit disk
10191019
sage: forget() # for doctests only
1020-
sage: c_xy.<x,y> = M.chart('x:(-1,1) y:(-1,1)') # Cartesian coord on M
1021-
sage: c_xy.add_restrictions(x^2+y^2<1)
1020+
sage: c_xy.<x,y> = M.chart('x:(-1,1) y:(-1,1)', coord_restrictions=lambda x,y: x^2+y^2<1)
1021+
....: # Cartesian coord on M
10221022
sage: N = Manifold(2, 'N') # R^2
10231023
sage: c_XY.<X,Y> = N.chart() # canonical coordinates on R^2
10241024
sage: Phi = M.diffeomorphism(N, [x/sqrt(1-x^2-y^2), y/sqrt(1-x^2-y^2)],

0 commit comments

Comments
 (0)