def test(self): from lazyflow.graph import Graph, MetaDict from lazyflow.operators import OpArrayPiper graph = Graph() opDataSource = OpArrayPiper(graph=graph) opDataSource.Input.setValue(numpy.ndarray((9, 10), dtype=numpy.uint8)) # Create some metadata shape = (1, 2, 3, 4, 5) data = numpy.indices(shape, dtype=int).sum(0) meta = MetaDict() meta.specialdata = "Salutations" meta.notsospecial = "Hey" opProvider = OpOutputProvider(data, meta, graph=graph) op = OpMetadataMerge(graph=graph) op.Input.connect(opDataSource.Output) op.MetadataSource.connect(opProvider.Output) op.FieldsToClone.setValue(["specialdata"]) assert op.Output.ready() assert op.Output.meta.shape == opDataSource.Output.meta.shape assert op.Output.meta.dtype == opDataSource.Output.meta.dtype assert op.Output.meta.specialdata == meta.specialdata assert op.Output.meta.notsospecial is None
def test(self): from lazyflow.graph import Graph, MetaDict g = Graph() # Create some data to give shape = (1,2,3,4,5) data = numpy.indices(shape, dtype=int).sum(0) meta = MetaDict() meta.axistags = vigra.defaultAxistags( 'xtycz' ) meta.shape = shape meta.dtype = int opProvider = OpOutputProvider( data, meta, graph=g ) assert (opProvider.Output[0:1, 1:2, 0:3, 2:4, 3:5].wait() == data[0:1, 1:2, 0:3, 2:4, 3:5]).all() for k,v in meta.items(): if k != '_ready' and k != '_dirty': assert opProvider.Output.meta[k] == v
def test(self): from lazyflow.graph import Graph, MetaDict g = Graph() # Create some data to give shape = (1, 2, 3, 4, 5) data = numpy.indices(shape, dtype=int).sum(0) meta = MetaDict() meta.axistags = vigra.defaultAxistags('xtycz') meta.shape = shape meta.dtype = int opProvider = OpOutputProvider(data, meta, graph=g) op = OpMetadataSelector(graph=g) op.Input.connect(opProvider.Output) op.MetadataKey.setValue('shape') assert op.Output.value == shape op.MetadataKey.setValue('axistags') assert op.Output.value == meta.axistags