コード例 #1
0
ファイル: test_plotter.py プロジェクト: CompRhys/pymatgen
 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)
コード例 #2
0
 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)
コード例 #3
0
ファイル: test_plotter.py プロジェクト: bocklund/pymatgen
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)
コード例 #4
0
ファイル: test_plotter.py プロジェクト: xueyang94/pymatgen
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)
コード例 #5
0
 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)
コード例 #6
0
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")
コード例 #7
0
ファイル: test_plotter.py プロジェクト: ExpHP/pymatgen
 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)
コード例 #8
0
ファイル: test_plotter.py プロジェクト: ExpHP/pymatgen
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")