LSST Applications g0da5cf3356+25b44625d0,g17e5ecfddb+50a5ac4092,g1c76d35bf8+585f0f68a2,g295839609d+8ef6456700,g2e2c1a68ba+cc1f6f037e,g38293774b4+62d12e78cb,g3b44f30a73+2891c76795,g48ccf36440+885b902d19,g4b2f1765b6+0c565e8f25,g5320a0a9f6+bd4bf1dc76,g56364267ca+403c24672b,g56b687f8c9+585f0f68a2,g5c4744a4d9+78cd207961,g5ffd174ac0+bd4bf1dc76,g6075d09f38+3075de592a,g667d525e37+cacede5508,g6f3e93b5a3+da81c812ee,g71f27ac40c+cacede5508,g7212e027e3+eb621d73aa,g774830318a+18d2b9fa6c,g7985c39107+62d12e78cb,g79ca90bc5c+fa2cc03294,g881bdbfe6c+cacede5508,g91fc1fa0cf+82a115f028,g961520b1fb+2534687f64,g96f01af41f+f2060f23b6,g9ca82378b8+cacede5508,g9d27549199+78cd207961,gb065e2a02a+ad48cbcda4,gb1df4690d6+585f0f68a2,gb35d6563ee+62d12e78cb,gbc3249ced9+bd4bf1dc76,gbec6a3398f+bd4bf1dc76,gd01420fc67+bd4bf1dc76,gd59336e7c4+c7bb92e648,gf46e8334de+81c9a61069,gfed783d017+bd4bf1dc76,v25.0.1.rc3
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
lsst.afw.image.image._disableArithmetic Namespace Reference

Functions

def wrapNotImplemented (cls, attr)
 
def disableImageArithmetic (cls)
 
def disableMaskArithmetic (cls)
 

Function Documentation

◆ disableImageArithmetic()

def lsst.afw.image.image._disableArithmetic.disableImageArithmetic (   cls)
Add helpful error messages about image arithmetic

Definition at line 66 of file _disableArithmetic.py.

66def disableImageArithmetic(cls):
67 """Add helpful error messages about image arithmetic"""
68 for attr in ("__add__", "__sub__", "__mul__", "__truediv__",
69 "__radd__", "__rsub__", "__rmul__", "__rtruediv__"):
70 setattr(cls, attr, wrapNotImplemented(cls, attr))
71
72

◆ disableMaskArithmetic()

def lsst.afw.image.image._disableArithmetic.disableMaskArithmetic (   cls)
Add helpful error messages about mask arithmetic

Definition at line 73 of file _disableArithmetic.py.

73def disableMaskArithmetic(cls):
74 """Add helpful error messages about mask arithmetic"""
75 for attr in ("__or__", "__and__", "__xor__",
76 "__ror__", "__rand__", "__rxor__"):
77 setattr(cls, attr, wrapNotImplemented(cls, attr))

◆ wrapNotImplemented()

def lsst.afw.image.image._disableArithmetic.wrapNotImplemented (   cls,
  attr 
)
Wrap a method providing a helpful error message about image arithmetic

Parameters
----------
cls : `type`
    Class in which the method is to be defined.
attr : `str`
    Name of the method.

Returns
-------
method : callable
    Wrapped method.

Definition at line 27 of file _disableArithmetic.py.

27def wrapNotImplemented(cls, attr):
28 """Wrap a method providing a helpful error message about image arithmetic
29
30 Parameters
31 ----------
32 cls : `type`
33 Class in which the method is to be defined.
34 attr : `str`
35 Name of the method.
36
37 Returns
38 -------
39 method : callable
40 Wrapped method.
41 """
42 existing = getattr(cls, attr, None)
43
44 def notImplemented(self, other):
45 """Provide a helpful error message about image arithmetic
46
47 Unless we're operating on an ImageSlice, in which case it might be
48 defined.
49
50 Parameters
51 ----------
52 self : subclass of `lsst.afw.image.ImageBase`
53 Image someone's attempting to do arithmetic with.
54 other : anything
55 The operand of the arithmetic operation.
56 """
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 "
62 "underlying arrays.")
63 return notImplemented
64
65
The base class for all image classed (Image, Mask, MaskedImage, ...)
Definition: ImageBase.h:102