phys2cvr.utils.check_array_dim

phys2cvr.utils.check_array_dim(fname, data, shape=None)[source]

Check dimensions of a matrix.

For future 3D implementation, check MIPLabCH/nigsp’s check_array_dim.

Parameters:
fnamestr

The name of the file representing data.

datanp.ndarray

The data which dimensionality needs to be checked.

shapeNone | 'square' | 'rectangle'

Shape of matrix, if empty, skip shape check.

Returns:
np.ndarray

If data.ndim = 2, returns data. If data.ndim = 1 and shape == 'rectangle', returns data with added empty axis.

Raises:
NotImplementedError

If data has more than 2 dimensions.

ValueError

If data is empty If shape == 'square' and data dimensions have different lengths.