LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+4b710797af,21.0.0-1-gfc31b0f+3b24369756,21.0.0-10-g2408eff+50e97f2f47,21.0.0-10-g560fb7b+0803ad37c5,21.0.0-10-g5daeb2b+f9b8dc6d5a,21.0.0-10-g8d1d15d+77a6b82ebf,21.0.0-10-gcf60f90+c961be884d,21.0.0-11-g25eff31+7692554667,21.0.0-17-g6590b197+a14a01c114,21.0.0-2-g103fe59+b79afc2051,21.0.0-2-g1367e85+1003a3501c,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+1003a3501c,21.0.0-2-g7f82c8f+c2a1919b98,21.0.0-2-g8f08a60+fd0b970de5,21.0.0-2-ga326454+c2a1919b98,21.0.0-2-gde069b7+ca45a81b40,21.0.0-2-gecfae73+afcaaec585,21.0.0-2-gfc62afb+1003a3501c,21.0.0-21-g5d80ea29e+5e3c9a3766,21.0.0-3-g357aad2+c67f36f878,21.0.0-3-g4be5c26+1003a3501c,21.0.0-3-g65f322c+02b1f88459,21.0.0-3-g7d9da8d+3b24369756,21.0.0-3-ge02ed75+a423c2ae7a,21.0.0-4-g591bb35+a423c2ae7a,21.0.0-4-g65b4814+0803ad37c5,21.0.0-4-g88306b8+199c7497e5,21.0.0-4-gccdca77+a631590478,21.0.0-4-ge8a399c+b923ff878e,21.0.0-5-gd00fb1e+d8b1e95daa,21.0.0-53-ge728e5d5+3cb64fea8e,21.0.0-6-g2d4f3f3+04719a4bac,21.0.0-7-g04766d7+8d320c19d5,21.0.0-7-g98eecf7+205433fbda,21.0.0-9-g39e06b5+a423c2ae7a,master-gac4afde19b+a423c2ae7a,w.2021.11
LSST Data Management Base Package
Functions
lsst.afw.image.disableArithmetic Namespace Reference

Functions

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

Function Documentation

◆ disableImageArithmetic()

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

Definition at line 66 of file disableArithmetic.py.

66 def 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.disableArithmetic.disableMaskArithmetic (   cls)
Add helpful error messages about mask arithmetic

Definition at line 73 of file disableArithmetic.py.

73 def 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.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.

27 def 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