def get_shape(array):
    """
    Return the shape of a array-like matrix.

    Args:
        array: array-like or sparse matrix, shape=(n_samples, n_features)

    Returns:
        n_samples: int, number of rows
        n_features: int, number of columns

    """

    try:
        if len(array.shape) > 2:
            raise ValueError("Error: Array is of dimension %d but must be of dimension 2" % len(array.shape))

        return array.shape[0], array.shape[1]

    except AttributeError:
        print("Error: The object has no attribute 'shape'. Please use a pandas.DataFrame or numpy.ndarray object")

    except IndexError:
        print("Error: The object has only one dimension. "
              "Please use a pandas.DataFrame or numpy.ndarray object with 2 dimensions")