22 from lsst.afw.image.imageSlice
import ImageSliceF, ImageSliceD
24 __all__ = (
"disableImageArithmetic",
"disableMaskArithmetic")
28 """Wrap a method providing a helpful error message about image arithmetic
33 Class in which the method is to be defined.
42 existing = getattr(cls, attr,
None)
44 def notImplemented(self, other):
45 """Provide a helpful error message about image arithmetic
47 Unless we're operating on an ImageSlice, in which case it might be
52 self : subclass of `lsst.afw.image.ImageBase`
53 Image someone's attempting to do arithmetic with.
55 The operand of the arithmetic operation.
57 if existing
is not None and isinstance(other, (ImageSliceF, ImageSliceD)):
58 return existing(self, other)
59 raise NotImplementedError(
"This arithmetic operation is not implemented, in order to prevent the "
60 "accidental proliferation of temporaries. Please use the in-place "
61 "arithmetic operations (e.g., += instead of +) or operate on the "
67 """Add helpful error messages about image arithmetic"""
68 for attr
in (
"__add__",
"__sub__",
"__mul__",
"__truediv__",
69 "__radd__",
"__rsub__",
"__rmul__",
"__rtruediv__"):
74 """Add helpful error messages about mask arithmetic"""
75 for attr
in (
"__or__",
"__and__",
"__xor__",
76 "__ror__",
"__rand__",
"__rxor__"):
def wrapNotImplemented(cls, attr)
def disableImageArithmetic(cls)
def disableMaskArithmetic(cls)