I included X = safe_asarray(X) in all of these locations to convert lists and sparse formats other than csr, csc, and coo.