示例#1
0
class TestOsziCar(unittest.TestCase):

    def setUp(self):
        #create an instance of OSZICAR file
        self.x = OsziCar('../testdata/OSZICAR')

    def test_attrs(self):
        "Make sure load() effects"
        for var in self.x.vars:
            self.assertTrue(hasattr(self.x, var))

        #should raise an exception for an AttributeError
        self.assertRaises(AttributeError)

    def test_esort(self):
        "Make sure the esort() effects"
        srted = self.x.esort('E0', 2)
        shouldbe = np.array([(-101.21186, 326), (-101.21116, 324)],
                            dtype=[('var', '<f8'), ('step', '<i4')])
        self.assertTrue((srted == shouldbe).all())

    def test_plot(self):
        "Make sure object could plot"
        plot = self.x.plot('E0', mode='save')
        self.assertTrue(isinstance(plot, matplotlib.figure.Figure))
示例#2
0
class OsziCarTest(unittest.TestCase):

    def setUp(self):
        #create an instance of OSZICAR file
        self.x = OsziCar('./testdata/OSZICAR')

    def test_attrs(self):
        "Make sure load() effects"
        for var in self.x.vars:
            self.assertTrue(hasattr(self.x, var))

        #should raise an exception for an AttributeError
        self.assertRaises(AttributeError)

    def test_esort(self):
        "Make sure the esort() effects"
        srted = self.x.esort('E0', 2)
        shouldbe = np.array([(-101.21186, 326), (-101.21116, 324)],
                            dtype=[('var', '<f8'), ('step', '<i4')])
        self.assertTrue((srted == shouldbe).all())

    def test_plot(self):
        "Make sure object could plot"
        plot = self.x.plot('E0', mode='save')
        self.assertTrue(isinstance(plot, matplotlib.figure.Figure))
示例#3
0
 def test_plot(self):
     "Make sure object could plot"
     filename = path + "/OSZICAR"
     oszicar = OsziCar(filename)
     plot = oszicar.plot('E0', mode='save')
     self.assertTrue(isinstance(plot, matplotlib.figure.Figure))
     # Remove picture.
     os.remove("E0_vs_step.png")
示例#4
0
 def test_plot(self):
     "Make sure object could plot"
     filename = path + "/OSZICAR"
     oszicar = OsziCar(filename) 
     plot = oszicar.plot('E0', mode='save')
     self.assertTrue(isinstance(plot, matplotlib.figure.Figure))
     # Remove picture.
     os.remove("E0_vs_step.png")