for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import copy
import pytest
import math
import numpy as np
import pandas as pd
from hyperactive import Hyperactive
search_space = {
"x1": list(np.arange(-100, 100, 1)),
}
def test_catch_0():
def objective_function(access):
x = y
y
return 0
hyper = Hyperactive()
hyper.add_search(
objective_function,
search_space,
n_iter=100,
catch={NameError: np.nan},
)
hyper.run()
def test_catch_1():
a = 1 + "str"
catch={TypeError: np.nan},
def test_catch_2():
math.sqrt(-10)
catch={ValueError: np.nan},
def test_catch_3():
x = 1 / 0
catch={ZeroDivisionError: np.nan},
def test_catch_all_0():
catch={
NameError: np.nan,
TypeError: np.nan,
ValueError: np.nan,
ZeroDivisionError: np.nan,
},
nan_ = hyper.search_data(objective_function)["score"].values[0]
assert math.isnan(nan_)
def test_catch_all_1():
return 0, {"error": False}
catch_return = (np.nan, {"error": True})
NameError: catch_return,
TypeError: catch_return,
ValueError: catch_return,
ZeroDivisionError: catch_return,
error_ = hyper.search_data(objective_function)["error"].values[0]
assert error_ == True