1 from lsst.afw.image.imageSlice
import ImageSliceF, ImageSliceD
3 __all__ = (
"disableImageArithmetic",
"disableMaskArithmetic")
7 """Wrap a method providing a helpful error message about image arithmetic
12 Class in which the method is to be defined.
21 existing = getattr(cls, attr,
None)
23 def notImplemented(self, other):
24 """Provide a helpful error message about image arithmetic
26 Unless we're operating on an ImageSlice, in which case it might be
31 self : subclass of `lsst.afw.image.ImageBase`
32 Image someone's attempting to do arithmetic with.
34 The operand of the arithmetic operation.
36 if existing
is not None and isinstance(other, (ImageSliceF, ImageSliceD)):
37 return existing(self, other)
38 raise NotImplementedError(
"This arithmetic operation is not implemented, in order to prevent the "
39 "accidental proliferation of temporaries. Please use the in-place "
40 "arithmetic operations (e.g., += instead of +) or operate on the "
46 """Add helpful error messages about image arithmetic"""
47 for attr
in (
"__add__",
"__sub__",
"__mul__",
"__truediv__",
48 "__radd__",
"__rsub__",
"__rmul__",
"__rtruediv__"):
53 """Add helpful error messages about mask arithmetic"""
54 for attr
in (
"__or__",
"__and__",
"__xor__",
55 "__ror__",
"__rand__",
"__rxor__"):