"platforms/brook/src/kernels/kcommon.br" did not exist on "170e493aa46b53b0afcfa9b1bd56f0c0dfbe8a14"
Commit 019f5026 authored by Jason Swails's avatar Jason Swails
Browse files

Add missing arg check. Implement "reshape" in Quantity that passes down to the

underlying numpy array. This function would be used in instances where, for
instance, a certain API would send a flattened array of coordinates or
velocities with units attached, and you wanted to reshape the array into
(natom, 3) to be consistent with OpenMM's Context object.
parent dc8b4038
......@@ -561,9 +561,22 @@ class Quantity(object):
# Faster for numpy arrays
mymin = self._value.min(*args, **kwargs)
except AttributeError:
if args or kwargs:
raise TypeError('Unsupported arguments for Quantity.min')
mymin = min(self._value)
return Quantity(mymin, self.unit)
def reshape(self, shape, order='C'):
"""
Same as numpy.ndarray.reshape, except the result is a Quantity with the
same units as the current object rather than a plain numpy.ndarray
"""
try:
return Quantity(self._value.reshape(shape, order=order))
except AttributeError:
raise AttributeError('Only numpy array Quantity objects can be '
'reshaped')
def __abs__(self):
"""
Return absolute value of a Quantity.
......
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