Skip to content

Commit 8c04041

Browse files
authored
Merge branch 'main' into papers
2 parents 0dc2d43 + d45802f commit 8c04041

25 files changed

Lines changed: 10 additions & 215 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
1818
- [#1724](https://github.com/pints-team/pints/pull/1724) The classes `PooledLogPDF` and `SumOfIndependentLogPDFs` are deprecated, in favour of `PooledLogLikelihood` and `SumOfIndependentLogLikelihoods` respectively.
1919
- [#1508](https://github.com/pints-team/pints/pull/1508) The methods `OptimisationController.max_unchanged_iterations` and `set_max_unchanged_iterations` are deprecated, in favour of `function_tolerance` and `set_function_tolerance` respectively.
2020
### Removed
21+
- [#1731](https://github.com/pints-team/pints/pull/1731) The method `ToyLogPDF.suggested_bounds()` and its implementations have been removed.
2122
### Fixed
2223
- [#1713](https://github.com/pints-team/pints/pull/1713) Fixed Numpy 2.4.1 compatibility issues.
2324
- [#1690](https://github.com/pints-team/pints/pull/1690) Fixed bug in optimisation controller if population size left at `None`.

pints/tests/test_toy_annulus_logpdf.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,6 @@ def test_bad_constructors(self):
6868
self.assertRaises(
6969
ValueError, pints.toy.AnnulusLogPDF, 3, 1, -1)
7070

71-
def test_suggested_bounds(self):
72-
# Tests suggested_bounds() method
73-
74-
f = pints.toy.AnnulusLogPDF()
75-
bounds = f.suggested_bounds()
76-
a_val = 55
77-
self.assertTrue(np.array_equal([[-a_val, -a_val], [a_val, a_val]],
78-
bounds))
79-
r0 = 25
80-
dimensions = 5
81-
sigma = 20
82-
f = pints.toy.AnnulusLogPDF(dimensions=dimensions,
83-
r0=r0,
84-
sigma=sigma)
85-
bounds = f.suggested_bounds()
86-
r0_magnitude = (r0 + sigma) * (5**(1.0 / (dimensions - 1.0)))
87-
self.assertEqual(bounds[0][0], -r0_magnitude)
88-
self.assertEqual(bounds[1][0], r0_magnitude)
89-
self.assertTrue(np.array_equal(np.array(bounds).shape, [2, 5]))
90-
9171
def test_distance_function(self):
9272
# Tests distance function
9373

pints/tests/test_toy_classes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def test_run(self):
2121
model = pints.toy.Hes1Model()
2222
vals = [1, 2, 3]
2323
model.set_initial_conditions(vals)
24-
self.assertTrue(np.array_equal(model.initial_conditions(),
25-
vals))
24+
self.assertTrue(np.array_equal(model.initial_conditions(), vals))
2625

2726

2827
if __name__ == '__main__':

pints/tests/test_toy_cone_logpdf.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,6 @@ def test_bad_constructors(self):
7070
self.assertRaises(ValueError, f.__call__, [1, 2, 3])
7171
self.assertRaises(ValueError, f.__call__, [1, 2, 3, 4, 5])
7272

73-
def test_bounds(self):
74-
# Tests suggested_bounds()
75-
76-
f = pints.toy.ConeLogPDF()
77-
bounds = f.suggested_bounds()
78-
self.assertTrue(np.array_equal([[-1000, -1000], [1000, 1000]],
79-
bounds))
80-
beta = 3
81-
dimensions = 4
82-
f = pints.toy.ConeLogPDF(beta=beta, dimensions=dimensions)
83-
magnitude = 1000
84-
bounds = np.tile([-magnitude, magnitude], (dimensions, 1))
85-
self.assertEqual(bounds[0][0], -magnitude)
86-
self.assertEqual(bounds[0][1], magnitude)
87-
self.assertTrue(np.array_equal(np.array(bounds).shape, [4, 2]))
88-
8973
def test_sensitivities(self):
9074
# Tests sensitivities
9175

pints/tests/test_toy_eight_schools_logpdf.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def test_basic(self):
2121

2222
# Default settings
2323
f = pints.toy.EightSchoolsLogPDF()
24+
self.assertEqual(f.n_parameters(), 10)
2425
f1, dp = f.evaluateS1(np.ones(10))
2526
self.assertEqual(f1, f(np.ones(10)))
2627
self.assertAlmostEqual(f1, -43.02226038161451)
@@ -83,12 +84,6 @@ def test_negative_sd(self):
8384
self.assertEqual(logp, -np.inf)
8485
self.assertTrue(np.array_equal(grad, np.full([1, 10], -np.inf)))
8586

86-
def test_bounds(self):
87-
""" Tests suggested_bounds() """
88-
f = pints.toy.EightSchoolsLogPDF()
89-
bounds = f.suggested_bounds()
90-
self.assertEqual(bounds[0][1], 0)
91-
9287

9388
if __name__ == '__main__':
9489
unittest.main()

pints/tests/test_toy_german_credit_hierarchical_logpdf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,8 @@ def test_sensitivities(self):
7171
self.assertAlmostEqual(dp[1], -700.8386959844057, places=6)
7272

7373
def test_givens(self):
74-
# tests whether boundaries are correct and n_parameters
74+
# tests n_parameters
7575
self.assertEqual(326, self.model.n_parameters())
76-
borders = self.model.suggested_bounds()
77-
self.assertEqual(borders[0][0], -100)
78-
self.assertEqual(borders[1][0], 100)
7976

8077

8178
if __name__ == '__main__':

pints/tests/test_toy_german_credit_logpdf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,8 @@ def test_sensitivities(self):
7171
self.assertAlmostEqual(dp[1], -160.7785147438439, places=6)
7272

7373
def test_givens(self):
74-
# tests whether boundaries are correct and n_parameters
74+
# tests n_parameters
7575
self.assertEqual(25, self.model.n_parameters())
76-
borders = self.model.suggested_bounds()
77-
self.assertEqual(borders[0][0], -100)
78-
self.assertEqual(borders[1][0], 100)
7976

8077

8178
if __name__ == '__main__':

pints/tests/test_toy_high_dimensional_gaussian_logpdf.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ def test_high_dimensional_log_pdf(self):
6767
f([1, 2]),
6868
scipy.stats.multivariate_normal.logpdf([1, 2], mean, cov))
6969

70-
# check suggested bounds
71-
f = pints.toy.HighDimensionalGaussianLogPDF(dimension=2)
72-
bounds = f.suggested_bounds()
73-
magnitude = 3 * np.sqrt(2.0)
74-
bounds1 = np.tile([-magnitude, magnitude], (2, 1))
75-
bounds1 = np.transpose(bounds1).tolist()
76-
self.assertTrue(np.array_equal(bounds, bounds1))
77-
78-
f = pints.toy.HighDimensionalGaussianLogPDF()
79-
bounds = f.suggested_bounds()
80-
self.assertTrue(bounds[0][0], np.sqrt(20) * 3.0)
81-
8270
# Test kl_divergence() errors
8371
n = 1000
8472
d = f.n_parameters()

pints/tests/test_toy_multimodal_gaussian_logpdf.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -131,33 +131,6 @@ def test_sensitivities(self):
131131
self.assertAlmostEqual(dl[1], -0.054933536830093638)
132132
self.assertAlmostEqual(dl[2], -0.39317158556789844)
133133

134-
def test_suggested_bounds(self):
135-
# Tests suggested_bounds().
136-
137-
f = pints.toy.MultimodalGaussianLogPDF()
138-
covariances = [[[5**2, 0.5 * 5 * 3, -0.1 * 5 * 2],
139-
[0.5 * 5 * 3, 3**2, 0.4 * 3 * 2],
140-
[-0.1 * 5 * 2, 0.4 * 3 * 2, 2**2]],
141-
[[5**2, 0.3 * 5 * 6, 0.2 * 5 * 7],
142-
[0.3 * 5 * 6, 6**2, -0.3 * 6 * 7],
143-
[0.2 * 5 * 7, -0.3 * 6 * 7, 7**2]]]
144-
bounds = f.suggested_bounds()
145-
lower = -10
146-
upper = 20
147-
bounds1 = np.tile([lower, upper], (2, 1))
148-
bounds1 = np.transpose(bounds1).tolist()
149-
self.assertTrue(np.array_equal(bounds, bounds1))
150-
151-
f = pints.toy.MultimodalGaussianLogPDF(
152-
modes=[[1, 2, 3], [3, 4, 5]],
153-
covariances=covariances)
154-
bounds = f.suggested_bounds()
155-
lower = 1 - 4
156-
upper = 5 + 4
157-
bounds1 = np.tile([lower, upper], (3, 1))
158-
bounds1 = np.transpose(bounds1).tolist()
159-
self.assertTrue(np.array_equal(bounds, bounds1))
160-
161134
def test_distance_function(self):
162135
# Tests distance function which calls kl_divergence().
163136

pints/tests/test_toy_neals_funnel_logpdf.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,6 @@ def test_bespoke(self):
9393
x = np.ones((n, d, 2))
9494
self.assertRaises(ValueError, f.kl_divergence, x)
9595

96-
def test_suggested_bounds(self):
97-
# Tests suggested_bounds().
98-
# default
99-
f = pints.toy.NealsFunnelLogPDF()
100-
bounds = f.suggested_bounds()
101-
magnitude = 30
102-
bounds1 = np.tile([-magnitude, magnitude],
103-
(f._n_parameters, 1))
104-
bounds1 = np.transpose(bounds1).tolist()
105-
self.assertTrue(np.array_equal(bounds, bounds1))
106-
107-
# non-default
108-
f = pints.toy.NealsFunnelLogPDF(20)
109-
bounds = f.suggested_bounds()
110-
magnitude = 30
111-
bounds1 = np.tile([-magnitude, magnitude],
112-
(f._n_parameters, 1))
113-
bounds1 = np.transpose(bounds1).tolist()
114-
self.assertTrue(np.array_equal(bounds, bounds1))
115-
11696

11797
if __name__ == '__main__':
11898
unittest.main()

0 commit comments

Comments
 (0)