dtrj

mdtools.check.dtrj(dtrj, shape=None, amin=None, amax=None, dtype=None)[source]

Check if the input array satisfies the conditions for a discrete trajectory.

Arrays that serve as discrete trajectory 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 (f,) or (n, f), where n is the number of compounds and f is the number of frames. Transposed discrete trajectories of shape (f, n) are also valid.

  • Must contain only integers or floats whose fractional part is zero, because the elements of a discrete trajectory are interpreted as the indices of the states in which a given compound is at a given frame.

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

  • shape (tuple, optional) – The shape expected for dtrj. Default is None, which means that the shape of dtrj is not checked. If provided, the length of shape must be two.

  • amin (scalar or array_like) – Minimum values that the elements of dtrj must not undermine. If amin and dtrj 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 dtrj must not exceed. If amax and dtrj 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 dtrj. The default is None, which means that the data type of dtrj is not checked.

Returns:

dtrj (numpy.ndarray) – The input array as numpy.ndarray with two dimensions and in row-major order (C-style memory layout). No copy is performed if the input is already a 2-dimensional numpy.ndarray with matching order.

Raises:

ValueError – If dtrj has more than two dimensions; Any element of dtrj is not an integer. Or if shape is not None and the length of shape is not two. See mdtools.check.array() for further potentially raised exceptions.

See also

mdtools.check.array()

Check if an array meets given requirements

Notes

If the input array has only shape (f,), it is expanded to shape (1, f). Hence, the output array will always have two dimensions.