def testStaibDatfileTextVal(self): """fileText data should match the data in the file.""" # open the data file and turn it into a list with readlines. datFile = open(self.filename, "r") fileTextList = datFile.readlines() datFile.close() SD = StaibDat(self.filename) self.assertEqual(fileTextList, SD["fileText"])
def testStaibDatC2Values(self): """C2 array should have the proper values.""" SD = StaibDat(self.filename) C2Array = numpy.array(SD["Channel_2"]["value"]) self.assertTrue(all(C2Array == SD["C2"]))
def testStaibDatC2Size(self): """C2 array should be the correct size.""" SD = StaibDat(self.filename) self.assertEqual(SD["C2"].shape[0], SD["DataPoints"])
def testStaibDatC2Array(self): """C2 data should be a numpy array.""" SD = StaibDat(self.filename) self.assertEqual(type(SD["C2"]), numpy.ndarray)
def testStaibDatC2Exist(self): """C2 key should exist.""" SD = StaibDat(self.filename) self.assertTrue("C2" in SD)
def testStaibDatsmoothSize(self): """smooth should return an array of the same size as what it was given""" SD = StaibDat(self.filename) self.assertEqual(SD.smooth("C1").shape[0],SD["C1"].shape[0])
def testStaibDatdifferentiateSize(self): """differentiate should return an array of the same size as what it was given""" SD = StaibDat(self.filename) self.assertEqual(SD.differentiate("C1").shape[0], SD["C1"].shape[0])
def testStaibDatsmoothInvalidKey(self): """smooth should fail if its given a key that doesn't refer to a numpy array""" SD = StaibDat(self.filename) self.assertRaises(TypeError, StaibDat.smooth, "fileText")
def testStaibDatfileTextStr(self): """fileText data should be a string.""" SD = StaibDat(self.filename) self.assertEqual(type(SD["fileText"]), type(list()))
def testStaibDatfilenameVal(self): """filename data should match instantiating string.""" SD = StaibDat(self.filename) self.assertEqual(SD["filename"], self.filename)
def testStaibDatfileTextExist(self): """fileText key should exist.""" SD = StaibDat(self.filename) self.assertTrue("fileText" in SD)
def testStaibDatfilenameStr(self): """filename data should be a string.""" SD = StaibDat(self.filename) self.assertEqual(type(SD["filename"]), type(str()))
def testStaibDatdifferentiateSize(self): """differentiate should return an array of the same size as what it was given""" SD = StaibDat(self.filename) self.assertEqual(SD.differentiate("C1").shape[0],SD["C1"].shape[0])
def testStaibDatdifferentiateArray(self): """differentiate should return a numpy array""" SD = StaibDat(self.filename) self.assertEqual(type(SD.differentiate("C1")),numpy.ndarray)
def testStaibDatsmoothArray(self): """smooth should return a numpy array""" SD = StaibDat(self.filename) self.assertEqual(type(SD.smooth("C1")), numpy.ndarray)
def testStaibDatKEValues(self): """KE array should have the proper values.""" SD = StaibDat(self.filename) KEArray = numpy.array(SD["Basis"]["value"]) / 1000 self.assertTrue(all(KEArray == SD["KE"]))
def testStaibDatsmoothSize(self): """smooth should return an array of the same size as what it was given""" SD = StaibDat(self.filename) self.assertEqual(SD.smooth("C1").shape[0], SD["C1"].shape[0])
def testStaibDatBEExist(self): """BE key should exist.""" SD = StaibDat(self.filename) self.assertTrue("BE" in SD)
def testStaibDatdifferentiateArray(self): """differentiate should return a numpy array""" SD = StaibDat(self.filename) self.assertEqual(type(SD.differentiate("C1")), numpy.ndarray)
def testStaibDatBEValues(self): """BE array should have the proper values.""" SD = StaibDat(self.filename) BEArray = SD["SourceEnergy"] - (numpy.array(SD["Basis"]["value"]) / 1000) self.assertTrue(all(BEArray == SD["BE"]))
def testStaibDatdifferentiateInvalidKey(self): """differentiate should fail if its given a key that doesn't refer to a numpy array""" SD = StaibDat(self.filename) self.assertRaises(TypeError, StaibDat.differentiate, "fileText")
def testStaibDatsmoothArray(self): """smooth should return a numpy array""" SD = StaibDat(self.filename) self.assertEqual(type(SD.smooth("C1")),numpy.ndarray)