def test_unzip_and_convert_metadata(self): file_zip = os.path.join(TestAsvJsonText.data, 'results2.zip') temp = get_temp_folder(__file__, 'temp_unzip_and_convert_metadata') create_asv_benchmark(location=temp, models={'LogisticRegression', 'LinearRegression'}) unzip_files(file_zip, temp) data = os.path.join(temp, 'results') conf = os.path.join(temp, 'asv.conf.json') exp = export_asv_json(data, baseline="skl", conf=conf) par_problem = [] par_scenario = [] for row in exp: if 'par_problem' in row: par_problem.append(row['par_problem']) if 'par_scenario' in row: par_scenario.append(row['par_scenario']) s = set(par_scenario) self.assertEqual(s, {'default', 'liblinear'}) s = set(par_problem) self.assertEqual(s, { 'm-cl', '~m-reg-64', 'b-cl', 'm-reg', 'b-reg', '~b-cl-64', '~b-reg-64' }) out = os.path.join(temp, "df.xlsx") df = pandas.DataFrame(exp) df.to_excel(out)
def test_cli_asv2csv(self): temp = get_temp_folder(__file__, "temp_asv2csv") file_zip = os.path.join(TestCliAsvBench.data, 'results.zip') unzip_files(file_zip, temp) data = os.path.join(temp, 'results') out = os.path.join(temp, "data.csv") st = BufferedPrint() main(args=["asv2csv", "-f", data, "-o", out], fLOG=st.fprint) self.assertExists(out) df = pandas.read_csv(out) self.assertEqual(df.shape, (168, 66)) out = os.path.join(temp, "data<date>.csv") main(args=["asv2csv", "-f", data, "-o", out], fLOG=st.fprint)
def test_unzip_and_convert(self): file_zip = os.path.join(TestAsvJsonText.data, 'results.zip') temp = get_temp_folder(__file__, 'temp_unzip_and_convert') unzip_files(file_zip, temp) data = os.path.join(temp, 'results') exp = export_asv_json(data, baseline="skl") self.assertIsInstance(exp, list) self.assertTrue(all(map(lambda x: isinstance(x, dict), exp))) cc = 0 for e in exp: ms = [k for k in e if k.startswith("M-")] rs = [k for k in e if k.startswith("R-")] if len(ms) > 0 and len(rs) > 0: cc += 1 if cc == 0: raise AssertionError("No rs")
def test_process_data(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") if is_travis_or_appveyor(): warnings.warn("disabled on appveyor and travis") return temp = get_temp_folder(__file__, "temp_process_data_cresus_2016") import keyring pwd = keyring.get_password( "cresus", os.environ["COMPUTERNAME"] + "ensae") assert pwd name = cresus_dummy_file() if not os.path.exists(name): raise FileNotFoundError(name) zipname = os.path.join(temp, "bdd.zip") pwd = pwd.encode("ascii") decrypt_stream(pwd, name, zipname) res = unzip_files(zipname, temp) fLOG(res) infile = res[0] train, test = process_cresus_whole_process( infile, outfold=temp, fLOG=fLOG) for r in train.values(): df = pandas.read_csv(r, sep="\t", encoding="utf-8") fLOG(df.columns)