Skip to content

Commit 25d5778

Browse files
committed
Fix np.all to np.allclose in tests
1 parent e53b901 commit 25d5778

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dfols/tests/test_trust_region.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def runTest(self):
8989
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
9090
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
9191
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
92-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
92+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
9393
print(crvmin)
9494
self.assertAlmostEqual(crvmin, 1.2, 'Wrong crvmin')
9595

@@ -112,7 +112,7 @@ def runTest(self):
112112
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
113113
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
114114
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
115-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
115+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
116116
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
117117

118118

@@ -134,7 +134,7 @@ def runTest(self):
134134
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
135135
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
136136
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
137-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
137+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
138138
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
139139

140140

@@ -156,7 +156,7 @@ def runTest(self):
156156
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
157157
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
158158
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
159-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
159+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
160160
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
161161
# self.assertAlmostEqual(crvmin, crvmin_cauchy, 'Wrong crvmin')
162162

@@ -179,7 +179,7 @@ def runTest(self):
179179
# self.assertAlmostEqual(est_min, true_min, 'Wrong min value')
180180
s_cauchy, red_cauchy, crvmin_cauchy = cauchy_pt(g, H, Delta)
181181
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
182-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
182+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
183183
self.assertAlmostEqual(crvmin, 0.0, 'Wrong crvmin')
184184

185185

@@ -203,7 +203,7 @@ def runTest(self):
203203
# print(s_cauchy)
204204
# print(d)
205205
self.assertTrue(est_min <= red_cauchy, 'Cauchy reduction not achieved')
206-
self.assertTrue(np.all(gnew == g + H.dot(d)), 'Wrong gnew')
206+
self.assertTrue(np.allclose(gnew, g + H.dot(d)), 'Wrong gnew')
207207
print(crvmin)
208208
self.assertAlmostEqual(crvmin, -1.0, 'Wrong crvmin')
209209

0 commit comments

Comments
 (0)