File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 44from bayes_opt import BayesianOptimization
55from bayes_opt .logger import ScreenLogger
66from bayes_opt .event import Events , DEFAULT_EVENTS
7-
7+ import pickle
8+ import os
89
910def target_func (** kwargs ):
1011 # arbitrary target func
@@ -320,6 +321,21 @@ def test_single_value_objective():
320321 )
321322
322323
324+ def test_pickle ():
325+ """
326+ several users have asked that the BO object be 'pickalable'
327+ This tests that this is the case
328+ """
329+ optimizer = BayesianOptimization (
330+ f = None ,
331+ pbounds = {'x' : (- 10 , 10 )},
332+ verbose = 2 ,
333+ random_state = 1 ,
334+ )
335+ with open ("test_dump.obj" , "wb" ) as filehandler :
336+ pickle .dump (optimizer , filehandler )
337+ os .remove ('test_dump.obj' )
338+
323339if __name__ == '__main__' :
324340 r"""
325341 CommandLine:
You can’t perform that action at this time.
0 commit comments