Skip to content

Commit

Permalink
Ignore our specific warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesYang007 committed Jun 15, 2024
1 parent ff3bc96 commit 69f8378
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
18 changes: 12 additions & 6 deletions tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def run_cov(
assert cA.cols() == p


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("ps", [[1, 5, 8, 2]])
@pytest.mark.parametrize("n", [2, 100, 20])
Expand All @@ -73,6 +74,7 @@ def test_cov_block_diag(n, ps, dtype, seed=0):
run_cov(A, cA, dtype)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, p", [
Expand Down Expand Up @@ -107,6 +109,7 @@ def test_cov_lazy_cov(n, p, dtype, order, seed=0):
run_cov(A, cA, dtype)


@pytest.mark.filterwarnings("ignore: Converting to CSC format.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, p", [
Expand All @@ -127,9 +130,7 @@ def test_cov_sparse(n, p, dtype, order, seed=0):
"C": scipy.sparse.csr_matrix,
"F": scipy.sparse.csc_matrix,
}[order](A)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cA = mod.sparse(A_sp, method="cov", n_threads=3)
cA = mod.sparse(A_sp, method="cov", n_threads=3)
run_cov(A, cA, dtype)


Expand Down Expand Up @@ -268,6 +269,7 @@ def run_naive(
assert np.allclose(expected, out, atol=atol)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("ps", [[1, 7, 41, 13, 113]])
@pytest.mark.parametrize("n", [10, 20, 30])
Expand All @@ -286,6 +288,7 @@ def test_naive_cconcatenate(n, ps, dtype, n_threads=2, seed=0):
run_naive(X, cX, dtype)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("ns", [[1, 7, 41, 13, 113]])
@pytest.mark.parametrize("p", [10, 20, 30])
Expand All @@ -304,6 +307,7 @@ def test_naive_rconcatenate(ns, p, dtype, n_threads=2, seed=0):
run_naive(X, cX, dtype)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, p", [
Expand All @@ -319,6 +323,7 @@ def test_naive_dense(n, p, dtype, order, seed=0):
run_naive(X, cX, dtype)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, d", [
Expand Down Expand Up @@ -377,6 +382,7 @@ def _create_dense(X, pairs, levels):
ad.configs.set_configs("min_bytes", min_bytes)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, p, K", [
Expand Down Expand Up @@ -413,6 +419,7 @@ def test_naive_kronecker_eye_dense(n, p, K, dtype, order, seed=0):
run_naive(X, cX, dtype)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, d", [
Expand Down Expand Up @@ -523,6 +530,7 @@ def create_dense(calldata, ancestries, A):
ad.configs.set_configs("min_bytes", min_bytes)


@pytest.mark.filterwarnings("ignore: Converting to CSC format.")
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
@pytest.mark.parametrize("order", ["C", "F"])
@pytest.mark.parametrize("n, p", [
Expand All @@ -538,9 +546,7 @@ def test_naive_sparse(n, p, dtype, order, seed=0):
"C": scipy.sparse.csr_matrix,
"F": scipy.sparse.csc_matrix,
}[order](X)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cX = mod.sparse(X_sp, method="naive", n_threads=3)
cX = mod.sparse(X_sp, method="naive", n_threads=3)
run_naive(X, cX, dtype)


Expand Down
4 changes: 4 additions & 0 deletions tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def run_solve_gaussian(state, args, pin):
return state


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("constraint", [False, True])
@pytest.mark.parametrize("n, p, G, S", [
[10, 4, 2, 2],
Expand Down Expand Up @@ -521,6 +522,7 @@ def test_solve_gaussian_pin_naive(
run_solve_gaussian(state, args, pin=True)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("constraint", [False, True])
@pytest.mark.parametrize("n, p, G, S", [
[10, 4, 2, 2],
Expand Down Expand Up @@ -582,6 +584,7 @@ def test_solve_gaussian_pin_cov(
run_solve_gaussian(state, args, pin=True)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("constraint", [False, True])
@pytest.mark.parametrize("n, p, G", [
[10, 4, 2],
Expand Down Expand Up @@ -818,6 +821,7 @@ def test_solve_gaussian_snp_unphased(
os.remove(filename)


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
@pytest.mark.parametrize("n, p", [
[10, 4],
[10, 100],
Expand Down
5 changes: 4 additions & 1 deletion tests/test_state.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from adelie.logger import logger
import logging
logger.setLevel(logging.DEBUG)

import adelie.state as mod
import adelie.matrix as matrix
import numpy as np
import pytest


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
def test_state_gaussian_pin_naive():
n = 1000
p = 100
Expand Down Expand Up @@ -65,6 +66,7 @@ def test_state_gaussian_pin_naive():
assert state.iters == 0


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
def test_state_gaussian_pin_cov():
n = 1000
p = 100
Expand Down Expand Up @@ -118,6 +120,7 @@ def test_state_gaussian_pin_cov():
assert state.iters == 0


@pytest.mark.filterwarnings("ignore: Detected matrix to be C-contiguous.")
def test_state_gaussian_naive():
n = 3
p = 100
Expand Down

0 comments on commit 69f8378

Please sign in to comment.