From db62fd94a8c93937bf9dc8f0e8b8797aa25d511b Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 14 Nov 2024 10:04:46 -0500 Subject: [PATCH] Add fail test for when pathfinder can't optimize --- clients/python/tests/test_pathfinder.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/clients/python/tests/test_pathfinder.py b/clients/python/tests/test_pathfinder.py index 10ab453..f3b9363 100644 --- a/clients/python/tests/test_pathfinder.py +++ b/clients/python/tests/test_pathfinder.py @@ -133,6 +133,22 @@ def test_inits(multimodal_model, temp_json): assert np.all(out3["mu"] < 0) +def test_inits_mode(multimodal_model): + # initializing at mode means theres nowhere to go + init1 = {"mu": -100} + + with pytest.raises( + RuntimeError, match="None of the LBFGS iterations completed successfully" + ): + multimodal_model.pathfinder(inits=init1) + + # also for single path + with pytest.raises( + RuntimeError, match="None of the LBFGS iterations completed successfully" + ): + multimodal_model.pathfinder(inits=init1, num_paths=1, psis_resample=False) + + def test_bad_data(bernoulli_model): data = {"N": -1} with pytest.raises(RuntimeError, match="greater than or equal to 0"):