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_5(): """Assert that the tpot_driver() in TPOT driver outputs normal result with exported python file and verbosity = 0.""" # Catch FutureWarning https://github.com/scikit-learn/scikit-learn/issues/11785 if (np.__version__ >= LooseVersion("1.15.0") and 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
def test_read_data_file(): """Assert that _read_data_file raises ValueError when the targe column is missing.""" # 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 test_read_data_file(): """Assert that _read_data_file raises ValueError when the targe column is missing.""" # 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 test_driver_5(): """Assert that the tpot_driver() in TPOT driver outputs normal result with exported python file and verbosity = 0.""" 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
def setUp(self): self.parser = _get_arg_parser()