Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_driver_2():
"""Assert that the tpot_driver() in TPOT driver outputs normal result with verbosity = 1."""
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class',
'-g', '1',
'-p', '2',
'-cv', '2',
'-s',' 45',
'-config', 'TPOT light',
'-v', '1'
]
args = _get_arg_parser().parse_args(args_list)
with captured_output() as (out, err):
tpot_driver(args)
ret_stdout = out.getvalue()
assert "TPOT settings" not in ret_stdout
assert "Final Pareto front testing scores" not in ret_stdout
try:
ret_val = float(ret_stdout.split('\n')[-2].split(': ')[-1])
except Exception:
ret_val = -float('inf')
assert ret_val > 0.0
def test_driver_4():
"""Assert that the tpot_driver() in TPOT driver outputs normal result with verbosity = 3."""
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class',
'-g', '1',
'-p', '2',
'-cv', '3',
'-s', '42',
'-config', 'TPOT light',
'-v', '3'
]
args = _get_arg_parser().parse_args(args_list)
with captured_output() as (out, err):
tpot_driver(args)
ret_stdout = out.getvalue()
assert "TPOT settings" in ret_stdout
assert "Final Pareto front testing scores" in ret_stdout
try:
ret_val = float(ret_stdout.split('\n')[-2].split('\t')[1])
except Exception:
ret_val = -float('inf')
assert ret_val > 0.0
def test_driver_3():
"""Assert that the tpot_driver() in TPOT driver outputs normal result with verbosity = 2."""
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class',
'-g', '1',
'-p', '2',
'-cv', '3',
'-s',' 45',
'-config', 'TPOT light',
'-v', '2'
]
args = _get_arg_parser().parse_args(args_list)
with captured_output() as (out, err):
tpot_driver(args)
ret_stdout = out.getvalue()
assert "TPOT settings" in ret_stdout
assert "Final Pareto front testing scores" not in ret_stdout
try:
ret_val = float(ret_stdout.split('\n')[-2].split(': ')[-1])
except Exception:
ret_val = -float('inf')
assert ret_val > 0.0
# Mis-spelled target
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'clas' # typo for right target 'class'
]
args = _get_arg_parser().parse_args(args_list)
assert_raises(ValueError, _read_data_file, args=args)
# Correctly spelled target
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class'
]
args = _get_arg_parser().parse_args(args_list)
input_data = _read_data_file(args)
assert isinstance(input_data, pd.DataFrame)
def setUp(self):
self.parser = _get_arg_parser()
sklearn.__version__ <= LooseVersion("0.20.0")):
raise nose.SkipTest("Warning raised by scikit-learn")
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class',
'-o', 'test_export.py',
'-g', '1',
'-p', '2',
'-cv', '3',
'-s', '42',
'-config', 'TPOT light',
'-v', '0'
]
args = _get_arg_parser().parse_args(args_list)
with captured_output() as (out, err):
tpot_driver(args)
ret_stdout = out.getvalue()
assert ret_stdout == ""
assert path.isfile("test_export.py")
remove("test_export.py") # clean up exported file