def test_fake_data_source(self): graph = lazyflow.graph.Graph() reader = OperatorWrapper(OpDataSelection, graph=graph, operator_kwargs={'forceAxisOrder': False}) reader.ProjectFile.setValue(self.projectFile) reader.WorkingDirectory.setValue(os.getcwd()) reader.ProjectDataGroup.setValue('DataSelection/local_data') info = DatasetInfo() # Will be read from the filesystem since the data won't be found in the project file. info.location = DatasetInfo.Location.ProjectInternal info.filePath = self.testRawDataFileName info.internalPath = "" info.invertColors = False info.convertToGrayscale = False # Use *fake* data source info.realDataSource = False info.axistags = vigra.defaultAxistags('tczyx') info.laneShape = self.imgData.shape info.laneDtype = self.imgData.dtype reader.Dataset.setValues([info]) # Verify that now data selection operator returns fake data # with expected shape and type imgData = reader.Image[0][...].wait() assert imgData.shape == self.imgData.shape assert imgData.dtype == self.imgData.dtype expected_fake_data = numpy.zeros(info.laneShape, dtype=info.laneDtype) numpy.testing.assert_array_equal(imgData, expected_fake_data)
def test_real_data_source(self): graph = lazyflow.graph.Graph() reader = OperatorWrapper(OpDataSelection, graph=graph, operator_kwargs={'forceAxisOrder': False}) reader.ProjectFile.setValue(self.projectFile) reader.WorkingDirectory.setValue(os.getcwd()) reader.ProjectDataGroup.setValue('DataSelection/local_data') info = DatasetInfo() # Will be read from the filesystem since the data won't be found in the project file. info.location = DatasetInfo.Location.ProjectInternal info.filePath = self.testRawDataFileName info.internalPath = "" info.invertColors = False info.convertToGrayscale = False #Use real data source info.realDataSource = True reader.Dataset.setValues([info]) # Read the test file using the data selection operator and verify the contents imgData = reader.Image[0][...].wait() assert imgData.shape == self.imgData.shape numpy.testing.assert_array_equal(imgData, self.imgData)