def _check_2d_shape ( X ) : if X . dtype . names is None and len ( X . shape ) != 2 : raise ValueError ( 'X needs to be 2-dimensional, not ' '{}-dimensional.' . format ( len ( X . shape ) ) )
check matrix dimension in python
Check shape of array or sparse matrix .
def _check_2d_shape(X):
    """Check shape of array or sparse matrix.

    Assure that X is always 2D: Unlike numpy we always deal with 2D arrays.
    """
    if X.dtype.names is None and len(X.shape) != 2:
        raise ValueError('X needs to be 2-dimensional, not '
                         '{}-dimensional.'.format(len(X.shape)))