コード例 #1
0
ファイル: stype.py プロジェクト: burgerdev/lazyflow
    def writeIntoDestination( self, destination, value, roi ):
        if destination is not None:
            if not isinstance(destination, list):
                assert(roi.dim == destination.ndim), "%r ndim=%r, shape=%r" % (roi.toSlice(), destination.ndim, destination.shape)
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination[:] = value[sl]
            except TypeError:
                warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination[:] = value
        else:
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination = value[sl]
            except:
                warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]

            if type(destination) == numpy.ndarray and destination.shape == ():
                # This is necessary because numpy types will not be caught in the except statement above.
                # They don't throw when used with __getitem__
                # e.g. try this:
                # x = np.int64(5)
                # assert type(x[()]) == np.ndarray and x[()].shape == ()
                warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]
        return destination
コード例 #2
0
ファイル: stype.py プロジェクト: ClausRipp/lazyflow
 def writeIntoDestination( self, destination, value, roi ):
     sl = roiToSlice(roi.start, roi.stop)
     try:
         destination[:] = value[sl]
     except TypeError:
         warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
         destination = [value]
     return destination
コード例 #3
0
ファイル: stype.py プロジェクト: constantinpape/lazyflow
    def writeIntoDestination( self, destination, value, roi ):
        # If we do not support masked arrays, ensure that we are not being passed one.
        assert self.slot.allow_mask or (not self.slot.meta.has_mask), \
            "A masked array was provided as a destination. However," \
            " the slot, \"%s\", of operator, " "\"%s\", does not support masked arrays." \
            " If you believe this message to be incorrect, " \
            "please pass the keyword argument `allow_mask=True` to the slot constructor." \
            % (self.slot.operator.name, self.slot.name)

        if destination is not None:
            if not isinstance(destination, list):
                assert(roi.dim == destination.ndim), "%r ndim=%r, shape=%r" % (roi.toSlice(), destination.ndim, destination.shape)
            sl = roiToSlice(roi.start, roi.stop)
            try:
                self.copy_data(destination, value[sl])
            except TypeError:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                self.copy_data(destination, value)
        else:
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination = value[sl]
            except:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]

            if isinstance(destination, numpy.ndarray) and destination.shape == ():
                # This is necessary because numpy types will not be caught in the except statement above.
                # They don't throw when used with __getitem__
                # e.g. try this:
                # x = np.int64(5)
                # assert type(x[()]) == np.ndarray and x[()].shape == ()

                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]
        return destination
コード例 #4
0
    def writeIntoDestination(self, destination, value, roi):
        if destination is not None:
            if not isinstance(destination, list):
                assert (
                    roi.dim == destination.ndim), "%r ndim=%r, shape=%r" % (
                        roi.toSlice(), destination.ndim, destination.shape)
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination[:] = value[sl]
            except TypeError:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination[:] = value
        else:
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination = value[sl]
            except:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]

            if type(destination) == numpy.ndarray and destination.shape == ():
                # This is necessary because numpy types will not be caught in the except statement above.
                # They don't throw when used with __getitem__
                # e.g. try this:
                # x = np.int64(5)
                # assert type(x[()]) == np.ndarray and x[()].shape == ()

                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]
        return destination
コード例 #5
0
ファイル: stype.py プロジェクト: christophdecker/lazyflow
    def writeIntoDestination( self, destination, value, roi ):
        if destination is not None:
            if not isinstance(destination, list):
                assert(roi.dim == destination.ndim), "%r ndim=%r, shape=%r" % (roi.toSlice(), destination.ndim, destination.shape)
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination[:] = value[sl]
            except TypeError:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination[:] = value
        else:
            sl = roiToSlice(roi.start, roi.stop)
            try:
                destination = value[sl]
            except:
                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]

            if type(destination) == numpy.ndarray and destination.shape == ():
                # This is necessary because numpy types will not be caught in the except statement above.
                # They don't throw when used with __getitem__
                # e.g. try this:
                # x = np.int64(5)
                # assert type(x[()]) == np.ndarray and x[()].shape == ()

                # FIXME: This warning used to be triggered by a corner case that could be encountered by "value slots".
                #        The behavior here isn't truly deprecated.  But we need a better solution for lazyflow 2.0.
                # See ilastik/ilastik#704
                #warn_deprecated("old style slot encountered: non array-like value set -> change SlotType from ArrayLike to proper SlotType")
                destination = [value]
        return destination
コード例 #6
0
ファイル: rtype.py プロジェクト: LimpingTwerp/lazyflow
 def toSlice(self, hardBind=False):
     return roiToSlice(self.start, self.stop, hardBind)