Skip to content

Commit c52f645

Browse files
authored
Release 2.1.1 (#419)
1 parent b3851cd commit c52f645

3 files changed

Lines changed: 56 additions & 49 deletions

File tree

.conda/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ build:
1515

1616
requirements:
1717
host:
18-
- python >=3.6
18+
- python >=3.7
1919
run:
20-
- python >=3.6
20+
- python >=3.7
2121
- click
2222
- estimagic >=0.1.2
2323
- hypothesis
2424
- joblib
2525
- fastparquet
2626
- mkl
2727
- numba >=0.42
28-
- numpy
28+
- numpy>=1.21.0
2929
- pandas >=0.24
3030
- pytest
3131
- python-snappy

respy/tests/test_regression.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import pytest
66

7+
from respy.config import CHAOSPY_INSTALLED
78
from respy.config import TEST_RESOURCES_DIR
89
from respy.config import TOL_REGRESSION_TESTS
910
from respy.likelihood import get_log_like_func
@@ -37,8 +38,10 @@ def regression_vault():
3738
def test_single_regression(regression_vault, index):
3839
"""Run a single regression test."""
3940
params, options, exp_val = regression_vault[index]
40-
crit_val = compute_log_likelihood(params, options)
4141

42-
assert np.isclose(
43-
crit_val, exp_val, rtol=TOL_REGRESSION_TESTS, atol=TOL_REGRESSION_TESTS
44-
)
42+
if CHAOSPY_INSTALLED or options["monte_carlo_sequence"] == "random":
43+
crit_val = compute_log_likelihood(params, options)
44+
45+
assert np.isclose(
46+
crit_val, exp_val, rtol=TOL_REGRESSION_TESTS, atol=TOL_REGRESSION_TESTS
47+
)

respy/tests/test_solve.py

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import numpy as np
22
import pytest
33

4+
from respy.config import CHAOSPY_INSTALLED
45
from respy.config import EXAMPLE_MODELS
56
from respy.config import INDEXER_INVALID_INDEX
67
from respy.config import KEANE_WOLPIN_1994_MODELS
@@ -274,58 +275,61 @@ def test_dense_choice_cores():
274275
where this is not the case!
275276
276277
"""
277-
point_constr = {"n_periods": 6, "observables": [3], "n_lagged_choices": 1}
278+
if CHAOSPY_INSTALLED:
279+
point_constr = {"n_periods": 6, "observables": [3], "n_lagged_choices": 1}
278280

279-
params, options = generate_random_model(point_constr=point_constr)
280-
options["monte_carlo_sequence"] = "sobol"
281-
282-
# Add some inadmissible states
283-
optim_paras, _ = process_params_and_options(params, options)
284-
285-
# Solve the base model
286-
solve = get_solve_func(params, options)
287-
state_space = solve(params)
281+
params, options = generate_random_model(point_constr=point_constr)
282+
options["monte_carlo_sequence"] = "sobol"
288283

289-
# Retrieve index
290-
edu_start = np.random.choice(list(optim_paras["choices"]["edu"]["start"].keys()))
291-
state = (3, 0, 3, edu_start, 1)
292-
core_ix = state_space.indexer[state]
284+
# Add some inadmissible states
285+
optim_paras, _ = process_params_and_options(params, options)
293286

294-
# Choose dense covar
295-
pos = np.random.choice(range(len(state_space.dense)))
287+
# Solve the base model
288+
solve = get_solve_func(params, options)
289+
state_space = solve(params)
296290

297-
# Get indices
298-
dense_combination = list(state_space.dense.keys())[pos]
299-
dense_index = state_space.dense_covariates_to_dense_index[dense_combination]
300-
ix = (
301-
state_space.core_key_and_dense_index_to_dense_key[core_ix[0], dense_index],
302-
core_ix[1],
303-
)
291+
# Retrieve index
292+
edu_start = np.random.choice(
293+
list(optim_paras["choices"]["edu"]["start"].keys())
294+
)
295+
state = (3, 0, 3, edu_start, 1)
296+
core_ix = state_space.indexer[state]
297+
298+
# Choose dense covar
299+
pos = np.random.choice(range(len(state_space.dense)))
300+
301+
# Get indices
302+
dense_combination = list(state_space.dense.keys())[pos]
303+
dense_index = state_space.dense_covariates_to_dense_index[dense_combination]
304+
ix = (
305+
state_space.core_key_and_dense_index_to_dense_key[core_ix[0], dense_index],
306+
core_ix[1],
307+
)
304308

305-
unrestricted_cont = state_space.get_continuation_values(3)[ix[0]][ix[1]]
309+
unrestricted_cont = state_space.get_continuation_values(3)[ix[0]][ix[1]]
306310

307-
# Impose some restriction
308-
options["negative_choice_set"] = {"a": ["period == 4 & exp_b ==4"]}
311+
# Impose some restriction
312+
options["negative_choice_set"] = {"a": ["period == 4 & exp_b ==4"]}
309313

310-
# Solve the restricted model
311-
solve = get_solve_func(params, options)
312-
state_space = solve(params)
313-
core_ix = state_space.indexer[state]
314+
# Solve the restricted model
315+
solve = get_solve_func(params, options)
316+
state_space = solve(params)
317+
core_ix = state_space.indexer[state]
314318

315-
# Get indices
316-
dense_combination = list(state_space.dense.keys())[pos]
317-
dense_index = state_space.dense_covariates_to_dense_index[dense_combination]
318-
ix = (
319-
state_space.core_key_and_dense_index_to_dense_key[core_ix[0], dense_index],
320-
core_ix[1],
321-
)
319+
# Get indices
320+
dense_combination = list(state_space.dense.keys())[pos]
321+
dense_index = state_space.dense_covariates_to_dense_index[dense_combination]
322+
ix = (
323+
state_space.core_key_and_dense_index_to_dense_key[core_ix[0], dense_index],
324+
core_ix[1],
325+
)
322326

323-
# Check some features of the state_space
324-
restricted_cont = state_space.get_continuation_values(3)[ix[0]][ix[1]]
327+
# Check some features of the state_space
328+
restricted_cont = state_space.get_continuation_values(3)[ix[0]][ix[1]]
325329

326-
for i in [0, 2, 3]:
327-
assert restricted_cont[i] == unrestricted_cont[i]
328-
assert restricted_cont[1] != unrestricted_cont[1]
330+
for i in [0, 2, 3]:
331+
assert restricted_cont[i] == unrestricted_cont[i]
332+
assert restricted_cont[1] != unrestricted_cont[1]
329333

330334

331335
@pytest.mark.end_to_end

0 commit comments

Comments
 (0)