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
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
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
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
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
def toSlice(self, hardBind=False): return roiToSlice(self.start, self.stop, hardBind)