Commit 1a820516 authored by payno's avatar payno

[unit test] add unit test for image shift

parent e673e094
......@@ -30,6 +30,7 @@ __date__ = "29/05/2017"
import unittest
from . import test_experiment
from . import test_geometry
from . import test_image
from . import test_mask
from . import test_operation
......@@ -39,6 +40,7 @@ def suite():
test_suite.addTests([
test_experiment.suite(),
test_geometry.suite(),
test_image.suite(),
test_mask.suite(),
test_operation.suite(),
])
......
......@@ -29,7 +29,7 @@ __date__ = "03/10/2018"
import unittest
from id06workflow.core.experiment.operation import OverwritingOperation, AdditiveOperation
from id06workflow.core.experiment.operation import OverwritingOperation, AdditiveOperation, shift
from id06workflow.core.experiment import Experiment, Dataset
from id06workflow.test import utils
import shutil
......@@ -72,9 +72,63 @@ class TestOperation(unittest.TestCase):
additiveOperation.data = 'toto'
class TestCOM(unittest.TestCase):
"""
Test center of mass operation
"""
def setUp(self):
unittest.TestCase.setUp(self)
dims = (100, 100)
pattern = numpy.zeros(dims)
background = numpy.random.random(dims)
self._dir = tempfile.mkdtemp()
dataset = utils.createDataset(_dir=self._dir,
pattern=pattern,
background=background,
nb_data_files=10,
nb_flat_field_files=1)
self.experiment = Experiment(dataset=dataset)
def tearDown(self):
self.experiment = None
shutil.rmtree(self._dir)
def testResult(self):
pass
class TestShift(unittest.TestCase):
"""Test shift operation"""
def setUp(self):
unittest.TestCase.setUp(self)
dims = (10, 10)
pattern = numpy.zeros(dims)
background = numpy.random.random(dims)
self._dir = tempfile.mkdtemp()
dataset = utils.createDataset(_dir=self._dir,
pattern=pattern,
background=background,
nb_data_files=2,
nb_flat_field_files=1)
self.experiment = Experiment(dataset=dataset)
def testPracticalResult(self):
original_data = self.experiment.data.copy()
operation = shift.Shift(self.experiment, dx=1.0, dy=-1.0, dz=0)
shifted_data = operation.compute()
self.assertTrue(numpy.allclose(original_data[1, :-1, 1:],
shifted_data[1, 1:, :-1]))
class TestOperationStream(unittest.TestCase):
"""Test some default operation streaming"""
pass
def suite():
test_suite = unittest.TestSuite()
for ui in (TestOperation, ):
for ui in (TestOperation, TestCOM, TestShift, TestOperationStream):
test_suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(ui))
return test_suite
......
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