Ejemplo n.º 1
0
 def _port_model(self):
     """Create and compile ported model for comparison of predictions."""
     subp.call(['rm', '-rf', 'temp'])  # $ rm -rf temp
     subp.call(['mkdir', 'temp'])  # $ mkdir temp
     filename = '%s.java' % self.tmp_fn
     path = os.path.join('temp', filename)
     with open(path, 'w') as f:
         porter = Porter(method_name='predict', class_name=self.tmp_fn)
         ported_model = porter.port(self.clf)
         f.write(ported_model)
     subp.call(['javac', path])  # $ javac temp/Tmp.java
Ejemplo n.º 2
0
 def _create_java_files(self):
     """Create and compile ported model for comparison of predictions."""
     # $ rm -rf temp
     subp.call(['rm', '-rf', 'temp'])
     # $ mkdir temp
     subp.call(['mkdir', 'temp'])
     path = 'temp/%s.java' % (self.tmp_fn)
     with open(path, 'w') as file:
         porter = Porter(method_name='predict', class_name=self.tmp_fn)
         ported_model = porter.port(self.clf)
         file.write(ported_model)
     # $ javac temp/Tmp.java
     subp.call(['javac', path])
Ejemplo n.º 3
0
 def test_porter_args_language(self):
     """Test invalid programming language."""
     args = dict(method_name='predict', language='random')
     porter = Porter(args)
     self.assertRaises(AttributeError, lambda: porter.port(self.clf))
Ejemplo n.º 4
0
 def test_porter_args_method(self):
     """Test invalid method name."""
     args = dict(method_name='random')
     porter = Porter(args)
     self.assertRaises(AttributeError, lambda: porter.port(self.clf))