示例#1
0
    def __init__(self, slot, start = None, stop = None, pslice = None):
        super(SubRegion,self).__init__(slot)
        shape = None
        if slot is not None:
            shape = slot.meta.shape
        if pslice != None or start is not None and stop is None and pslice is None:
            if pslice is None:
                pslice = start
            if shape is None:
                # Okay to use a shapeless slot if the key is bounded
                # AND if the key has the correct length
                assert slicingtools.is_bounded(pslice)
                # Supply a dummy shape
                shape = [0] * len(pslice)
            self.start, self.stop = sliceToRoi(pslice,shape)
        elif start is None and pslice is None:
            assert shape is not None, "Can't create a default subregion without a slot and a shape."
            self.start, self.stop = roiFromShape(shape)
        else:
            self.start = TinyVector(start)
            self.stop = TinyVector(stop)
        self.dim = len(self.start)

        for start, stop in zip(self.start, self.stop):
            assert isinstance(start, (int, long, numpy.integer)), "Roi contains non-integers: {}".format( self )
            assert isinstance(start, (int, long, numpy.integer)), "Roi contains non-integers: {}".format( self )
示例#2
0
    def __setitem__(self, key, value):
        """This method provied access to the subslots of a
        MultiSlot.

        """
        assert not isinstance(value, Slot), \
            "Can't use setitem to connect slots.  Use connect()"
        assert self.level == 0, \
            ("setitem can only be used with slots of level 0."
             " Did you forget to append a key?")
        assert self.operator is not None, \
            "cannot do __setitem__ on Slot '{}' -> no operator !!"
        assert slicingtools.is_bounded(key), \
            "Can't use Slot.__setitem__ with keys that include : or ..."
        roi = self.rtype(self, pslice=key)
        if self._value is not None:
            self._value[key] = value

            # only propagate the dirty key at the very beginning of
            # the chain
            self.setDirty(roi)
        if self._type == "input":
            self.operator.setInSlot(self, (), roi, value)

        # Forward to partners
        for p in self.partners:
            p[key] = value
示例#3
0
文件: rtype.py 项目: buotex/lazyflow
 def __init__(self, slot, start = None, stop = None, pslice = None):
     super(SubRegion,self).__init__(slot)
     if pslice != None or start is not None and stop is None and pslice is None:
         if pslice is None:
             pslice = start
         shape = self.slot.meta.shape
         if shape is None:
             # Okay to use a shapeless slot if the key is bounded
             # AND if the key has the correct length
             assert slicingtools.is_bounded(pslice)
             # Supply a dummy shape
             shape = [0] * len(pslice)
         self.start, self.stop = sliceToRoi(pslice,shape)
     elif start is None and pslice is None:
         self.start, self.stop = sliceToRoi(slice(None,None,None),self.slot.meta.shape)
     else:
         self.start = TinyVector(start)
         self.stop = TinyVector(stop)
     self.dim = len(self.start)