Beispiel #1
0
    def setUp(self):
        self.dataShape = (1, 100, 100, 10, 1)
        self.data = (numpy.random.random(self.dataShape) * 100).astype(int)
        self.data = numpy.ma.masked_array(self.data,
                                          mask=numpy.ma.getmaskarray(
                                              self.data),
                                          fill_value=self.data.dtype.type(0),
                                          shrink=False)
        self.data[0, :1, :1, 0, 0] = numpy.ma.masked

        graph = Graph()
        opProvider = OpArrayPiperWithAccessCount(graph=graph)
        opProvider.Input.meta.axistags = vigra.defaultAxistags('txyzc')
        opProvider.Input.meta.has_mask = True
        opProvider.Input.setValue(self.data)
        self.opProvider = opProvider

        opCache = OpSlicedBlockedArrayCache(graph=graph)
        opCache.Input.connect(opProvider.Output)
        opCache.innerBlockShape.setValue(
            ((10, 1, 10, 10, 10), (10, 10, 1, 10, 10), (10, 10, 10, 1, 10)))
        opCache.outerBlockShape.setValue(
            ((20, 2, 20, 20, 20), (20, 20, 2, 20, 20), (20, 20, 20, 2, 20)))
        opCache.fixAtCurrent.setValue(False)
        self.opCache = opCache
    def testCleanup(self):
        try:
            CacheMemoryManager().disable()

            op = OpSlicedBlockedArrayCache(graph=self.opProvider.graph)
            op.Input.connect(self.opProvider.Output)
            op.BlockShape.setValue(self.opCache.BlockShape.value)
            op.fixAtCurrent.setValue(False)
            x = op.Output[...].wait()
            op.Input.disconnect()
            op.cleanUp()

            r = weakref.ref(op)
            del op
            gc.collect()
            assert r() is None, "OpBlockedArrayCache was not cleaned up correctly"
        finally:
            CacheMemoryManager().enable()
    def testCleanup(self):
        try:
            CacheMemoryManager().disable()
            
            op = OpSlicedBlockedArrayCache(graph=self.opProvider.graph)
            op.Input.connect(self.opProvider.Output)
            op.BlockShape.setValue(self.opCache.BlockShape.value)
            op.fixAtCurrent.setValue(False)
            x = op.Output[...].wait()
            op.Input.disconnect()
            op.cleanUp()

            r = weakref.ref(op)
            del op
            gc.collect()
            assert r() is None, "OpBlockedArrayCache was not cleaned up correctly"
        finally:
            CacheMemoryManager().enable()
    def setUp(self):
        self.dataShape = (1,100,100,10,1)
        self.data = (numpy.random.random(self.dataShape) * 100).astype(numpy.uint32)
        self.data = self.data.view(vigra.VigraArray)
        self.data.axistags = vigra.defaultAxistags('txyzc')

        graph = Graph()
        opProvider = OpArrayPiperWithAccessCount(graph=graph)
        opProvider.Input.setValue(self.data)
        self.opProvider = opProvider
        
        opCache = OpSlicedBlockedArrayCache(graph=graph)
        opCache.Input.connect(opProvider.Output)
        opCache.BlockShape.setValue( ( (20,2,20,20,20), (20,20,2,20,20), (20,20,20,2,20) ) )
        opCache.fixAtCurrent.setValue(False)
        self.opCache = opCache