Version: 8.3.0
PMMLBasicsTest.PMMLBasicsTest Class Reference
Inheritance diagram for PMMLBasicsTest.PMMLBasicsTest:
Collaboration diagram for PMMLBasicsTest.PMMLBasicsTest:

Public Member Functions

def setUp
 
def tearDown
 
def testExportPythonNeuralNet
 
def testExportPythonRegression
 
def testPmmlFileNotReadable
 
def testPmmlFileNotReadable
 
def testPmmlFileNotWritable
 

Public Attributes

 resourcesDir
 
 tmpDir
 

Detailed Description

Definition at line 31 of file PMMLBasicsTest.py.

Member Function Documentation

def PMMLBasicsTest.PMMLBasicsTest.setUp (   self)

Definition at line 33 of file PMMLBasicsTest.py.

33 
34  def setUp(self):
35  self.resourcesDir = ".." + os.sep + "Test" + os.sep + "samples" + os.sep ;
36  self.tmpDir = os.sep + "tmp" + os.sep + os.environ['LOGNAME'] + os.sep ;
37  self.tmpDir += "PmmlUnitTest";
38  self.tmpDir += os.sep ;
39  if ( not os.path.exists(self.tmpDir) ):
40  os.mkdir(self.tmpDir);
41  pass
42  pass
def PMMLBasicsTest.PMMLBasicsTest.tearDown (   self)

Definition at line 43 of file PMMLBasicsTest.py.

References PMMLBasicsTest.PMMLBasicsTest.tmpDir.

43 
44  def tearDown(self):
45  if ( os.path.exists(self.tmpDir) ):
46  shutil.rmtree(self.tmpDir);
47  pass
48  pass
def PMMLBasicsTest.PMMLBasicsTest.testExportPythonNeuralNet (   self)

Definition at line 49 of file PMMLBasicsTest.py.

References PMMLBasicsTest.PMMLBasicsTest.resourcesDir, YACSPMMLBasicsTest1.resourcesDir, and PMMLBasicsTest.PMMLBasicsTest.tmpDir.

49 
50  def testExportPythonNeuralNet(self):
51  pmmlFile = self.resourcesDir + "ann_model.pmml";
52  model = "sANNName";
53  exportPyScript = self.tmpDir + "swigTestExportPythonNeuralNet.py";
54  refPyFilename = self.resourcesDir + "unittest_ref_ann_model.py";
55  refLines = file(refPyFilename).readlines();
56  #
57  p = PMMLlib( pmmlFile );
58  p.SetCurrentModel( model, kANN );
59  p.ExportPython( exportPyScript, "myTestFunc",
60  "File used by unit test\n PMMLBasicsTest1::testExportNeuralNetworkPython" );
61  myLines = file(exportPyScript).readlines();
62  self.assertEqual( len(myLines), len(refLines) );
63  for (i,line) in enumerate(myLines):
64  self.assertEqual( line, refLines[i] );
65  pass
66  pass
def PMMLBasicsTest.PMMLBasicsTest.testExportPythonRegression (   self)

Definition at line 67 of file PMMLBasicsTest.py.

References PMMLBasicsTest.PMMLBasicsTest.resourcesDir, YACSPMMLBasicsTest1.resourcesDir, and PMMLBasicsTest.PMMLBasicsTest.tmpDir.

67 
69  pmmlFile = self.resourcesDir + "lr_model.pmml";
70  model = "Modeler[LinearRegression]Tds[steamplant]Predictor[x6:x8:x6x8:x6x6x8]Target[x1]";
71  exportPyScript = self.tmpDir + "swigTestExportPythonRegression.py";
72  refPyFilename = self.resourcesDir + "unittest_ref_lr_model.py";
73  refLines = file(refPyFilename).readlines();
74  #
75  p = PMMLlib( pmmlFile );
76  p.SetCurrentModel( model, kLR );
77  p.ExportPython( exportPyScript, "myTestFunc",
78  "File used by unit test\n PMMLBasicsTest1::testExportLinearRegressionPython" );
79  myLines = file(exportPyScript).readlines();
80  self.assertEqual( len(myLines), len(refLines) );
81  for (i,line) in enumerate(myLines):
82  self.assertEqual( line, refLines[i] );
83  pass
84  pass
def PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotReadable (   self)

Definition at line 85 of file PMMLBasicsTest.py.

Referenced by PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotReadable().

85 
86  def testPmmlFileNotReadable(self):
87  self.assertRaises( RuntimeError, PMMLlib, "0.mml" );
88  pass
def PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotReadable (   self)

Definition at line 89 of file PMMLBasicsTest.py.

References PMMLBasicsTest.PMMLBasicsTest.resourcesDir, YACSPMMLBasicsTest1.resourcesDir, and PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotReadable().

89 
90  def testPmmlFileNotReadable(self):
91  pmmlFile = self.resourcesDir + "ann_model.pmml";
92  model = "sANNName";
93  p = PMMLlib(pmmlFile);
94  self.assertRaises( RuntimeError, p.SetCurrentModel, model, kLR );
95  pass
def PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotWritable (   self)

Definition at line 96 of file PMMLBasicsTest.py.

96 
97  def testPmmlFileNotWritable(self):
98  p = PMMLlib();
99  self.assertRaises( RuntimeError, p.Write );
pass

Member Data Documentation

PMMLBasicsTest.PMMLBasicsTest.resourcesDir

Definition at line 34 of file PMMLBasicsTest.py.

Referenced by PMMLBasicsTest.PMMLBasicsTest.testExportPythonNeuralNet(), PMMLBasicsTest.PMMLBasicsTest.testExportPythonRegression(), and PMMLBasicsTest.PMMLBasicsTest.testPmmlFileNotReadable().

PMMLBasicsTest.PMMLBasicsTest.tmpDir

Definition at line 35 of file PMMLBasicsTest.py.

Referenced by PMMLBasicsTest.PMMLBasicsTest.tearDown(), PMMLBasicsTest.PMMLBasicsTest.testExportPythonNeuralNet(), and PMMLBasicsTest.PMMLBasicsTest.testExportPythonRegression().


The documentation for this class was generated from the following file: