def test_scraping_and_plotting(self):
    from matador.plotting.convergence_plotting import get_convergence_data, get_convergence_files, combine_convergence_data, get_convergence_values
    from matador.plotting.convergence_plotting import plot_cutoff_kpt_grid
    kpt_files = get_convergence_files('completed_kpts')
    cutoff_files = get_convergence_files('completed_cutoff')
    kpt_data = get_convergence_data(kpt_files, conv_parameter='kpoints_mp_spacing', species=['Li'])
    cutoff_data = get_convergence_data(cutoff_files, conv_parameter='cut_off_energy', species=['Li'])
    data = combine_convergence_data(kpt_data, cutoff_data)
    self.assertEqual(data['Li-bcc']['kpoints_mp_spacing']['kpoints_mp_spacing'], [0.1, 0.07])
    self.assertEqual(data['Li-bcc']['cut_off_energy']['cut_off_energy'], [300, 400])
    (values, parameters) = get_convergence_values(data['Li-bcc'], 'cut_off_energy', 'formation_energy_per_atom', log=True)
    self.assertEqual(parameters.tolist(), [300.0, 400.0])
    self.assertAlmostEqual(values.tolist()[0], 0.7291198427497395, places=6)
    self.assertEqual(values.tolist()[1], (- np.inf))
    self.data = data
    expected_files = ['conv.svg']
    for expected_file in expected_files:
        if os.path.isfile(expected_file):
            os.remove(expected_file)
    plot_cutoff_kpt_grid(self.data, svg=True)
    for file in expected_files:
        self.assertTrue(os.path.isfile(file))
    for expected_file in expected_files:
        os.remove(expected_file)
def test_scraping_and_plotting(self):
    from matador.plotting.convergence_plotting import get_convergence_data, get_convergence_files, combine_convergence_data, get_convergence_values
    from matador.plotting.convergence_plotting import plot_cutoff_kpt_grid
    kpt_files = get_convergence_files('completed_kpts')
    cutoff_files = get_convergence_files('completed_cutoff')
    kpt_data = get_convergence_data(kpt_files, conv_parameter='kpoints_mp_spacing', species=['Li'])
    cutoff_data = get_convergence_data(cutoff_files, conv_parameter='cut_off_energy', species=['Li'])
    data = combine_convergence_data(kpt_data, cutoff_data)
    self.assertEqual(data['Li-bcc']['kpoints_mp_spacing']['kpoints_mp_spacing'], [0.1, 0.07])
    self.assertEqual(data['Li-bcc']['cut_off_energy']['cut_off_energy'], [300, 400])
    (values, parameters) = get_convergence_values(data['Li-bcc'], 'cut_off_energy', 'formation_energy_per_atom', log=True)
    self.assertEqual(parameters.tolist(), [300.0, 400.0])
    self.assertAlmostEqual(values.tolist()[0], 0.7291198427497395, places=6)
    self.assertEqual(values.tolist()[1], (- np.inf))
    self.data = data
    expected_files = ['conv.svg']
    for expected_file in expected_files:
        if os.path.isfile(expected_file):
            os.remove(expected_file)
    plot_cutoff_kpt_grid(self.data, svg=True)
    for file in expected_files:
        self.assertTrue(os.path.isfile(file))
    for expected_file in expected_files:
        os.remove(expected_file)