예제 #1
0
def test_csr_mean_variance_axis0(failure_logger, sparse_random_dataset):
    X_np, _, _, X_sparse = sparse_random_dataset
    if X_sparse.format != 'csr':
        pytest.skip('Skip non CSR matrices')

    means, variances = csr_mean_variance_axis0(X_sparse)

    ref_means = np.nanmean(X_np, axis=0)
    ref_variances = np.nanvar(X_np, axis=0)

    assert_allclose(means, ref_means)
    assert_allclose(variances, ref_variances)
예제 #2
0
def test_csr_mean_variance_axis0(sparse_clf_dataset):  # noqa: F811
    X_np, X = sparse_clf_dataset

    if not cp.sparse.issparse(X):
        pytest.skip("Skipping non-CuPy or non-sparse arrays")

    if X.format != 'csr':
        X = X.tocsr()

    means, variances = csr_mean_variance_axis0(X)

    X_np = X_np.toarray()
    ref_means = np.nanmean(X_np, axis=0)
    ref_variances = np.nanvar(X_np, axis=0)

    assert_allclose(means, ref_means)
    assert_allclose(variances, ref_variances)