コード例 #1
0
 def test_output(self):
     self.makeFiles()
     try:
         alg = simpleapi.DakotaChiSquared(self.datafile, self.simfile, self.chifile)
         self.assertEqual(len(alg), 2)
         self.assertEqual(alg[0], 4.5)
         self.assertEqual(alg[1].name(), "alg")
         self.assertEqual(alg[1].blocksize(), 5)
         self.assertEqual(alg[1].getNumberHistograms(), 1)
         self.assertEqual(alg[1].dataY(0)[3], 1.5)
         ads = AnalysisDataServiceImpl.Instance()
         ads.remove("alg")
         alg1 = simpleapi.DakotaChiSquared(self.datafile, self.simfile, self.chifile, ResidualsWorkspace="res")
         self.assertEqual(alg1[0], 4.5)
         self.assertEqual(alg1[1].name(), "res")
         ads.remove("res")
     except:
         assert False, "Raised an exception"
     self.cleanup()
コード例 #2
0
 def test_wrongType(self):
     self.makeFiles()
     try:
         simpleapi.DakotaChiSquared(self.datafile, 'CNCS_7860_event.nxs', self.chifile)
     except RuntimeError as e:
         self.assertNotEquals(str(e).find('Wrong workspace type for calculated file'), -1)
     except:
         assert False, "Raised the wrong exception type"
     else:
         assert False, "Didn't raise any exception"
     try:
         simpleapi.DakotaChiSquared('CNCS_7860_event.nxs', self.simfile, self.chifile)
     except RuntimeError as e:
         self.assertNotEquals(str(e).find('Wrong workspace type for data file'), -1)
     except:
         assert False, "Raised the wrong exception type"
     else:
         assert False, "Didn't raise any exception"
     self.cleanup()
コード例 #3
0
 def test_value(self):
     self.makeFiles()
     try:
         simpleapi.DakotaChiSquared(self.datafile, self.simfile, self.chifile)
         f = open(self.chifile, 'r')
         chistr = f.read()
         self.assertEqual(chistr, '4.5 obj_fn\n')
         f.close()
     except:
         assert False, "Raised an exception"
     self.cleanup()
コード例 #4
0
 def test_wrongSize(self):
     self.makeFiles()
     try:
         simpleapi.DakotaChiSquared(self.datafile, self.simwrongfile, self.chifile)
     except RuntimeError as e:
         self.assertNotEquals(str(e).find('The file sizes are different'), -1)
     except:
         assert False, "Raised the wrong exception type"
     else:
         assert False, "Didn't raise any exception"
     self.cleanup()