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 | Public Attributes | Properties | List of all members
lsst.pex.config.registry.RegistryInstanceDict Class Reference
Inheritance diagram for lsst.pex.config.registry.RegistryInstanceDict:
lsst.pex.config.configChoiceField.ConfigInstanceDict

Public Member Functions

def __init__ (self, config, field)
 
def apply (self, *args, **kw)
 
def __setattr__ (self, attr, value)
 
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)
 

Public Attributes

 registry
 

Properties

 target = property(_getTarget)
 
 targets = property(_getTargets)
 
 names = property(_getNames, _setNames, _delNames)
 
 name = property(_getName, _setName, _delName)
 
 active = property(_getActive)
 

Detailed Description

Dictionary of instantiated configs, used to populate a `RegistryField`.

Parameters
----------
config : `lsst.pex.config.Config`
    Configuration instance.
field : `RegistryField`
    Configuration field.

Definition at line 225 of file registry.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pex.config.registry.RegistryInstanceDict.__init__ (   self,
  config,
  field 
)

Reimplemented from lsst.pex.config.configChoiceField.ConfigInstanceDict.

Definition at line 236 of file registry.py.

236  def __init__(self, config, field):
237  ConfigInstanceDict.__init__(self, config, field)
238  self.registry = field.registry
239 

Member Function Documentation

◆ __contains__()

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

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" 
)
inherited

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)
inherited

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)
inherited

Definition at line 174 of file configChoiceField.py.

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

◆ __setattr__() [1/2]

def lsst.pex.config.registry.RegistryInstanceDict.__setattr__ (   self,
  attr,
  value 
)

Definition at line 276 of file registry.py.

276  def __setattr__(self, attr, value):
277  if attr == "registry":
278  object.__setattr__(self, attr, value)
279  else:
280  ConfigInstanceDict.__setattr__(self, attr, value)
281 
282 

◆ __setattr__() [2/2]

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

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" 
)
inherited

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

◆ apply()

def lsst.pex.config.registry.RegistryInstanceDict.apply (   self,
args,
**  kw 
)
Call the active target(s) with the active config as a keyword arg

If this is a multi-selection field, return a list obtained by calling
each active target with its corresponding active config.

Additional arguments will be passed on to the configurable target(s)

Definition at line 256 of file registry.py.

256  def apply(self, *args, **kw):
257  """Call the active target(s) with the active config as a keyword arg
258 
259  If this is a multi-selection field, return a list obtained by calling
260  each active target with its corresponding active config.
261 
262  Additional arguments will be passed on to the configurable target(s)
263  """
264  if self.active is None:
265  msg = "No selection has been made. Options: %s" % \
266  " ".join(self.types.registry.keys())
267  raise FieldValidationError(self._field, self._config, msg)
268  if self._field.multi:
269  retvals = []
270  for c in self._selection:
271  retvals.append(self.types.registry[c](*args, config=self[c], **kw))
272  return retvals
273  else:
274  return self.types.registry[self.name](*args, config=self[self.name], **kw)
275 

◆ freeze()

def lsst.pex.config.configChoiceField.ConfigInstanceDict.freeze (   self)
inherited
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)
inherited

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 

Member Data Documentation

◆ registry

lsst.pex.config.registry.RegistryInstanceDict.registry

Definition at line 238 of file registry.py.

Property Documentation

◆ active

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

Definition at line 254 of file configChoiceField.py.

◆ name

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

Definition at line 239 of file configChoiceField.py.

◆ names

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

Definition at line 233 of file configChoiceField.py.

◆ target

lsst.pex.config.registry.RegistryInstanceDict.target = property(_getTarget)
static

Definition at line 246 of file registry.py.

◆ targets

lsst.pex.config.registry.RegistryInstanceDict.targets = property(_getTargets)
static

Definition at line 254 of file registry.py.


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