LSSTApplications  19.0.0-14-gb0260a2+2d714fc2ef,20.0.0+34a42eae2c,20.0.0+76f397ef0c,20.0.0+8558dd3f48,20.0.0+a6b6977b51,20.0.0+b2ea66fa67,20.0.0+cc669a8b45,20.0.0+d561663fb5,20.0.0+d778e99126,20.0.0+efe67588cf,20.0.0+f45b7d88f4,20.0.0+f7c597f720,20.0.0+fb43bee9b9,20.0.0+fb4d547e0d,20.0.0-1-g10df615+d8b88ec1b5,20.0.0-1-g253301a+a6b6977b51,20.0.0-1-g498fb60+ff88705a28,20.0.0-1-g4d801e7+ce0d01dabd,20.0.0-1-g5b95a8c+24eaf908b3,20.0.0-1-g8a53f90+2817c06967,20.0.0-1-gc96f8cb+fb4d547e0d,20.0.0-1-gd1c87d7+2817c06967,20.0.0-1-gdb27ee5+abab67204f,20.0.0-13-ge998c5c+9f8c516ffa,20.0.0-18-g08fba245+88079d2923,20.0.0-2-gec03fae+fb98bf9d97,20.0.0-3-gdd5c15c+a61313b210,20.0.0-34-gdb4d86a+b43b2c05ff,20.0.0-4-g4a2362f+f45b7d88f4,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-gac0d578b1+a8c4e2ada3,20.0.0-5-gfcebe35+cfceff6a24,20.0.0-6-g01203fff+e332440eaf,20.0.0-8-gea2affd+48c001ce3c,20.0.0-9-gabd0d4c+abab67204f,20.0.0-9-gf3ab18e+fb4d547e0d,w.2020.33
LSSTDataManagementBasePackage
Public Member Functions | Properties | List of all members
pex.config.configChoiceField.ConfigInstanceDict Class Reference
Inheritance diagram for pex.config.configChoiceField.ConfigInstanceDict:
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 135 of file configChoiceField.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented in pex.config.registry.RegistryInstanceDict.

Definition at line 148 of file configChoiceField.py.

148  def __init__(self, config, field):
149  collections.abc.Mapping.__init__(self)
150  self._dict = dict()
151  self._selection = None
152  self._config = config
153  self._field = field
154  self._history = config._history.setdefault(field.name, [])
155  self.__doc__ = field.doc
156  self._typemap = None
157 

Member Function Documentation

◆ __contains__()

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

Definition at line 162 of file configChoiceField.py.

162  def __contains__(self, k):
163  return k in self.types
164 

◆ __getitem__()

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

Definition at line 252 of file configChoiceField.py.

252  def __getitem__(self, k, at=None, label="default"):
253  try:
254  value = self._dict[k]
255  except KeyError:
256  try:
257  dtype = self.types[k]
258  except Exception:
259  raise FieldValidationError(self._field, self._config,
260  "Unknown key %r in Registry/ConfigChoiceField" % k)
261  name = _joinNamePath(self._config._name, self._field.name, k)
262  if at is None:
263  at = getCallStack()
264  at.insert(0, dtype._source)
265  value = self._dict.setdefault(k, dtype(__name=name, __at=at, __label=label))
266  return value
267 

◆ __iter__()

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

Definition at line 168 of file configChoiceField.py.

168  def __iter__(self):
169  return iter(self.types)
170 

◆ __len__()

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

Definition at line 165 of file configChoiceField.py.

165  def __len__(self):
166  return len(self.types)
167 

◆ __setattr__()

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

Definition at line 300 of file configChoiceField.py.

300  def __setattr__(self, attr, value, at=None, label="assignment"):
301  if hasattr(getattr(self.__class__, attr, None), '__set__'):
302  # This allows properties to work.
303  object.__setattr__(self, attr, value)
304  elif attr in self.__dict__ or attr in ["_history", "_field", "_config", "_dict",
305  "_selection", "__doc__", "_typemap"]:
306  # This allows specific private attributes to work.
307  object.__setattr__(self, attr, value)
308  else:
309  # We throw everything else.
310  msg = "%s has no attribute %s" % (_typeStr(self._field), attr)
311  raise FieldValidationError(self._field, self._config, msg)
312 

◆ __setitem__()

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

Definition at line 268 of file configChoiceField.py.

268  def __setitem__(self, k, value, at=None, label="assignment"):
269  if self._config._frozen:
270  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
271 
272  try:
273  dtype = self.types[k]
274  except Exception:
275  raise FieldValidationError(self._field, self._config, "Unknown key %r" % k)
276 
277  if value != dtype and type(value) != dtype:
278  msg = "Value %s at key %k is of incorrect type %s. Expected type %s" % \
279  (value, k, _typeStr(value), _typeStr(dtype))
280  raise FieldValidationError(self._field, self._config, msg)
281 
282  if at is None:
283  at = getCallStack()
284  name = _joinNamePath(self._config._name, self._field.name, k)
285  oldValue = self._dict.get(k, None)
286  if oldValue is None:
287  if value == dtype:
288  self._dict[k] = value(__name=name, __at=at, __label=label)
289  else:
290  self._dict[k] = dtype(__name=name, __at=at, __label=label, **value._storage)
291  else:
292  if value == dtype:
293  value = value()
294  oldValue.update(__at=at, __label=label, **value._storage)
295 

◆ freeze()

def 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 313 of file configChoiceField.py.

313  def freeze(self):
314  """Invoking this freeze method will create a local copy of the field
315  attribute's typemap. This decouples this instance dict from the
316  underlying objects type map ensuring that and subsequent changes to the
317  typemap will not be reflected in this instance (i.e imports adding
318  additional registry entries).
319  """
320  if self._typemap is None:
321  self._typemap = copy.deepcopy(self.types)
322 
323 

◆ types()

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

Definition at line 159 of file configChoiceField.py.

159  def types(self):
160  return self._typemap if self._typemap is not None else self._field.typemap
161 

Property Documentation

◆ active

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

Definition at line 245 of file configChoiceField.py.

◆ name

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

Definition at line 230 of file configChoiceField.py.

◆ names

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

Definition at line 224 of file configChoiceField.py.


The documentation for this class was generated from the following file:
pex.config.callStack.getCallStack
def getCallStack(skip=0)
Definition: callStack.py:175
type
table::Key< int > type
Definition: Detector.cc:163
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88