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), where n is the number of particles and k is the number of frames.

Parameters:
  • pos_array (array_like) – The array to check.

  • shape (tuple, optional) – The shape expected for pos_array. Default is None, 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 is None, which means that the dimension of pos_array is not checked.

  • amin (scalar or array_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 or array_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 is None, which means that the data type of pos_array is not checked.

Returns:

pos_array (numpy.ndarray) – The input array as numpy.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 not None and the length of shape is neither one, two or three; dim is not None and neither one, two or three. See mdtools.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