def setUp(self): with open( os.path.join(PymatgenTest.TEST_FILES_DIR, "NaCl_complete_ph_dos.json")) as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True) self.plotter_nostack = PhononDosPlotter(sigma=0.2, stack=False)
def save_plot_dos(self, filename, img_format="eps", units="thz", label="total dos"): plotter2 = PhononDosPlotter(stack=False, sigma=None) plotter2.add_dos(label=label, dos=self.phonon_dos_pymatgen) plotter2.save_plot(filename=filename, img_format=img_format, units=units)
class PhononDosPlotterTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True) def test_add_dos_dict(self): d = self.plotter.get_dos_dict() self.assertEqual(len(d), 0) self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() self.assertEqual(len(d), 2) def test_get_dos_dict(self): self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() for el in ["Na", "Cl"]: self.assertIn(el, d)
def setUp(self): with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True)
class PhononDosPlotterTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True) def test_add_dos_dict(self): d = self.plotter.get_dos_dict() self.assertEqual(len(d), 0) self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() self.assertEqual(len(d), 2) def test_get_dos_dict(self): self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() for el in ["Na", "Cl"]: self.assertIn(el, d) def test_plot(self): # Disabling latex for testing. from matplotlib import rc rc('text', usetex=False) self.plotter.add_dos("Total", self.dos) self.plotter.get_plot(units="mev")
def setUp(self): with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True) self.plotter_nostack = PhononDosPlotter(sigma=0.2, stack=False)
class PhononDosPlotterTest(unittest.TestCase): def setUp(self): with open(os.path.join(test_dir, "NaCl_complete_ph_dos.json"), "r") as f: self.dos = CompletePhononDos.from_dict(json.load(f)) self.plotter = PhononDosPlotter(sigma=0.2, stack=True) self.plotter_nostack = PhononDosPlotter(sigma=0.2, stack=False) def test_add_dos_dict(self): d = self.plotter.get_dos_dict() self.assertEqual(len(d), 0) self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() self.assertEqual(len(d), 2) def test_get_dos_dict(self): self.plotter.add_dos_dict(self.dos.get_element_dos(), key_sort_func=lambda x: x.X) d = self.plotter.get_dos_dict() for el in ["Na", "Cl"]: self.assertIn(el, d) def test_plot(self): # Disabling latex for testing. from matplotlib import rc rc('text', usetex=False) self.plotter.add_dos("Total", self.dos) self.plotter.get_plot(units="mev") self.plotter_nostack.add_dos("Total", self.dos) self.plotter_nostack.get_plot(units="mev")