Commit 9184c372 authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed bug in Quantity.sum()

parent f96c8313
......@@ -467,7 +467,12 @@ class Quantity(object):
# This will be much faster for numpy arrays
mysum = self._value.sum()
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)
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