Commit efc8cdba authored by Peter Eastman's avatar Peter Eastman
Browse files

Fixed error when retrieving a numpy array twice

parent f6c08a06
...@@ -80,11 +80,11 @@ class State(_object): ...@@ -80,11 +80,11 @@ class State(_object):
def getPeriodicBoxVectors(self, asNumpy=False): def getPeriodicBoxVectors(self, asNumpy=False):
"""Get the three periodic box vectors if this state is from a """Get the three periodic box vectors if this state is from a
simulation using PBC .""" simulation using PBC ."""
if not self._periodicBoxVectorsList: if self._periodicBoxVectorsList is None:
raise TypeError('periodic box vectors were not available.') raise TypeError('periodic box vectors were not available.')
if asNumpy: if asNumpy:
if not self._periodicBoxVectorsListNumpy: if self._periodicBoxVectorsListNumpy is None:
self._periodicBoxVectorsListNumpy = \ self._periodicBoxVectorsListNumpy = \
numpy.array(self._periodicBoxVectorsList) numpy.array(self._periodicBoxVectorsList)
returnValue=self._periodicBoxVectorsListNumpy returnValue=self._periodicBoxVectorsListNumpy
...@@ -104,11 +104,11 @@ class State(_object): ...@@ -104,11 +104,11 @@ class State(_object):
or unit.nanometer. See the following for details: or unit.nanometer. See the following for details:
https://simtk.org/home/python_units https://simtk.org/home/python_units
""" """
if not self._coordList: if self._coordList is None:
raise TypeError('Positions were not requested in getState() call, so are not available.') raise TypeError('Positions were not requested in getState() call, so are not available.')
if asNumpy: if asNumpy:
if not self._coordListNumpy: if self._coordListNumpy is None:
self._coordListNumpy=numpy.array(self._coordList) self._coordListNumpy=numpy.array(self._coordList)
returnValue=self._coordListNumpy returnValue=self._coordListNumpy
else: else:
...@@ -128,11 +128,11 @@ class State(_object): ...@@ -128,11 +128,11 @@ class State(_object):
etc. See the following for details: etc. See the following for details:
https://simtk.org/home/python_units https://simtk.org/home/python_units
""" """
if not self._velList: if self._velList is None:
raise TypeError('Velocities were not requested in getState() call, so are not available.') raise TypeError('Velocities were not requested in getState() call, so are not available.')
if asNumpy: if asNumpy:
if not self._velListNumpy: if self._velListNumpy is None:
self._velListNumpy=numpy.array(self._velList) self._velListNumpy=numpy.array(self._velList)
returnValue=self._velListNumpy returnValue=self._velListNumpy
else: else:
...@@ -153,11 +153,11 @@ class State(_object): ...@@ -153,11 +153,11 @@ class State(_object):
See the following for details: See the following for details:
https://simtk.org/home/python_units https://simtk.org/home/python_units
""" """
if not self._forceList: if self._forceList is None:
raise TypeError('Forces were not requested in getState() call, so are not available.') raise TypeError('Forces were not requested in getState() call, so are not available.')
if asNumpy: if asNumpy:
if not self._forceListNumpy: if self._forceListNumpy is None:
self._forceListNumpy=numpy.array(self._forceList) self._forceListNumpy=numpy.array(self._forceList)
returnValue=self._forceListNumpy returnValue=self._forceListNumpy
else: else:
......
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