"vscode:/vscode.git/clone" did not exist on "48e40f63f92614f72267933cd5cdf7906a692382"
Commit 68411b8d authored by peastman's avatar peastman
Browse files

Merge pull request #656 from peastman/sum

Fixed bug in Quantity.sum()
parents 05030307 9184c372
...@@ -467,7 +467,12 @@ class Quantity(object): ...@@ -467,7 +467,12 @@ class Quantity(object):
# This will be much faster for numpy arrays # This will be much faster for numpy arrays
mysum = self._value.sum() mysum = self._value.sum()
except AttributeError: except AttributeError:
mysum = sum(self._value) if len(self._value) == 0:
mysum = 0
else:
mysum = self._value[0]
for i in range(1, len(self._value)):
mysum += self._value[i]
return Quantity(mysum, self.unit) return Quantity(mysum, self.unit)
def mean(self): def mean(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment