Skip to content

Add slow marker to multiple test cases #699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/test_data_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def cpn():
return Path(__file__).parent / "fixtures" / "ddm_cpn.onnx"


@pytest.mark.slow
def test_data_sanity_check(data_ddm, cpn, caplog):
# Case 1: raise error if there are missing fields in data
with pytest.raises(ValueError, match="Field rt not found in data."):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_distribution_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_lapse_distribution():
np.testing.assert_array_equal(random_sample_a, random_sample_b)


@pytest.mark.slow
def test_apply_param_bounds_to_loglik():
"""Tests the function in separation."""
logp = np.random.normal(size=1000)
Expand Down Expand Up @@ -121,6 +122,7 @@ def test_apply_param_bounds_to_loglik():
)


@pytest.mark.slow
def test_make_distribution():
def fake_logp_function(data, param1, param2):
"""Make up a fake log likelihood function for this test only."""
Expand Down Expand Up @@ -165,6 +167,7 @@ def fake_logp_function(data, param1, param2):
)


@pytest.mark.slow
def test_extra_fields(data_ddm):
ones = np.ones(data_ddm.shape[0])
x = ones * 0.5
Expand Down Expand Up @@ -231,6 +234,7 @@ def logp_ddm_extra_fields(data, v, a, z, t, x, y):
)


@pytest.mark.slow
def test_ensure_positive_ndt():
data = np.zeros((1000, 2))
data[:, 0] = np.random.uniform(size=1000)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_graphing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

import hssm


@pytest.mark.slow
def test_simple_graphing(data_ddm):
model = hssm.HSSM(data=data_ddm, model="ddm")
graph = model.graph()
Expand Down
11 changes: 11 additions & 0 deletions tests/test_hssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
param_a = param_v | dict(name="a", formula="a ~ 1 + x + y")


@pytest.mark.slow
@pytest.mark.parametrize(
"include, should_raise_exception",
[
Expand Down Expand Up @@ -80,6 +81,7 @@ def test_transform_params_general(data_ddm_reg, include, should_raise_exception)
assert len(model.params) == 5


@pytest.mark.slow
def test_custom_model(data_ddm):
with pytest.raises(
ValueError, match="When using a custom model, please provide a `loglik_kind.`"
Expand Down Expand Up @@ -132,6 +134,7 @@ def test_custom_model(data_ddm):
assert model.list_params == ["v", "a", "z", "t", "p_outlier"]


@pytest.mark.slow
def test_model_definition_outside_include(data_ddm):
model_with_one_param_fixed = HSSM(data_ddm, a=0.5)

Expand All @@ -151,6 +154,7 @@ def test_model_definition_outside_include(data_ddm):
HSSM(data_ddm, include=[{"name": "a", "prior": 0.5}], a=0.5)


@pytest.mark.slow
def test_sample_prior_predictive(data_ddm_reg):
data_ddm_reg = data_ddm_reg.iloc[:10, :]

Expand Down Expand Up @@ -195,6 +199,7 @@ def test_sample_prior_predictive(data_ddm_reg):
)


@pytest.mark.slow
def test_override_default_link(caplog, data_ddm_reg):
param_v = {
"name": "v",
Expand Down Expand Up @@ -225,6 +230,7 @@ def test_override_default_link(caplog, data_ddm_reg):
assert "strange" in caplog.records[0].message


@pytest.mark.slow
def test_resampling(data_ddm):
model = HSSM(data=data_ddm)
sample_1 = model.sample(draws=10, chains=1, tune=0)
Expand All @@ -236,6 +242,7 @@ def test_resampling(data_ddm):
assert sample_1 is not sample_2


@pytest.mark.slow
def test_add_likelihood_parameters_to_data(data_ddm):
"""Test if the likelihood parameters are added to the InferenceData object."""
model = HSSM(data=data_ddm)
Expand Down Expand Up @@ -271,6 +278,7 @@ def test_add_likelihood_parameters_to_data(data_ddm):


# Setting any parameter to a fixed value should work:
@pytest.mark.slow
def test_model_creation_constant_parameter(data_ddm):
for param_name in ["v", "a", "z", "t"]:
model = HSSM(data=data_ddm, **{param_name: 1.0})
Expand All @@ -279,6 +287,7 @@ def test_model_creation_constant_parameter(data_ddm):


# Setting any single parameter to a regression should respect the default bounds:
@pytest.mark.slow
@pytest.mark.parametrize(
"param_name, dist_name",
[("v", "Normal"), ("a", "Gamma"), ("z", "Beta"), ("t", "Gamma")],
Expand All @@ -299,6 +308,7 @@ def test_model_creation_all_parameters_constant(data_ddm):


# Prior settings
@pytest.mark.slow
def test_prior_settings_basic(cavanagh_test):
model_1 = HSSM(
data=cavanagh_test,
Expand All @@ -321,6 +331,7 @@ def test_prior_settings_basic(cavanagh_test):
)


@pytest.mark.slow
def test_compile_logp(cavanagh_test):
model_1 = HSSM(
data=cavanagh_test,
Expand Down
9 changes: 9 additions & 0 deletions tests/test_initvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
]


@pytest.mark.slow
@pytest.mark.parametrize(parameter_names, parameter_grid)
def test_sample_map(caplog, loglik_kind, model, sampler, initvals):
"""Test sampling from MAP starting point."""
Expand Down Expand Up @@ -136,6 +137,7 @@ def _check_initval_defaults_correctness(model) -> None:
pass


@pytest.mark.slow
def test_basic_model(caplog):
"""Test basic model with p_outlier distribution defined."""
caplog.set_level(logging.INFO)
Expand All @@ -149,6 +151,7 @@ def test_basic_model(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_basic_model_p_outlier(caplog):
"""Test basic model with p_outlier distribution defined."""
caplog.set_level(logging.INFO)
Expand All @@ -163,6 +166,7 @@ def test_basic_model_p_outlier(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_basic_model_p_outlier_initval(caplog):
"""Test basic model with p_outlier distribution defined."""
caplog.set_level(logging.INFO)
Expand All @@ -180,6 +184,7 @@ def test_basic_model_p_outlier_initval(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_reg_model(caplog):
"""Test regression model, with regression on all parameters."""
caplog.set_level(logging.INFO)
Expand All @@ -199,6 +204,7 @@ def test_reg_model(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_reg_model_subset(caplog):
"""Test regression model, with subset of parameters being regressions."""
caplog.set_level(logging.INFO)
Expand All @@ -217,6 +223,7 @@ def test_reg_model_subset(caplog):
)


@pytest.mark.slow
def test_angle_model_reg(caplog):
"""Test with angle model regression."""
caplog.set_level(logging.INFO)
Expand All @@ -237,6 +244,7 @@ def test_angle_model_reg(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_angle_model(caplog):
"""Test with angle model basic."""
caplog.set_level(logging.INFO)
Expand All @@ -250,6 +258,7 @@ def test_angle_model(caplog):
_check_initval_defaults_correctness(model)


@pytest.mark.slow
def test_process_no_process(caplog):
"""Test mismatch with and without preprocessing."""
caplog.set_level(logging.INFO)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def shared_params():
parameters = [(name, np.arange(value, 5.1, 0.5)) for name, value in zip(names, values)]


@pytest.mark.slow
@pytest.mark.parametrize("param_name, param_values", parameters)
def test_no_inf_values(data_ddm, shared_params, param_name, param_values):
for value in param_values:
Expand All @@ -82,6 +83,7 @@ def test_no_inf_values(data_ddm, shared_params, param_name, param_values):
parameters = [standard, svd] # type: ignore


@pytest.mark.slow
@pytest.mark.parametrize("logp_func, logp_bbox_func, true_values", parameters)
def test_bbox(data_ddm, logp_func, logp_bbox_func, true_values):
data = data_ddm.values
Expand All @@ -101,6 +103,7 @@ def test_bbox(data_ddm, logp_func, logp_bbox_func, true_values):
nan_guard_mode = NanGuardMode(nan_is_error=True, inf_is_error=True, big_is_error=False)


@pytest.mark.slow
def test_analytical_gradient():
v = pt.dvector()
a = pt.dvector()
Expand Down Expand Up @@ -145,6 +148,7 @@ def test_analytical_gradient():
)


@pytest.mark.slow
@pytest.mark.parametrize("p_outlier, loglik_kind", param_matrix)
def test_lapse_distribution_cav(p_outlier, loglik_kind):
true_values = (1.5, 0.5, 0.5)
Expand Down
1 change: 1 addition & 0 deletions tests/test_likelihoods_lba.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def vectorize_param(theta, param, size):
theta_lba3 = theta_lba2 | {"v2": 1.0}


@pytest.mark.slow
@pytest.mark.parametrize(
"logp_func, model, theta",
[(logp_lba2, "lba2", theta_lba2), (logp_lba3, "lba3", theta_lba3)],
Expand Down
1 change: 1 addition & 0 deletions tests/test_missing_and_deadline.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def data():
cases = product(["cpn", "opn"], [True, False])


@pytest.mark.slow
@pytest.mark.parametrize("cpn, is_vector", cases)
def test_make_missing_data_callable(data, fixture_path, cpn, is_vector):
is_cpn = cpn == "cpn"
Expand Down
2 changes: 2 additions & 0 deletions tests/test_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def onnx_session(fixture_path):
)


@pytest.mark.slow
def test_interpret_onnx(onnx_session, fixture_path):
"""Tests whether both versions of interpret_onnx return similar values as does the
ONNX runtime.
Expand Down Expand Up @@ -100,6 +101,7 @@ def test_make_jax_logp_funcs_from_onnx(fixture_path):
)


@pytest.mark.slow
def test_make_jax_logp_ops(fixture_path):
"""Tests whether the logp Op returned from make_jax_logp_ops with different backends
work the same way.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def test__plot_posterior_predictive_2D(cav_idata, cavanagh_test):
assert len(g2.figure.axes[0].get_lines()) == 1


@pytest.mark.slow
def test_plot_posterior_predictive(cav_idata, cavanagh_test):
# Mock model object
model = hssm.HSSM(
Expand Down Expand Up @@ -289,6 +290,7 @@ def test__plot_quantile_probability_2D(cav_idata, cavanagh_test):
assert len(g.figure.axes) == 5 * 4


@pytest.mark.slow
def test_plot_quantile_probability(cav_idata, cavanagh_test):
# Mock model object
model = hssm.HSSM(
Expand Down
2 changes: 2 additions & 0 deletions tests/test_plotting_cartoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


# I want to parameter
@pytest.mark.slow
@pytest.mark.parametrize(
["n_trajectories", "groups", "plot_pp_mean", "plot_pp_samples", "row", "col"],
[
Expand Down Expand Up @@ -66,6 +67,7 @@ def test_plot_model_cartoon_2_choice(
assert len(ax) == len(cav_model_cartoon.data[groups[0]].unique())


@pytest.mark.slow
@pytest.mark.parametrize(
["n_trajectories", "groups", "plot_pp_mean", "plot_pp_samples", "row", "col"],
[
Expand Down
1 change: 1 addition & 0 deletions tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)


@pytest.mark.slow
def test_register_model():
"""Test registering a custom model"""

Expand Down
1 change: 1 addition & 0 deletions tests/test_sample_posterior_predictive.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
]


@pytest.mark.slow
@pytest.mark.parametrize(PARAMETER_NAMES, PARAMETER_GRID)
def test_sample_posterior_predictive(
cav_idata, cavanagh_test, draws, safe_mode, inplace
Expand Down
5 changes: 5 additions & 0 deletions tests/test_save_load.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import numpy as np
import shutil
from pathlib import Path

import pytest

import hssm


Expand All @@ -19,6 +22,7 @@ def compare_hssm_class_attributes(model_a, model_b):
], "Basic RVs not the same"


@pytest.mark.slow
def test_save_load_model_only(basic_hssm_model):
tmp_folder_name = "models_pytest"
tmp_model_name = "hssm_model_pytest"
Expand All @@ -32,6 +36,7 @@ def test_save_load_model_only(basic_hssm_model):
shutil.rmtree(tmp_folder_name)


@pytest.mark.slow
def test_save_load_vi_mcmc(basic_hssm_model):
tmp_folder_name = "models_pytest"
tmp_model_name = "hssm_model_pytest"
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
hssm.set_floatX("float32")


@pytest.mark.slow
def test_get_alias_dict():
# Simulate some data:
v_true, a_true, z_true, t_true = [0.5, 1.5, 0.5, 0.5]
Expand Down
Loading