Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danlessa committed Jan 18, 2024
1 parent 9f6134d commit 196040a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
28 changes: 7 additions & 21 deletions testing/test_param_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

P_no_lst = {'pA': 1, 'pB': 2, 'pC': 3}
P_single_lst = {'pA': [1], 'pB': [1], 'pC': [3]}
P_single_swp = {'pA': [1, 2, 3], 'pB': [1], 'pC': [3]}
P_all_swp = {'pA': [1, 2, 3], 'pB': [1, 2, 3], 'pC': [1, 2, 3]}
Ps = [P_no_lst, P_single_lst, P_single_swp, P_all_swp]
P_single_swp = {'pA': [4, 5, 6], 'pB': [1], 'pC': [3]}
P_all_swp = {'pA': [7, 8, 9], 'pB': [1, 2, 3], 'pC': [1, 2, 3]}
P_all_but_one_swp = {'pA': [7, 8, 9], 'pB': [1, 2, 3], 'pC': [1]}
Ps = [P_no_lst, P_single_lst, P_single_swp, P_all_swp, P_all_but_one_swp]

CONFIG_SIGNATURES_TO_TEST = [(3, 3, 3, 3, 3), (1, 3, 3, 3, 3),
(3, 1, 3, 3, 3), (1, 1, 3, 3, 3),
Expand All @@ -24,13 +25,9 @@ def run_experiment(exp: Experiment, mode: str):
return records






def param_count_test_generator(provided_params):
def s_test_param_count(params, _2, _3, _4, _5):
assert params.keys() == provided_params.keys()
assert params.keys() == provided_params.keys(), 'Params are not matching'


def create_experiments(N_simulations=3, N_sweeps=3, N_runs=3, N_timesteps=3, N_substeps=3, params={}) -> Experiment:
Expand Down Expand Up @@ -64,23 +61,12 @@ def expected_rows(N_simulations, N_sweeps, N_runs, N_timesteps, N_substeps,P) ->
@pytest.mark.parametrize("P", Ps)
def test_row_count_single(N_sim, N_sw, N_r, N_t, N_s, P):
args = (N_sim, N_sw, N_r, N_t, N_s, P)
assert len(run_experiment(create_experiments(*args), 'single_proc')) == expected_rows(*args)


@pytest.mark.parametrize("N_sim,N_sw,N_r,N_t,N_s", CONFIG_SIGNATURES_TO_TEST)
@pytest.mark.parametrize("P", Ps)
def test_row_count_multi(N_sim, N_sw, N_r, N_t, N_s, P):
args = (N_sim, N_sw, N_r, N_t, N_s, P)
len(run_experiment(create_experiments(*args), 'single_proc'))

if N_sim == 1 and N_sw == 1 and N_r == 1:
with pytest.raises(ValueError) as e_info:
assert len(run_experiment(create_experiments(*args), 'multi_proc')) == expected_rows(*args)
else:
assert len(run_experiment(create_experiments(*args), 'multi_proc')) == expected_rows(*args)


@pytest.mark.parametrize("N_sim,N_sw,N_r,N_t,N_s", CONFIG_SIGNATURES_TO_TEST)
@pytest.mark.parametrize("P", Ps)
def test_row_count_local(N_sim, N_sw, N_r, N_t, N_s, P):
args = (N_sim, N_sw, N_r, N_t, N_s, P)
assert len(run_experiment(create_experiments(*args), 'local_proc')) == expected_rows(*args)
len(run_experiment(create_experiments(*args), 'local_proc'))
2 changes: 1 addition & 1 deletion testing/tests/cadCAD_memory_address.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"memory_address": "0x111857380"}
{"memory_address": "0x10d841d50"}

0 comments on commit 196040a

Please sign in to comment.