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

Commit efd8e03

Browse files
author
Michael Jung
committed
Mixed form zero treatment
1 parent c104fc8 commit efd8e03

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/sage/manifolds/differentiable/mixed_form.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ class MixedForm(AlgebraElement):
181181
sage: F.disp(e_xy)
182182
F = [x] + [x*y dx] + [(-2*x^3 + 2*x^2*y + 2*x*y^2 - 2*y^3) dx/\dy]
183183
184+
Since zero and one are special elements, their components cannot be
185+
changed::
186+
187+
sage: z = M.mixed_form_algebra().zero()
188+
sage: z[0] = 1
189+
Traceback (most recent call last):
190+
...
191+
AssertionError: the components of the element zero cannot be changed
192+
sage: one = M.mixed_form_algebra().one()
193+
sage: one[0] = 0
194+
Traceback (most recent call last):
195+
...
196+
AssertionError: the components of the element one cannot be changed
197+
184198
"""
185199
def __init__(self, parent, comp=None, name=None, latex_name=None):
186200
r"""
@@ -1067,6 +1081,9 @@ def __setitem__(self, index, values):
10671081
A = [x] + [y dx] + [x*y dx/\dy]
10681082
10691083
"""
1084+
if self is self.parent().one() or self is self.parent().zero():
1085+
raise AssertionError("the components of the element "
1086+
"{} cannot be changed".format(self._name))
10701087
if isinstance(index, (int, Integer)):
10711088
start = index
10721089
stop = index + 1

0 commit comments

Comments
 (0)