def test_plot_hull(self): df = pd.read_csv(os.path.join(CAMD_TEST_FILES, "test_df_analysis.csv"), index_col="id") df['Composition'] = df['formula'] # Test 2D with ScratchDir('.'): analyzer = StabilityAnalyzer(hull_distance=0.1) filtered = filter_dataframe_by_composition(df, "TiO") analyzer.plot_hull(filtered, new_result_ids=["mp-685151", "mp-755875"], filename="hull.png") self.assertTrue(os.path.isfile("hull.png")) # Test 3D with ScratchDir('.'): analyzer.hull_distance = 0.05 filtered = filter_dataframe_by_composition(df, "TiNO") analyzer.plot_hull(filtered, new_result_ids=["mp-776280", "mp-30998"], filename="hull.png") self.assertTrue(os.path.isfile("hull.png"))
def update_run(folder): """ Updates existing runs in s3 to include plots Returns: List of modified chemsys """ required_files = ["seed_data.pickle", "report.log"] with cd(folder): if os.path.isfile("error.json"): error = loadfn("error.json") print("{} ERROR: {}".format(folder, error)) if not all([os.path.isfile(fn) for fn in required_files]): print("{} ERROR: no seed data, no analysis to be done") else: analyzer = StabilityAnalyzer(hull_distance=0.2) # Generate report plots for iteration in range(0, 25): print("{}: {}".format(folder, iteration)) if not os.path.isdir(str(iteration)) or not os.path.isdir( str(iteration - 1)): continue with open(os.path.join(str(iteration), "seed_data.pickle"), "rb") as f: result_df = pickle.load(f) all_result_ids = loadfn( os.path.join(str(iteration - 1), "consumed_candidates.json")) new_result_ids = loadfn( os.path.join(str(iteration - 1), "submitted_experiment_requests.json")) analyzer.plot_hull(df=result_df, new_result_ids=new_result_ids, all_result_ids=all_result_ids, filename="hull_{}.png".format(iteration), finalize=False) Campaign.generate_report_plot()