def test_normalize( failure_logger, clf_dataset, axis, norm, # noqa: F811 return_norm): X_np, X = clf_dataset if return_norm: t_X, t_norms = cu_normalize(X, axis=axis, norm=norm, return_norm=return_norm) sk_t_X, sk_t_norms = sk_normalize(X_np, axis=axis, norm=norm, return_norm=return_norm) assert_allclose(t_norms, sk_t_norms) else: t_X = cu_normalize(X, axis=axis, norm=norm, return_norm=return_norm) sk_t_X = sk_normalize(X_np, axis=axis, norm=norm, return_norm=return_norm) assert type(t_X) == type(X) assert_allclose(t_X, sk_t_X)
def test_normalize_sparse(failure_logger, sparse_clf_dataset, # noqa: F811 norm): X_np, X = sparse_clf_dataset axis = 0 if X.format == 'csc' else 1 t_X = cu_normalize(X, axis=axis, norm=norm) # assert type(t_X) == type(X) if cpx.scipy.sparse.issparse(X): assert cpx.scipy.sparse.issparse(t_X) if scipy.sparse.issparse(X): assert scipy.sparse.issparse(t_X) sk_t_X = sk_normalize(X_np, axis=axis, norm=norm) assert_allclose(t_X, sk_t_X)