optimize.tests.test__basinhopping

Unit tests for the basin hopping global minimization algorithm.

Module Contents

Classes

MyTakeStep1(self) use a copy of displace, but have it set a special parameter to
MyAcceptTest(self) pass a custom accept test
MyCallBack(self) pass a custom callback function
TestBasinHopping()
Test_Storage()
Test_RandomDisplacement()
Test_Metropolis()
Test_AdaptiveStepsize()

Functions

func1d(x)
func1d_nograd(x)
func2d_nograd(x)
func2d(x)
func2d_easyderiv(x)
myTakeStep2(x) redo RandomDisplacement in function form without the attribute stepsize
func1d(x)
func1d_nograd(x)
func2d_nograd(x)
func2d(x)
func2d_easyderiv(x)
class MyTakeStep1

use a copy of displace, but have it set a special parameter to make sure it’s actually being used.

__init__()
__call__(x)
myTakeStep2(x)

redo RandomDisplacement in function form without the attribute stepsize to make sure still everything works ok

class MyAcceptTest

pass a custom accept test

This does nothing but make sure it’s being used and ensure all the possible return values are accepted

__init__()
__call__(**kwargs)
class MyCallBack

pass a custom callback function

This makes sure it’s being used. It also returns True after 10 steps to ensure that it’s stopping early.

__init__()
__call__(x, f, accepted)
class TestBasinHopping
setup_method()

Tests setup.

Run tests based on the 1-D and 2-D functions described above.

test_TypeError()
test_1d_grad()
test_2d()
test_njev()
test_jac()
test_2d_nograd()
test_all_minimizers()
test_all_nograd_minimizers()
test_pass_takestep()
test_pass_simple_takestep()
test_pass_accept_test()
test_pass_callback()
test_minimizer_fail()
test_niter_zero()
test_seed_reproducibility()
class Test_Storage
setup_method()
test_higher_f_rejected()
test_lower_f_accepted()
class Test_RandomDisplacement
setup_method()
test_random()
class Test_Metropolis
setup_method()
test_boolean_return()
test_lower_f_accepted()
test_KeyError()
test_accept()
test_GH7495()
class Test_AdaptiveStepsize
setup_method()
test_adaptive_increase()
test_adaptive_decrease()
test_all_accepted()
test_all_rejected()