list_of_cms
- mdtools.check.list_of_cms(cms, shape=None, dim=None, amin=None, amax=None, dtype=None)[source]
Check if the input is a sequence of contact matrices (or arrays).
A sequence of contact matrices must meet the following requirements:
The sequence must be a tuple, list or
numpy.ndarray
instance containing the contact matrices either asNumPy arrays
or asSciPy sparse matrices
. A mix ofNumPy arrays
andSciPy sparse matrices
is not permitted.All arrays in the sequence must have the same shape. If shape is supplied, their shape must be equal to shape.
All arrays in the sequence must have a dimension equal to the supplied dim (usually 2 for contact matrices).
All array elements must be greater than or equal to amin (if supplied; usually 0 for contact matrices).
All array elements must be less than or equal to amax (if supplied; usually 1 for contact matrices).
All arrays in the sequence must have a data type equal to the supplied dtype.
- Parameters:
cms (
tuple
orlist
ornumpy.ndarray
) – Sequence of contact matrices (or generally arrays) as e.g. generated withmdtools.structure.contact_matrices()
. The contact matrices itself can be eitherNumPy arrays
orSciPy sparse matrices
. A mix ofNumPy arrays
andSciPy sparse matrices
is not permitted.shape (
tuple
, optional) – The shape expected for the arrays in cms. Default isNone
, which means that it is only checked whether all arrays in cms have the same shape, but not what shape that is.dim (
int
, optional) – The dimension expected for the arrays in cms. IfNone
, the dimension is not checked.amin (
scalar
) – Minimum values that the elements of the arrays in cms must not undermine.amax (
scalar
) – Maximum values that the elements of the arrays in cms must not exceed.dtype (
type
, optional) – The data type expected for the arrays in cms. Default isNone
, which means that the data type is not checked.
- Returns:
cms (
tuple
orlist
ornumpy.ndarray
) – The unmodified input.- Raises:
ValueError – If shape is not
None
and the shape of the arrays in cms is not shape; dim is notNone
and the dimension of the arrays in cms is not dim; The arrays in cms contain elements that are less than amin; The arrays in cms contain elements that are greater than amax. Or if the given combination of shape and dim is not satisfiable by any array; amax is less than amin.TypeError – If cms is not a sequence of arrays; dtype is not
None
and the data type of the arrays in cms is not dtype; Not all arrays in cms are of the same instance.