LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
LSSTDataManagementBasePackage
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 __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")
 

Public Attributes

 registry
 

Properties

 target = property(_getTarget)
 
 targets = property(_getTargets)
 
 types = property(lambda x: x._field.typemap)
 
 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 220 of file registry.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 231 of file registry.py.

231  def __init__(self, config, field):
232  ConfigInstanceDict.__init__(self, config, field)
233  self.registry = field.registry
234 
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ __contains__()

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

Definition at line 154 of file configChoiceField.py.

154  def __contains__(self, k):
155  return k in self._field.typemap
156 

◆ __getitem__()

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

Definition at line 244 of file configChoiceField.py.

244  def __getitem__(self, k, at=None, label="default"):
245  try:
246  value = self._dict[k]
247  except KeyError:
248  try:
249  dtype = self._field.typemap[k]
250  except Exception:
251  raise FieldValidationError(self._field, self._config,
252  "Unknown key %r in Registry/ConfigChoiceField" % k)
253  name = _joinNamePath(self._config._name, self._field.name, k)
254  if at is None:
255  at = getCallStack()
256  at.insert(0, dtype._source)
257  value = self._dict.setdefault(k, dtype(__name=name, __at=at, __label=label))
258  return value
259 
def getCallStack(skip=0)
Definition: callStack.py:169

◆ __iter__()

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

Definition at line 160 of file configChoiceField.py.

160  def __iter__(self):
161  return iter(self._field.typemap)
162 

◆ __len__()

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

Definition at line 157 of file configChoiceField.py.

157  def __len__(self):
158  return len(self._field.typemap)
159 

◆ __setattr__() [1/2]

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

Definition at line 271 of file registry.py.

271  def __setattr__(self, attr, value):
272  if attr == "registry":
273  object.__setattr__(self, attr, value)
274  else:
275  ConfigInstanceDict.__setattr__(self, attr, value)
276 
277 

◆ __setattr__() [2/2]

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

Definition at line 292 of file configChoiceField.py.

292  def __setattr__(self, attr, value, at=None, label="assignment"):
293  if hasattr(getattr(self.__class__, attr, None), '__set__'):
294  # This allows properties to work.
295  object.__setattr__(self, attr, value)
296  elif attr in self.__dict__ or attr in ["_history", "_field", "_config", "_dict",
297  "_selection", "__doc__"]:
298  # This allows specific private attributes to work.
299  object.__setattr__(self, attr, value)
300  else:
301  # We throw everything else.
302  msg = "%s has no attribute %s" % (_typeStr(self._field), attr)
303  raise FieldValidationError(self._field, self._config, msg)
304 
305 

◆ __setitem__()

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

Definition at line 260 of file configChoiceField.py.

260  def __setitem__(self, k, value, at=None, label="assignment"):
261  if self._config._frozen:
262  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
263 
264  try:
265  dtype = self._field.typemap[k]
266  except Exception:
267  raise FieldValidationError(self._field, self._config, "Unknown key %r" % k)
268 
269  if value != dtype and type(value) != dtype:
270  msg = "Value %s at key %k is of incorrect type %s. Expected type %s" % \
271  (value, k, _typeStr(value), _typeStr(dtype))
272  raise FieldValidationError(self._field, self._config, msg)
273 
274  if at is None:
275  at = getCallStack()
276  name = _joinNamePath(self._config._name, self._field.name, k)
277  oldValue = self._dict.get(k, None)
278  if oldValue is None:
279  if value == dtype:
280  self._dict[k] = value(__name=name, __at=at, __label=label)
281  else:
282  self._dict[k] = dtype(__name=name, __at=at, __label=label, **value._storage)
283  else:
284  if value == dtype:
285  value = value()
286  oldValue.update(__at=at, __label=label, **value._storage)
287 
def getCallStack(skip=0)
Definition: callStack.py:169
table::Key< int > type
Definition: Detector.cc:164

◆ 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 251 of file registry.py.

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

Member Data Documentation

◆ registry

lsst.pex.config.registry.RegistryInstanceDict.registry

Definition at line 233 of file registry.py.

Property Documentation

◆ active

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

Definition at line 237 of file configChoiceField.py.

◆ name

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

Definition at line 222 of file configChoiceField.py.

◆ names

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

Definition at line 216 of file configChoiceField.py.

◆ target

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

Definition at line 241 of file registry.py.

◆ targets

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

Definition at line 249 of file registry.py.

◆ types

lsst.pex.config.configChoiceField.ConfigInstanceDict.types = property(lambda x: x._field.typemap)
staticinherited

Definition at line 152 of file configChoiceField.py.


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