Skip to content

Commit

Permalink
--amend
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejnovak committed Jun 9, 2022
1 parent 14ff296 commit 98d3d73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/fit/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ def test_ranking(mock_fit, example_spec):
bestfit = np.asarray([0.9, 1.0])
uncertainty = np.asarray([0.02, 0.1])
labels = ["staterror", "mu"]
labels = ["staterror", "normfactor"]
fit_results = fit.FitResults(bestfit, uncertainty, labels, np.empty(0), 0.0)
types = ["staterror", "normfactor"]
fit_results = fit.FitResults(bestfit, uncertainty, labels, types, np.empty(0), 0.0)
model, data = model_utils.model_and_data(example_spec)
ranking_results = fit.ranking(model, data, fit_results=fit_results)

Expand Down
19 changes: 16 additions & 3 deletions tests/fit/test_fit_results_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ def test_FitResults():
bestfit = np.asarray([1.0])
uncertainty = np.asarray([0.1])
labels = ["par_a"]
types = [None]
corr_mat = np.asarray([[1.0]])
best_twice_nll = 2.0
fit_results = fit.FitResults(bestfit, uncertainty, labels, corr_mat, best_twice_nll)
fit_results = fit.FitResults(
bestfit, uncertainty, labels, types, corr_mat, best_twice_nll
)
assert np.allclose(fit_results.bestfit, bestfit)
assert np.allclose(fit_results.uncertainty, uncertainty)
assert fit_results.labels == labels
Expand All @@ -25,16 +28,25 @@ def test_RankingResults():
bestfit = np.asarray([1.0])
uncertainty = np.asarray([0.1])
labels = ["par_a"]
types = [None]
prefit_up = np.asarray([0.3])
prefit_down = np.asarray([-0.3])
postfit_up = np.asarray([0.2])
postfit_down = np.asarray([-0.2])
ranking_results = fit.RankingResults(
bestfit, uncertainty, labels, prefit_up, prefit_down, postfit_up, postfit_down
bestfit,
uncertainty,
labels,
types,
prefit_up,
prefit_down,
postfit_up,
postfit_down,
)
assert np.allclose(ranking_results.bestfit, bestfit)
assert np.allclose(ranking_results.uncertainty, uncertainty)
assert ranking_results.labels == labels
assert ranking_results.types == types
assert np.allclose(ranking_results.prefit_up, prefit_up)
assert np.allclose(ranking_results.prefit_down, prefit_down)
assert np.allclose(ranking_results.postfit_up, postfit_up)
Expand Down Expand Up @@ -100,7 +112,8 @@ def test_print_results(caplog):
bestfit = np.asarray([1.0, 2.0])
uncertainty = np.asarray([0.1, 0.3])
labels = ["param_A", "param_B"]
fit_results = fit.FitResults(bestfit, uncertainty, labels, np.empty(0), 0.0)
types = [None, None]
fit_results = fit.FitResults(bestfit, uncertainty, labels, types, np.empty(0), 0.0)

fit.print_results(fit_results)
assert "param_A = 1.0000 +/- 0.1000" in [rec.message for rec in caplog.records]
Expand Down
8 changes: 5 additions & 3 deletions tests/visualize/test_visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,11 @@ def test_correlation_matrix(mock_draw):
corr_mat = np.asarray([[1.0, 0.2, 0.1], [0.2, 1.0, 0.1], [0.1, 0.1, 1.0]])
corr_mat_pruned = np.asarray([[1.0, 0.2], [0.2, 1.0]])
labels = ["a", "b", "c"]
types = [None, None, None]
labels_pruned = ["a", "b"]
folder_path = "tmp"
figure_path = pathlib.Path(folder_path) / "correlation_matrix.pdf"
fit_results = fit.FitResults(np.empty(0), np.empty(0), labels, corr_mat, 1.0)
fit_results = fit.FitResults(np.empty(0), np.empty(0), labels, types, corr_mat, 1.0)

# pruning with threshold
fig = visualize.correlation_matrix(
Expand All @@ -382,7 +383,7 @@ def test_correlation_matrix(mock_draw):
# close figure, do not save
corr_mat_fixed = np.asarray([[1.0, 0.2, 0.0], [0.2, 1.0, 0.0], [0.0, 0.0, 0.0]])
fit_results_fixed = fit.FitResults(
np.empty(0), np.empty(0), labels, corr_mat_fixed, 1.0
np.empty(0), np.empty(0), labels, types, corr_mat_fixed, 1.0
)
_ = visualize.correlation_matrix(
fit_results_fixed,
Expand All @@ -407,9 +408,10 @@ def test_pulls(mock_draw):
bestfit = np.asarray([0.8, 1.0, 1.05, 1.1])
uncertainty = np.asarray([0.9, 1.0, 0.03, 0.7])
labels = ["a", "b", "staterror_region[0]", "c"]
types = [None, None, None, None]
exclude = ["a"]
folder_path = "tmp"
fit_results = fit.FitResults(bestfit, uncertainty, labels, np.empty(0), 1.0)
fit_results = fit.FitResults(bestfit, uncertainty, labels, types, np.empty(0), 1.0)

filtered_bestfit = np.asarray([1.0, 1.1])
filtered_uncertainty = np.asarray([1.0, 0.7])
Expand Down

0 comments on commit 98d3d73

Please sign in to comment.