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

Commit 2783253

Browse files
committed
Minor changes in the zero and one treatment of tensor fields
1 parent a91dba0 commit 2783253

File tree

12 files changed

+32
-47
lines changed

12 files changed

+32
-47
lines changed

src/sage/manifolds/differentiable/diff_form.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ def wedge(self, other):
529529
dest_map = self._vmodule._dest_map
530530
dest_map_resu = dest_map.restrict(dom_resu,
531531
subcodomain=ambient_dom_resu)
532-
###
533532
# Facilitate computations involving zero:
534533
if resu_degree > ambient_dom_resu._dim:
535534
return dom_resu.diff_form_module(resu_degree,
@@ -540,7 +539,6 @@ def wedge(self, other):
540539
if self is other and (self._tensor_rank % 2) == 1:
541540
return dom_resu.diff_form_module(resu_degree,
542541
dest_map=dest_map_resu).zero()
543-
###
544542
# Generic case:
545543
self_r = self.restrict(dom_resu)
546544
other_r = other.restrict(dom_resu)

src/sage/manifolds/differentiable/mixed_form.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ class MixedForm(AlgebraElement):
3535
`\varphi: M \to N` between two differentiable manifolds `M` and `N`. More
3636
precisely, a mixed form `a` along `\varphi: M \to N` can be considered as a
3737
differentiable map
38-
38+
3939
.. MATH::
4040
4141
a: M \longrightarrow \bigoplus^n_{k=0} T^{(0,k)}N,
42-
42+
4343
where `T^{(0,k)}` denotes the tensor bundle of type `(0,k)`, `\bigoplus`
4444
the Whitney sum and `n` the dimension of `N`, such that
45-
45+
4646
.. MATH::
4747
4848
\forall x\in M, \quad a(x) \in \bigoplus^n_{k=0} \Lambda^k\left( T_{\varphi(x)}^* N \right),
49-
49+
5050
where `\Lambda^k(T^*_{\varphi(x)} N)` is the `k`-th exterior power of the
5151
dual of the tangent space `T_{\varphi(x)} N`.
5252
@@ -656,13 +656,11 @@ def _add_(self, other):
656656
True
657657
658658
"""
659-
###
660659
# Case zero:
661660
if self._is_zero:
662661
return other
663662
if other._is_zero:
664663
return self
665-
###
666664
# Generic case:
667665
resu_comp = [self[j] + other[j]
668666
for j in range(self._max_deg + 1)]
@@ -730,13 +728,11 @@ def _sub_(self, other):
730728
True
731729
732730
"""
733-
###
734731
# Case zero:
735732
if self._is_zero:
736733
return -other
737734
if other._is_zero:
738735
return self
739-
###
740736
# Generic case:
741737
resu_comp = [self[j] - other[j]
742738
for j in range(self._max_deg + 1)]
@@ -851,17 +847,14 @@ def wedge(self, other):
851847
A/\eta = [0] + [x*y dy] + [x*y dx/\dy] + [-y*z dx/\dy/\dz]
852848
853849
"""
854-
###
855850
# Case zero:
856851
if self._is_zero or other._is_zero:
857852
return self.parent().zero()
858-
###
859853
# Case one:
860854
if self is self.parent().one():
861855
return other
862856
if other is self.parent().one():
863857
return self
864-
###
865858
# Generic case:
866859
resu_comp = [None] * (self._max_deg + 1)
867860
resu_comp[0] = self[0] * other[0]
@@ -941,7 +934,7 @@ def exterior_derivative(self):
941934
`\Omega^*(M,\varphi)`:
942935
943936
.. MATH::
944-
937+
945938
\mathrm{d}: \Omega^*(M,\varphi) \to \Omega^*(M,\varphi).
946939
947940
OUTPUT:

src/sage/manifolds/differentiable/multivector_module.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ def zero(self):
390390
manifold M
391391
392392
"""
393-
zero = self.element_class(self._vmodule, self._degree,
394-
name='zero', latex_name='0')
395393
zero = self._element_constructor_(name='zero', latex_name='0')
396394
for frame in self._domain._frames:
397395
if self._dest_map.restrict(frame._domain) == frame._dest_map:

src/sage/manifolds/differentiable/tangent_space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def __init__(self, point):
245245
if frame is frame2:
246246
basis = basis2
247247
if basis is not None:
248-
cauto = auto.add_comp(basis)
248+
cauto = auto.add_comp(basis=basis)
249249
for ind, val in comp._comp.items():
250250
cauto._comp[ind] = val(point)
251251
except ValueError:

src/sage/manifolds/differentiable/tensorfield.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ def set_comp(self, basis=None):
12131213
basis = self._domain._def_frame
12141214
self._del_derived() # deletes the derived quantities
12151215
rst = self.restrict(basis._domain, dest_map=basis._dest_map)
1216-
return rst.set_comp(basis)
1216+
return rst.set_comp(basis=basis)
12171217

12181218
def _add_comp_unsafe(self, basis=None):
12191219
r"""
@@ -1342,7 +1342,7 @@ def add_comp(self, basis=None):
13421342
basis = self._domain._def_frame
13431343
self._del_derived() # deletes the derived quantities
13441344
rst = self.restrict(basis._domain, dest_map=basis._dest_map)
1345-
return rst.add_comp(basis)
1345+
return rst.add_comp(basis=basis)
13461346

13471347
def add_comp_by_continuation(self, frame, subdomain, chart=None):
13481348
r"""
@@ -2294,13 +2294,11 @@ def _add_(self, other):
22942294
True
22952295
22962296
"""
2297-
###
22982297
# Case zero:
22992298
if self._is_zero:
23002299
return other
23012300
if other._is_zero:
23022301
return self
2303-
###
23042302
# Generic case:
23052303
resu_rst = {}
23062304
for dom in self._common_subdomains(other):
@@ -2365,13 +2363,11 @@ def _sub_(self, other):
23652363
True
23662364
23672365
"""
2368-
###
23692366
# Case zero:
23702367
if self._is_zero:
23712368
return -other
23722369
if other._is_zero:
23732370
return self
2374-
###
23752371
# Generic case:
23762372
resu_rst = {}
23772373
for dom in self._common_subdomains(other):
@@ -2446,15 +2442,12 @@ def _rmul_(self, scalar):
24462442
True
24472443
24482444
"""
2449-
###
24502445
# Case zero:
24512446
if scalar._is_zero:
24522447
return self.parent().zero()
2453-
###
24542448
# Case one:
24552449
if scalar is self._domain._one_scalar_field:
24562450
return self
2457-
###
24582451
# Generic case:
24592452
resu = self._new_instance()
24602453
for dom, rst in self._restrictions.items():

src/sage/manifolds/differentiable/tensorfield_paral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ class :class:`~sage.tensor.modules.comp.Components`; if such
900900
# deleted by _del_derived):
901901
self._restrictions[basis._domain] = rst
902902
# The set_comp operation is performed on the subdomain:
903-
return rst.set_comp(basis)
903+
return rst.set_comp(basis=basis)
904904

905905
def _add_comp_unsafe(self, basis=None):
906906
r"""
@@ -1077,7 +1077,7 @@ class :class:`~sage.tensor.modules.comp.Components`; if such
10771077
# subdomains:
10781078
self._del_derived(del_restrictions=False)
10791079
# The add_comp operation is performed on the subdomain:
1080-
return rst.add_comp(basis)
1080+
return rst.add_comp(basis=basis)
10811081

10821082
def comp(self, basis=None, from_basis=None):
10831083
r"""

src/sage/manifolds/differentiable/vectorfield_module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,7 @@ def _element_constructor_(self, comp=[], basis=None, name=None,
14471447
"to a vector field in {}".format(self))
14481448
resu = self.element_class(self, name=name, latex_name=latex_name)
14491449
if comp != []:
1450-
resu.set_comp(basis)[:] = comp
1450+
resu.set_comp(basis=basis)[:] = comp
14511451
return resu
14521452

14531453
# Rem: _an_element_ is declared in the superclass FiniteRankFreeModule

src/sage/manifolds/differentiable/vectorframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def __init__(self, vector_field_module, symbol, latex_symbol=None,
710710
xsd = sd._vector_field_modules[dest_map]
711711
if not isinstance(xsd, FiniteRankFreeModule):
712712
for t in xsd._tensor_modules.values():
713-
t(0)._add_comp_unsafe(self)
713+
t.zero()._add_comp_unsafe(self)
714714
# (since new components are initialized to zero)
715715
if dest_map is self._domain.identity_map():
716716
# The frame is added to the list of the domain's covering frames:

src/sage/manifolds/scalarfield.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,23 +1673,23 @@ def set_expr(self, coord_expression, chart=None):
16731673
sage: f._express # the (u,v) expression has been lost:
16741674
{Chart (M, (x, y)): 3*y}
16751675
1676-
Since zero and one are special elements, their components cannot be
1676+
Since zero and one are special elements, their expressions cannot be
16771677
changed::
16781678
16791679
sage: z = M.zero_scalar_field()
16801680
sage: z.set_expr(3*y)
16811681
Traceback (most recent call last):
16821682
...
1683-
AssertionError: the components of the element zero cannot be changed
1683+
AssertionError: the expressions of the element zero cannot be changed
16841684
sage: one = M.one_scalar_field()
16851685
sage: one.set_expr(3*y)
16861686
Traceback (most recent call last):
16871687
...
1688-
AssertionError: the components of the element 1 cannot be changed
1688+
AssertionError: the expressions of the element 1 cannot be changed
16891689
16901690
"""
16911691
if self is self.parent().one() or self is self.parent().zero():
1692-
raise AssertionError("the components of the element "
1692+
raise AssertionError("the expressions of the element "
16931693
"{} cannot be changed".format(self._name))
16941694
if chart is None:
16951695
chart = self._domain._def_chart
@@ -1735,23 +1735,23 @@ def add_expr(self, coord_expression, chart=None):
17351735
sage: f._express # random (dict. output); f has now 2 expressions:
17361736
{Chart (M, (x, y)): 3*y, Chart (M, (u, v)): cos(u) - sin(v)}
17371737
1738-
Since zero and one are special elements, their components cannot be
1738+
Since zero and one are special elements, their expressions cannot be
17391739
changed::
17401740
17411741
sage: z = M.zero_scalar_field()
17421742
sage: z.add_expr(cos(u)-sin(v), c_uv)
17431743
Traceback (most recent call last):
17441744
...
1745-
AssertionError: the components of the element zero cannot be changed
1745+
AssertionError: the expressions of the element zero cannot be changed
17461746
sage: one = M.one_scalar_field()
17471747
sage: one.add_expr(cos(u)-sin(v), c_uv)
17481748
Traceback (most recent call last):
17491749
...
1750-
AssertionError: the components of the element 1 cannot be changed
1750+
AssertionError: the expressions of the element 1 cannot be changed
17511751
17521752
"""
17531753
if self is self.parent().one() or self is self.parent().zero():
1754-
raise AssertionError("the components of the element "
1754+
raise AssertionError("the expressions of the element "
17551755
"{} cannot be changed".format(self._name))
17561756
if chart is None:
17571757
chart = self._domain._def_chart

src/sage/tensor/modules/free_module_alt_form.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,13 @@ def wedge(self, other):
614614
return self * other
615615
fmodule = self._fmodule
616616
rank_r = self._tensor_rank + other._tensor_rank
617-
###
618617
# Facilitate computations involving zero:
619618
if rank_r > fmodule._rank:
620619
return fmodule.dual_exterior_power(rank_r).zero()
621620
if self._is_zero or other._is_zero:
622621
return fmodule.dual_exterior_power(rank_r).zero()
623622
if self is other and (self._tensor_rank % 2) == 1:
624623
return fmodule.dual_exterior_power(rank_r).zero()
625-
###
626624
# Generic case:
627625
basis = self.common_basis(other)
628626
if basis is None:

0 commit comments

Comments
 (0)