"platforms/vscode:/vscode.git/clone" did not exist on "344805a8a17351ef4cef719b9c4944bef8f8d733"
Commit 4340498f authored by peastman's avatar peastman
Browse files

Merge pull request #750 from swails/fix_unit

Fix small bug in `simtk.unit` related to mutable sequences.
parents 11e5dc73 f8a101d7
...@@ -356,7 +356,7 @@ class Quantity(object): ...@@ -356,7 +356,7 @@ class Quantity(object):
if unit.is_dimensionless(): if unit.is_dimensionless():
assert unit is dimensionless # should have been set earlier in this method assert unit is dimensionless # should have been set earlier in this method
if is_quantity(result): if is_quantity(result):
result = result._value result = copy.deepcopy(result._value)
return result return result
def __mul__(self, other): def __mul__(self, other):
...@@ -506,7 +506,7 @@ class Quantity(object): ...@@ -506,7 +506,7 @@ class Quantity(object):
except AttributeError: except AttributeError:
if args or kwargs: if args or kwargs:
raise TypeError('Unsupported arguments for Quantity.mean') raise TypeError('Unsupported arguments for Quantity.mean')
mean = self.sum() / len(self._value) mean = (self.sum() / len(self._value))._value
return Quantity(mean, self.unit) return Quantity(mean, self.unit)
def std(self, *args, **kwargs): def std(self, *args, **kwargs):
...@@ -526,7 +526,8 @@ class Quantity(object): ...@@ -526,7 +526,8 @@ class Quantity(object):
except AttributeError: except AttributeError:
if args or kwargs: if args or kwargs:
raise TypeError('Unsupported arguments for Quantity.std') raise TypeError('Unsupported arguments for Quantity.std')
mean = self.mean() mean = self.mean()._value
var = 0
for val in self._value: for val in self._value:
res = mean - val res = mean - val
var += res * res var += res * res
......
This diff is collapsed.
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