'Convert an arbitrary value into a matrix of type self.target_matrix.
Args:
value: The constant to be converted.
convert_scalars: Should scalars be converted?
Returns:
A matrix of type self.target_matrix or a scalar.'

@NDArrayInterface.scalar_const
def const_to_matrix(self, value, convert_scalars=False):

    if (isinstance(value, list) or (isinstance(value, np.ndarray) and (value.ndim == 1))):
        value = np.asmatrix(value, dtype='float64').T
    elif sp.issparse(value):
        value = value.todense()
    return np.asmatrix(value, dtype='float64')
