def testOutput(self): graph = Graph() data = numpy.random.random( (1,100,100,10,1) ) opProvider = OpArrayPiper(graph=graph) opProvider.Input.setValue(data) opSubRegion = OpSubRegion( graph=graph ) opSubRegion.Input.connect( opProvider.Output ) opSubRegion.Roi.setValue( ((0,20,30,5,0), (1,30,50,8,1)) ) subData = opSubRegion.Output( start=( 0,5,10,1,0 ), stop=( 1,10,20,3,1 ) ).wait() assert (subData == data[0:1, 25:30, 40:50, 6:8, 0:1]).all()
def testOutput_masked(self): graph = Graph() data = numpy.random.random( (1,100,100,10,1) ) data = numpy.ma.masked_array(data, mask=numpy.ma.getmaskarray(data), fill_value=data.dtype.type(numpy.nan), shrink=False ) data[:, 25] = numpy.ma.masked opProvider = OpArrayPiper(graph=graph) opProvider.Input.setValue(data) opSubRegion = OpSubRegion( graph=graph ) opSubRegion.Input.connect( opProvider.Output ) opSubRegion.Roi.setValue( ((0,20,30,5,0), (1,30,50,8,1)) ) subData = opSubRegion.Output( start=( 0,5,10,1,0 ), stop=( 1,10,20,3,1 ) ).wait() assert (subData == data[0:1, 25:30, 40:50, 6:8, 0:1]).all() assert (subData.mask == data.mask[0:1, 25:30, 40:50, 6:8, 0:1]).all() assert ((subData.fill_value == data.fill_value) | (numpy.isnan(subData.fill_value) & numpy.isnan(data.fill_value))).all()