Commit 79c1e29d authored by Manuel Günther's avatar Manuel Günther
Browse files

Improved python3 compatibility.

parent e0da0361
# import the C++ stuff
from ._boosting import StumpMachine, LUTMachine, BoostedMachine, weighted_histogram
# import trainer and loss functions
import trainer
import loss
from . import trainer
from . import loss
#import examples
#import tests
from ExponentialLoss import ExponentialLoss
from LogitLoss import LogitLoss
from TangentialLoss import TangentialLoss
from JesorskyLoss import JesorskyLoss
from .ExponentialLoss import ExponentialLoss
from .LogitLoss import LogitLoss
from .TangentialLoss import TangentialLoss
from .JesorskyLoss import JesorskyLoss
......@@ -54,7 +54,7 @@ class TestBoosting(unittest.TestCase):
# check the result
weight = 1.83178082
self.assertEqual(machine.weights.shape, (1,1))
self.assertAlmostEqual(machine.weights, -weight)
self.assertTrue(numpy.allclose(machine.weights, -weight))
self.assertEqual(len(machine.weak_machines), 1)
self.assertEqual(machine.indices, [483])
weak = machine.weak_machines[0]
......@@ -89,7 +89,7 @@ class TestBoosting(unittest.TestCase):
weight = 15.46452387
machine = booster.train(inputs.astype(numpy.uint16), aligned)
self.assertEqual(machine.weights.shape, (1,1))
self.assertAlmostEqual(machine.weights, -weight)
self.assertTrue(numpy.allclose(machine.weights, -weight))
self.assertEqual(len(machine.weak_machines), 1)
self.assertEqual(machine.indices, [379])
weak = machine.weak_machines[0]
......@@ -162,7 +162,6 @@ class TestBoosting(unittest.TestCase):
self.assertEqual(machine.weights.shape, (1,len(digits)))
self.assertTrue(numpy.allclose(machine.weights, -weights))
self.assertEqual(len(machine.weak_machines), 1)
print machine.indices
self.assertTrue(all(machine.indices == [215, 236, 264, 349]))
weak = machine.weak_machines[0]
self.assertTrue(isinstance(weak, xbob.boosting.LUTMachine))
......
from LUTTrainer import LUTTrainer
from StumpTrainer import StumpTrainer
from Boosting import Boosting
from .LUTTrainer import LUTTrainer
from .StumpTrainer import StumpTrainer
from .Boosting import Boosting
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment