Exemple #1
0
    def test_create_virtual_layout(self, layout_mock, source_mock, file_mock):
        gen = ReshapeVDSGeneratorTester(output_file="/test/path/vds.hdf5",
                                        dimensions=(5, 3, 10),
                                        alternate=None,
                                        periods=[],
                                        radices=(30, 10),
                                        target_node="full_frame",
                                        source_node="data",
                                        source_file="raw.h5",
                                        name="vds.hdf5")
        source = vdsgenerator.SourceMeta(frames=(150, ),
                                         height=256,
                                         width=2048,
                                         dtype="uint16")
        dataset_mock = MagicMock()
        self.file_mock.reset_mock()
        vds_file_mock = self.file_mock.__enter__.return_value
        vds_file_mock.__getitem__.return_value = dataset_mock

        layout = gen.create_virtual_layout(source)

        layout_mock.assert_called_once_with((5, 3, 10, 256, 2048), "uint16")
        source_mock.assert_called_once_with("raw.h5",
                                            dtype="uint16",
                                            name="data",
                                            shape=(150, 256, 2048))
Exemple #2
0
    def test_process_source_datasets_given_valid_data(self, grab_mock):
        gen = SubFrameVDSGeneratorTester(
            files=["stripe_1.h5", "stripe_2.h5"])
        expected_source = vdsgenerator.SourceMeta(
            frames=(3,), height=256, width=2048, dtype="uint16")

        source = gen.process_source_datasets()

        grab_mock.assert_has_calls([call("stripe_1.h5"), call("stripe_2.h5")])
        self.assertEqual(expected_source, source)
    def test_create_virtual_layout(self):
        gen = VDSGeneratorTester(output_file="/test/path/vds.hdf5",
                                 stripe_spacing=10, module_spacing=100,
                                 target_node="full_frame", source_node="data",
                                 datasets=["source"] * 6, name="vds.hdf5")
        source = vdsgenerator.SourceMeta(frames=(3,), height=256, width=2048,
                                         dtype="uint16")

        with self.assertRaises(NotImplementedError):
            gen.create_virtual_layout(source)
Exemple #4
0
    def test_process_source_datasets_given_valid_data(self, grab_mock):
        gen = GapFillVDSGeneratorTester(
            files=["raw.h5"])
        expected_source = vdsgenerator.SourceMeta(
            frames=(3,), height=256, width=2048, dtype="uint16")

        source = gen.process_source_datasets()

        grab_mock.assert_called_once_with("raw.h5")
        self.assertEqual(expected_source, source)
Exemple #5
0
    def test_create_virtual_layout_frame_mismatch(self):
        gen = ReshapeVDSGeneratorTester(output_file="/test/path/vds.hdf5",
                                        dimensions=(5, 3, 10),
                                        alternate=None,
                                        periods=[],
                                        radices=(30, 10),
                                        target_node="full_frame",
                                        source_node="data",
                                        source_file="raw.h5",
                                        name="vds.hdf5")
        source = vdsgenerator.SourceMeta(frames=(3, ),
                                         height=256,
                                         width=2048,
                                         dtype="uint16")

        with self.assertRaises(ValueError):
            gen.create_virtual_layout(source)
Exemple #6
0
    def test_create_virtual_layout(self, layout_mock, source_mock, file_mock):
        gen = SubFrameVDSGeneratorTester(
            output_file="/test/path/vds.hdf5",
            stripe_spacing=10, module_spacing=100,
            target_node="full_frame", source_node="data",
            files=["raw1.h5", "raw2.h5", "raw3.h5",
                   "raw4.h5", "raw5.h5", "raw6.h5"],
            name="vds.hdf5")
        source = vdsgenerator.SourceMeta(
            frames=(3,), height=256, width=2048, dtype="uint16")
        dataset_mock = MagicMock()
        self.file_mock.reset_mock()
        vds_file_mock = self.file_mock.__enter__.return_value
        vds_file_mock.__getitem__.return_value = dataset_mock

        layout = gen.create_virtual_layout(source)

        layout_mock.assert_called_once_with((3, 1766, 2048), "uint16")
        source_mock.assert_has_calls(
            [call("raw{}.h5".format(x),
                  dtype="uint16", name="data", shape=(3, 256, 2048))
             for x in range(1, 7)])
    def test_generate_vds_given_args(self):
        files = ["stripe_1.h5", "stripe_2.h5"]
        file_paths = ["/test/path/" + file_ for file_ in files]
        source_dict = dict(shape=(3, 256, 2048), dtype="int16")
        source = vdsgenerator.SourceMeta(frames=(3,), height=256, width=2048,
                                     dtype="int16")

        gen = VDSGenerator("/test/path",
                           files=files,
                           output="vds.hdf5",
                           source=source_dict,
                           source_node="entry/data/data",
                           target_node="entry/detector/detector1")

        self.assertEqual("/test/path", gen.path)
        self.assertEqual("stripe_", gen.prefix)
        self.assertEqual("vds.hdf5", gen.name)
        self.assertEqual(file_paths, gen.files)
        self.assertEqual(source, gen.source_metadata)
        self.assertEqual("entry/data/data", gen.source_node)
        self.assertEqual("entry/detector/detector1", gen.target_node)
        self.assertEqual(gen.CREATE, gen.mode)
    def test_create_virtual_layout(self, layout_mock, source_mock, file_mock):
        gen = InterleaveVDSGeneratorTester(output_file="/test/path/vds.hdf5",
                                           target_node="full_frame",
                                           source_node="data",
                                           files=["raw1.h5", "raw2.h5"],
                                           name="vds.hdf5",
                                           block_size=1)
        source = vdsgenerator.SourceMeta(frames=(3, 2),
                                         height=256,
                                         width=2048,
                                         dtype="uint16")
        dataset_mock = MagicMock()
        self.file_mock.reset_mock()
        vds_file_mock = self.file_mock.__enter__.return_value
        vds_file_mock.__getitem__.return_value = dataset_mock

        layout = gen.create_virtual_layout(source)

        layout_mock.assert_called_once_with((5, 256, 2048), "uint16")
        source_mock.assert_has_calls([
            call("raw1.h5", dtype="uint16", name="data", shape=(3, 256, 2048)),
            call("raw2.h5", dtype="uint16", name="data", shape=(2, 256, 2048))
        ],
                                     any_order=True)