Conditions | 1 |
Total Lines | 30 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import copy |
||
91 | def test_catch_all_1(): |
||
92 | def objective_function(access): |
||
93 | x = y |
||
94 | a = 1 + "str" |
||
95 | math.sqrt(-10) |
||
96 | x = 1 / 0 |
||
97 | |||
98 | return 0, {"error": False} |
||
99 | |||
100 | catch_return = (np.nan, {"error": True}) |
||
101 | |||
102 | hyper = Hyperactive() |
||
103 | hyper.add_search( |
||
104 | objective_function, |
||
105 | search_space, |
||
106 | n_iter=100, |
||
107 | catch={ |
||
108 | NameError: catch_return, |
||
109 | TypeError: catch_return, |
||
110 | ValueError: catch_return, |
||
111 | ZeroDivisionError: catch_return, |
||
112 | }, |
||
113 | ) |
||
114 | hyper.run() |
||
115 | |||
116 | nan_ = hyper.search_data(objective_function)["score"].values[0] |
||
117 | error_ = hyper.search_data(objective_function)["error"].values[0] |
||
118 | |||
119 | assert math.isnan(nan_) |
||
120 | assert error_ == True |
||
121 |