Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

TST: replace assertGreater/Less by assertTrue in basinhopping unittests #483

Closed
wants to merge 1 commit into from

2 participants

Denis Laxalde Ralf Gommers
Denis Laxalde
Collaborator

assertGreater/Less methods (of TestCase) come from unittests2 which is only
available in python2.7 by default. basinhopping tests fail otherwise on 2.6.

Denis Laxalde dlax TST: replace assertGreater/Less by assertTrue in basinhopping unittests
assertGreater/Less methods (of TestCase) come from unittests2 which is only
available in python2.7 by default. basinhopping tests fail otherwise on 2.6.
34323f2
Ralf Gommers
Owner

Guess that should be fixed in 0.12.x as well then.

In general I'm not a fan of TestCase methods, I'd prefer assert_ over self.assertTrue. But that's nitpicking, this PR can be merged.

Denis Laxalde
Collaborator

Applied in f031383. I'll fix 0.12 as well.

Denis Laxalde dlax closed this
Ralf Gommers
Owner

thanks!

Clemens ClemensFMN referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Denis Laxalde dlax deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2013
  1. Denis Laxalde

    TST: replace assertGreater/Less by assertTrue in basinhopping unittests

    dlax authored
    assertGreater/Less methods (of TestCase) come from unittests2 which is only
    available in python2.7 by default. basinhopping tests fail otherwise on 2.6.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 scipy/optimize/tests/test__basinhopping.py
12 scipy/optimize/tests/test__basinhopping.py
View
@@ -171,7 +171,7 @@ def test_2d(self):
res = basinhopping(func2d, self.x0[i], minimizer_kwargs=self.kwargs,
niter=self.niter, disp=self.disp)
assert_almost_equal(res.x, self.sol[i], self.tol)
- self.assertGreater(res.nfev, 0)
+ self.assertTrue(res.nfev > 0)
def test_njev(self):
# test njev is returned correctly
@@ -182,7 +182,7 @@ def test_njev(self):
res = basinhopping(func2d, self.x0[i],
minimizer_kwargs=minimizer_kwargs, niter=self.niter,
disp=self.disp)
- self.assertGreater(res.nfev, 0)
+ self.assertTrue(res.nfev > 0)
self.assertEqual(res.nfev, res.njev)
def test_2d_nograd(self):
@@ -345,7 +345,7 @@ def test_adaptive_increase(self):
for i in range(self.takestep.interval):
self.takestep(x)
self.takestep.report(True)
- self.assertGreater(self.ts.stepsize, self.stepsize)
+ self.assertTrue(self.ts.stepsize > self.stepsize)
def test_adaptive_decrease(self):
#if few steps are rejected, the stepsize should increase
@@ -355,7 +355,7 @@ def test_adaptive_decrease(self):
for i in range(self.takestep.interval):
self.takestep(x)
self.takestep.report(False)
- self.assertLess(self.ts.stepsize, self.stepsize)
+ self.assertTrue(self.ts.stepsize < self.stepsize)
def test_all_accepted(self):
#test that everything works OK if all steps were accepted
@@ -363,7 +363,7 @@ def test_all_accepted(self):
for i in range(self.takestep.interval + 1):
self.takestep(x)
self.takestep.report(True)
- self.assertGreater(self.ts.stepsize, self.stepsize)
+ self.assertTrue(self.ts.stepsize > self.stepsize)
def test_all_rejected(self):
#test that everything works OK if all steps were rejected
@@ -371,7 +371,7 @@ def test_all_rejected(self):
for i in range(self.takestep.interval + 1):
self.takestep(x)
self.takestep.report(False)
- self.assertLess(self.ts.stepsize, self.stepsize)
+ self.assertTrue(self.ts.stepsize < self.stepsize)
if __name__ == "__main__":
Something went wrong with that request. Please try again.