nigsp.io.check_mtx_dim

nigsp.io.check_mtx_dim(fname, data, shape=None)[source]

Check dimensions of a matrix.

Parameters:
fnamestr

The name of the file representing data

datanp.ndarray

The data which dimensionality needs to be checked

shapeNone, ‘square’, or ‘rectangle’}, str, optional

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 3 dimensions. If shape is not None but data is 3D.

ValueError

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