Ejemplo n.º 1
0
class PhononBSPlotterTest(unittest.TestCase):

    def setUp(self):
        with open(os.path.join(test_dir, "NaCl_phonon_bandstructure.json"), "r") as f:
            d = json.loads(f.read())
            self.bs = PhononBandStructureSymmLine.from_dict(d)
            self.plotter = PhononBSPlotter(self.bs)

    def test_bs_plot_data(self):
        self.assertEqual(len(self.plotter.bs_plot_data()['distances'][0]), 51,
                         "wrong number of distances in the first branch")
        self.assertEqual(len(self.plotter.bs_plot_data()['distances']), 4,
                         "wrong number of branches")
        self.assertEqual(
            sum([len(e) for e in self.plotter.bs_plot_data()['distances']]),
            204, "wrong number of distances")
        self.assertEqual(self.plotter.bs_plot_data()['ticks']['label'][4], "Y",
                         "wrong tick label")
        self.assertEqual(len(self.plotter.bs_plot_data()['ticks']['label']),
                         8, "wrong number of tick labels")

    def test_plot(self):
        # Disabling latex for testing.
        from matplotlib import rc
        rc('text', usetex=False)
        self.plotter.get_plot(units="mev")
Ejemplo n.º 2
0
class PhononBSPlotterTest(unittest.TestCase):

    def setUp(self):
        with open(os.path.join(test_dir, "NaCl_phonon_bandstructure.json"), "r") as f:
            d = json.loads(f.read())
            self.bs = PhononBandStructureSymmLine.from_dict(d)
            self.plotter = PhononBSPlotter(self.bs)

    def test_bs_plot_data(self):
        self.assertEqual(len(self.plotter.bs_plot_data()['distances'][0]), 51,
                         "wrong number of distances in the first branch")
        self.assertEqual(len(self.plotter.bs_plot_data()['distances']), 4,
                         "wrong number of branches")
        self.assertEqual(
            sum([len(e) for e in self.plotter.bs_plot_data()['distances']]),
            204, "wrong number of distances")
        self.assertEqual(self.plotter.bs_plot_data()['ticks']['label'][4], "Y",
                         "wrong tick label")
        self.assertEqual(len(self.plotter.bs_plot_data()['ticks']['label']),
                         8, "wrong number of tick labels")

    def test_plot(self):
        # Disabling latex for testing.
        from matplotlib import rc
        rc('text', usetex=False)
        self.plotter.get_plot(units="mev")
Ejemplo n.º 3
0
class PhononBSPlotterTest(unittest.TestCase):
    def setUp(self):
        with open(
                os.path.join(PymatgenTest.TEST_FILES_DIR,
                             "NaCl_phonon_bandstructure.json")) as f:
            d = json.loads(f.read())
            self.bs = PhononBandStructureSymmLine.from_dict(d)
            self.plotter = PhononBSPlotter(self.bs)

    def test_bs_plot_data(self):
        self.assertEqual(
            len(self.plotter.bs_plot_data()["distances"][0]),
            51,
            "wrong number of distances in the first branch",
        )
        self.assertEqual(len(self.plotter.bs_plot_data()["distances"]), 4,
                         "wrong number of branches")
        self.assertEqual(
            sum(len(e) for e in self.plotter.bs_plot_data()["distances"]),
            204,
            "wrong number of distances",
        )
        self.assertEqual(self.plotter.bs_plot_data()["ticks"]["label"][4], "Y",
                         "wrong tick label")
        self.assertEqual(
            len(self.plotter.bs_plot_data()["ticks"]["label"]),
            8,
            "wrong number of tick labels",
        )

    def test_plot(self):
        # Disabling latex for testing.
        from matplotlib import rc

        rc("text", usetex=False)
        self.plotter.get_plot(units="mev")

    def test_plot_compare(self):
        # Disabling latex for testing.
        from matplotlib import rc

        rc("text", usetex=False)
        self.plotter.plot_compare(self.plotter, units="mev")