LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Properties | List of all members
lsst.pex.config.configChoiceField.ConfigInstanceDict Class Reference
Inheritance diagram for lsst.pex.config.configChoiceField.ConfigInstanceDict:
lsst.pex.config.registry.RegistryInstanceDict

Public Member Functions

def __init__ (self, config, field)
 
def types (self)
 
def __contains__ (self, k)
 
def __len__ (self)
 
def __iter__ (self)
 
def __getitem__ (self, k, at=None, label="default")
 
def __setitem__ (self, k, value, at=None, label="assignment")
 
def __setattr__ (self, attr, value, at=None, label="assignment")
 
def freeze (self)
 

Properties

 names = property(_getNames, _setNames, _delNames)
 
 name = property(_getName, _setName, _delName)
 
 active = property(_getActive)
 

Detailed Description

Dictionary of instantiated configs, used to populate a
`~lsst.pex.config.ConfigChoiceField`.

Parameters
----------
config : `lsst.pex.config.Config`
    A configuration instance.
field : `lsst.pex.config.Field`-type
    A configuration field. Note that the `lsst.pex.config.Field.fieldmap`
    attribute must provide key-based access to configuration classes,
    (that is, ``typemap[name]``).

Definition at line 144 of file configChoiceField.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__init__ (   self,
  config,
  field 
)

Reimplemented in lsst.pex.config.registry.RegistryInstanceDict.

Definition at line 157 of file configChoiceField.py.

157  def __init__(self, config, field):
158  collections.abc.Mapping.__init__(self)
159  self._dict = dict()
160  self._selection = None
161  self._config = config
162  self._field = field
163  self._history = config._history.setdefault(field.name, [])
164  self.__doc__ = field.doc
165  self._typemap = None
166 

Member Function Documentation

◆ __contains__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__contains__ (   self,
  k 
)

Definition at line 171 of file configChoiceField.py.

171  def __contains__(self, k):
172  return k in self.types
173 

◆ __getitem__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__getitem__ (   self,
  k,
  at = None,
  label = "default" 
)

Definition at line 261 of file configChoiceField.py.

261  def __getitem__(self, k, at=None, label="default"):
262  try:
263  value = self._dict[k]
264  except KeyError:
265  try:
266  dtype = self.types[k]
267  except Exception:
268  raise FieldValidationError(self._field, self._config,
269  "Unknown key %r in Registry/ConfigChoiceField" % k)
270  name = _joinNamePath(self._config._name, self._field.name, k)
271  if at is None:
272  at = getCallStack()
273  at.insert(0, dtype._source)
274  value = self._dict.setdefault(k, dtype(__name=name, __at=at, __label=label))
275  return value
276 
def getCallStack(skip=0)
Definition: callStack.py:175

◆ __iter__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__iter__ (   self)

Definition at line 177 of file configChoiceField.py.

177  def __iter__(self):
178  return iter(self.types)
179 

◆ __len__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__len__ (   self)

Definition at line 174 of file configChoiceField.py.

174  def __len__(self):
175  return len(self.types)
176 

◆ __setattr__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__setattr__ (   self,
  attr,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 309 of file configChoiceField.py.

309  def __setattr__(self, attr, value, at=None, label="assignment"):
310  if hasattr(getattr(self.__class__, attr, None), '__set__'):
311  # This allows properties to work.
312  object.__setattr__(self, attr, value)
313  elif attr in self.__dict__ or attr in ["_history", "_field", "_config", "_dict",
314  "_selection", "__doc__", "_typemap"]:
315  # This allows specific private attributes to work.
316  object.__setattr__(self, attr, value)
317  else:
318  # We throw everything else.
319  msg = "%s has no attribute %s" % (_typeStr(self._field), attr)
320  raise FieldValidationError(self._field, self._config, msg)
321 

◆ __setitem__()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__setitem__ (   self,
  k,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 277 of file configChoiceField.py.

277  def __setitem__(self, k, value, at=None, label="assignment"):
278  if self._config._frozen:
279  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
280 
281  try:
282  dtype = self.types[k]
283  except Exception:
284  raise FieldValidationError(self._field, self._config, "Unknown key %r" % k)
285 
286  if value != dtype and type(value) != dtype:
287  msg = "Value %s at key %s is of incorrect type %s. Expected type %s" % \
288  (value, k, _typeStr(value), _typeStr(dtype))
289  raise FieldValidationError(self._field, self._config, msg)
290 
291  if at is None:
292  at = getCallStack()
293  name = _joinNamePath(self._config._name, self._field.name, k)
294  oldValue = self._dict.get(k, None)
295  if oldValue is None:
296  if value == dtype:
297  self._dict[k] = value(__name=name, __at=at, __label=label)
298  else:
299  self._dict[k] = dtype(__name=name, __at=at, __label=label, **value._storage)
300  else:
301  if value == dtype:
302  value = value()
303  oldValue.update(__at=at, __label=label, **value._storage)
304 
table::Key< int > type
Definition: Detector.cc:163

◆ freeze()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.freeze (   self)
Invoking this freeze method will create a local copy of the field
attribute's typemap. This decouples this instance dict from the
underlying objects type map ensuring that and subsequent changes to the
typemap will not be reflected in this instance (i.e imports adding
additional registry entries).

Definition at line 322 of file configChoiceField.py.

322  def freeze(self):
323  """Invoking this freeze method will create a local copy of the field
324  attribute's typemap. This decouples this instance dict from the
325  underlying objects type map ensuring that and subsequent changes to the
326  typemap will not be reflected in this instance (i.e imports adding
327  additional registry entries).
328  """
329  if self._typemap is None:
330  self._typemap = copy.deepcopy(self.types)
331 
332 

◆ types()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.types (   self)

Definition at line 168 of file configChoiceField.py.

168  def types(self):
169  return self._typemap if self._typemap is not None else self._field.typemap
170 

Property Documentation

◆ active

lsst.pex.config.configChoiceField.ConfigInstanceDict.active = property(_getActive)
static

Definition at line 254 of file configChoiceField.py.

◆ name

lsst.pex.config.configChoiceField.ConfigInstanceDict.name = property(_getName, _setName, _delName)
static

Definition at line 239 of file configChoiceField.py.

◆ names

lsst.pex.config.configChoiceField.ConfigInstanceDict.names = property(_getNames, _setNames, _delNames)
static

Definition at line 233 of file configChoiceField.py.


The documentation for this class was generated from the following file: