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

Commit b7b0b3f

Browse files
author
Michael Jung
committed
return copies
1 parent 4f3b69f commit b7b0b3f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/sage/manifolds/scalarfield.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,9 +2452,9 @@ def _add_(self, other):
24522452
"""
24532453
# Trivial cases:
24542454
if self.is_trivial_zero():
2455-
return other
2455+
return other.copy(other._name, other._latex_name)
24562456
if other.is_trivial_zero():
2457-
return self
2457+
return self.copy(self._name, self._latex_name)
24582458
# Generic case:
24592459
com_charts = self.common_charts(other)
24602460
if com_charts is None:
@@ -2503,9 +2503,10 @@ def _sub_(self, other):
25032503
if self.is_trivial_zero():
25042504
return -other
25052505
if other.is_trivial_zero():
2506-
return self
2506+
return self.copy(self._name, self._latex_name)
25072507
if self is other:
2508-
return self.parent().zero()
2508+
zero = self.parent().zero()
2509+
return zero.copy(zero._name, zero._latex_name)
25092510
# Generic case:
25102511
com_charts = self.common_charts(other)
25112512
if com_charts is None:
@@ -2554,11 +2555,12 @@ def _mul_(self, other):
25542555
"""
25552556
# Trivial cases:
25562557
if self.is_trivial_zero() or other.is_trivial_zero():
2557-
return self._domain.zero_scalar_field()
2558+
zero = self._domain.zero_scalar_field()
2559+
return zero.copy(zero._name, zero._latex_name)
25582560
if (self - 1).is_trivial_zero():
2559-
return other
2561+
return other.copy(other._name, other._latex_name)
25602562
if (other - 1).is_trivial_zero():
2561-
return self
2563+
return self.copy(self._name, self._latex_name)
25622564
# Generic case:
25632565
from sage.tensor.modules.format_utilities import (format_mul_txt,
25642566
format_mul_latex)
@@ -2612,7 +2614,8 @@ def _div_(self, other):
26122614
if other.is_trivial_zero():
26132615
raise ZeroDivisionError("division of a scalar field by zero")
26142616
if self.is_trivial_zero():
2615-
return self._domain.zero_scalar_field()
2617+
zero = self._domain.zero_scalar_field()
2618+
return zero.copy(zero._name, zero._latex_name)
26162619
# Generic case:
26172620
com_charts = self.common_charts(other)
26182621
if com_charts is None:
@@ -2676,15 +2679,17 @@ def _lmul_(self, number):
26762679
# Trivial cases:
26772680
try:
26782681
if number.is_trivial_zero():
2679-
return self.parent().zero()
2682+
zero = self.parent().zero()
2683+
return zero.copy(zero._name, zero._latex_name)
26802684
if (number - 1).is_trivial_zero():
2681-
return self
2685+
return self.copy(self._name, self._latex_name)
26822686
except AttributeError:
26832687
# in case base ring is not SR:
26842688
if number == 0:
2685-
return self.parent().zero()
2689+
zero = self.parent().zero()
2690+
return zero.copy(zero._name, zero._latex_name)
26862691
if number == 1:
2687-
return self
2692+
return self.copy(self._name, self._latex_name)
26882693
# Generic case:
26892694
result = type(self)(self.parent())
26902695
if isinstance(number, Expression):

0 commit comments

Comments
 (0)