pos_array
- mdtools.check.pos_array(pos_array, shape=None, dim=None, amin=None, amax=None, dtype=None)[source]
Check if the input array satisfies the conditions for a position array.
Arrays that contain positions (spatial coordinates) of particles must meet the following requirements:
Must be of an array_like type, i.e. a type that can be converted to a
numpy.ndarray
.Must be of shape
(3,)
or(n, 3)
or(k, n, 3)
, wheren
is the number of particles andk
is the number of frames.
- Parameters:
pos_array (
array_like
) – The array to check.shape (
tuple
, optional) – The shape expected for pos_array. Default isNone
, which means that the shape of pos_array is not checked. If provided, the length of shape must be either one, two or three and the last element of shape must be 3.dim (
{None, 1, 2, 3}
, optional) – The dimension expected for pos_array. Default isNone
, which means that the dimension of pos_array is not checked.amin (
scalar
orarray_like
) – Minimum values that the elements of pos_array must not undermine. If amin and pos_array do not have the same shape, they must be broadcastable to a common shape.amax (
scalar
orarray_like
) – Maximum values that the elements of pos_array must not exceed. If amax and pos_array do not have the same shape, they must be broadcastable to a common shape. amax must be greater than amin.dtype (
type
, optional) – The data type expected for pos_array. The default isNone
, which means that the data type of pos_array is not checked.
- Returns:
pos_array (
numpy.ndarray
) – The input array asnumpy.ndarray
.- Raises:
ValueError – If the last dimension of pos_array is not of shape
(3,)
; The dimension of pos_array is neither one, two or three. Or if shape is notNone
and the length of shape is neither one, two or three; dim is notNone
and neither one, two or three. Seemdtools.check.array()
for further potentially raised exceptions.
See also
mdtools.check.array()
Check if an array meets given requirements
mdtools.check.box()
Check if an array is a suitable simulation box array