Exemple #1
0
 def request( self, slicing, through=None ):
     assert is_pure_slicing(slicing)
     assert is_bounded(slicing)
     shape = slicing2shape(slicing)
     result = np.zeros( shape, dtype = self._dtype )
     result[:] = self._constant
     return ConstantRequest( result )
Exemple #2
0
 def request(self, slicing, through=None):
     assert is_pure_slicing(slicing)
     assert is_bounded(slicing)
     shape = slicing2shape(slicing)
     result = np.zeros(shape, dtype=self._dtype)
     result[:] = self._constant
     return ConstantRequest(result)
Exemple #3
0
    def request(self, slicing):
        assert is_pure_slicing(slicing)
        assert is_bounded(slicing)
        shape = slicing2shape(slicing)
        key = (shape, self._constant, self._dtype)

        if key not in self._cache:
            result = np.full(shape, self._constant, dtype=self._dtype)
            result.setflags(write=False)
            self._cache[key] = result

        return ConstantRequest(self._cache[key])
Exemple #4
0
    def setDirty(self, slicing):
        """Mark a region of the image as dirty.

        slicing -- if one ore more slices in the slicing
                   are unbounded, the whole image is marked dirty;
                   since an image has two dimensions, only the first
                   two slices in the slicing are used

        """
        if not is_pure_slicing(slicing):
            raise Exception("dirty region: slicing is not pure")
        if not is_bounded(slicing):
            self.isDirty.emit(QRect())  # empty rect == everything is dirty
        else:
            self.isDirty.emit(slicing2rect(slicing))
Exemple #5
0
    def setDirty( self, slicing ):
        '''Mark a region of the image as dirty.

        slicing -- if one ore more slices in the slicing
                   are unbounded, the whole image is marked dirty;
                   since an image has two dimensions, only the first
                   two slices in the slicing are used

        '''
        if not is_pure_slicing(slicing):
            raise Exception('dirty region: slicing is not pure')
        if not is_bounded( slicing ):
            self.isDirty.emit(QRect()) # empty rect == everything is dirty
        else:
            self.isDirty.emit(slicing2rect( slicing ))