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.listField.List Class Reference
Inheritance diagram for pex.config.listField.List:

Public Member Functions

def __init__ (self, config, field, value, at, label, setHistory=True)
 
def validateItem (self, i, x)
 
def list (self)
 
def __contains__ (self, x)
 
def __len__ (self)
 
def __setitem__ (self, i, x, at=None, label="setitem", setHistory=True)
 
def __getitem__ (self, i)
 
def __delitem__ (self, i, at=None, label="delitem", setHistory=True)
 
def __iter__ (self)
 
def insert (self, i, x, at=None, label="insert", setHistory=True)
 
def __repr__ (self)
 
def __str__ (self)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __setattr__ (self, attr, value, at=None, label="assignment")
 

Properties

 history = property(lambda x: x._history)
 

Detailed Description

List collection used internally by `ListField`.

Parameters
----------
config : `lsst.pex.config.Config`
    Config instance that contains the ``field``.
field : `ListField`
    Instance of the `ListField` using this ``List``.
value : sequence
    Sequence of values that are inserted into this ``List``.
at : `list` of `lsst.pex.config.callStack.StackFrame`
    The call stack (created by `lsst.pex.config.callStack.getCallStack`).
label : `str`
    Event label for the history.
setHistory : `bool`, optional
    Enable setting the field's history, using the value of the ``at``
    parameter. Default is `True`.

Raises
------
FieldValidationError
    Raised if an item in the ``value`` parameter does not have the
    appropriate type for this field or does not pass the
    `ListField.itemCheck` method of the ``field`` parameter.

Definition at line 37 of file listField.py.

Constructor & Destructor Documentation

◆ __init__()

def pex.config.listField.List.__init__ (   self,
  config,
  field,
  value,
  at,
  label,
  setHistory = True 
)

Definition at line 64 of file listField.py.

64  def __init__(self, config, field, value, at, label, setHistory=True):
65  self._field = field
66  self._config = config
67  self._history = self._config._history.setdefault(self._field.name, [])
68  self._list = []
69  self.__doc__ = field.doc
70  if value is not None:
71  try:
72  for i, x in enumerate(value):
73  self.insert(i, x, setHistory=False)
74  except TypeError:
75  msg = "Value %s is of incorrect type %s. Sequence type expected" % (value, _typeStr(value))
76  raise FieldValidationError(self._field, self._config, msg)
77  if setHistory:
78  self.history.append((list(self._list), at, label))
79 

Member Function Documentation

◆ __contains__()

def pex.config.listField.List.__contains__ (   self,
  x 
)

Definition at line 116 of file listField.py.

116  def __contains__(self, x):
117  return x in self._list
118 

◆ __delitem__()

def pex.config.listField.List.__delitem__ (   self,
  i,
  at = None,
  label = "delitem",
  setHistory = True 
)

Definition at line 146 of file listField.py.

146  def __delitem__(self, i, at=None, label="delitem", setHistory=True):
147  if self._config._frozen:
148  raise FieldValidationError(self._field, self._config,
149  "Cannot modify a frozen Config")
150  del self._list[i]
151  if setHistory:
152  if at is None:
153  at = getCallStack()
154  self.history.append((list(self._list), at, label))
155 

◆ __eq__()

def pex.config.listField.List.__eq__ (   self,
  other 
)

Definition at line 187 of file listField.py.

187  def __eq__(self, other):
188  try:
189  if len(self) != len(other):
190  return False
191 
192  for i, j in zip(self, other):
193  if i != j:
194  return False
195  return True
196  except AttributeError:
197  # other is not a sequence type
198  return False
199 

◆ __getitem__()

def pex.config.listField.List.__getitem__ (   self,
  i 
)

Definition at line 143 of file listField.py.

143  def __getitem__(self, i):
144  return self._list[i]
145 

◆ __iter__()

def pex.config.listField.List.__iter__ (   self)

Definition at line 156 of file listField.py.

156  def __iter__(self):
157  return iter(self._list)
158 

◆ __len__()

def pex.config.listField.List.__len__ (   self)

Definition at line 119 of file listField.py.

119  def __len__(self):
120  return len(self._list)
121 

◆ __ne__()

def pex.config.listField.List.__ne__ (   self,
  other 
)

Definition at line 200 of file listField.py.

200  def __ne__(self, other):
201  return not self.__eq__(other)
202 

◆ __repr__()

def pex.config.listField.List.__repr__ (   self)

Definition at line 181 of file listField.py.

181  def __repr__(self):
182  return repr(self._list)
183 

◆ __setattr__()

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

Definition at line 203 of file listField.py.

203  def __setattr__(self, attr, value, at=None, label="assignment"):
204  if hasattr(getattr(self.__class__, attr, None), '__set__'):
205  # This allows properties to work.
206  object.__setattr__(self, attr, value)
207  elif attr in self.__dict__ or attr in ["_field", "_config", "_history", "_list", "__doc__"]:
208  # This allows specific private attributes to work.
209  object.__setattr__(self, attr, value)
210  else:
211  # We throw everything else.
212  msg = "%s has no attribute %s" % (_typeStr(self._field), attr)
213  raise FieldValidationError(self._field, self._config, msg)
214 
215 

◆ __setitem__()

def pex.config.listField.List.__setitem__ (   self,
  i,
  x,
  at = None,
  label = "setitem",
  setHistory = True 
)

Definition at line 122 of file listField.py.

122  def __setitem__(self, i, x, at=None, label="setitem", setHistory=True):
123  if self._config._frozen:
124  raise FieldValidationError(self._field, self._config,
125  "Cannot modify a frozen Config")
126  if isinstance(i, slice):
127  k, stop, step = i.indices(len(self))
128  for j, xj in enumerate(x):
129  xj = _autocast(xj, self._field.itemtype)
130  self.validateItem(k, xj)
131  x[j] = xj
132  k += step
133  else:
134  x = _autocast(x, self._field.itemtype)
135  self.validateItem(i, x)
136 
137  self._list[i] = x
138  if setHistory:
139  if at is None:
140  at = getCallStack()
141  self.history.append((list(self._list), at, label))
142 

◆ __str__()

def pex.config.listField.List.__str__ (   self)

Definition at line 184 of file listField.py.

184  def __str__(self):
185  return str(self._list)
186 

◆ insert()

def pex.config.listField.List.insert (   self,
  i,
  x,
  at = None,
  label = "insert",
  setHistory = True 
)
Insert an item into the list at the given index.

Parameters
----------
i : `int`
    Index where the item is inserted.
x : object
    Item that is inserted.
at : `list` of `lsst.pex.config.callStack.StackFrame`, optional
    The call stack (created by
    `lsst.pex.config.callStack.getCallStack`).
label : `str`, optional
    Event label for the history.
setHistory : `bool`, optional
    Enable setting the field's history, using the value of the ``at``
    parameter. Default is `True`.

Definition at line 159 of file listField.py.

159  def insert(self, i, x, at=None, label="insert", setHistory=True):
160  """Insert an item into the list at the given index.
161 
162  Parameters
163  ----------
164  i : `int`
165  Index where the item is inserted.
166  x : object
167  Item that is inserted.
168  at : `list` of `lsst.pex.config.callStack.StackFrame`, optional
169  The call stack (created by
170  `lsst.pex.config.callStack.getCallStack`).
171  label : `str`, optional
172  Event label for the history.
173  setHistory : `bool`, optional
174  Enable setting the field's history, using the value of the ``at``
175  parameter. Default is `True`.
176  """
177  if at is None:
178  at = getCallStack()
179  self.__setitem__(slice(i, i), [x], at=at, label=label, setHistory=setHistory)
180 

◆ list()

def pex.config.listField.List.list (   self)
Sequence of items contained by the `List` (`list`).

Definition at line 107 of file listField.py.

107  def list(self):
108  """Sequence of items contained by the `List` (`list`).
109  """
110  return self._list
111 

◆ validateItem()

def pex.config.listField.List.validateItem (   self,
  i,
  x 
)
Validate an item to determine if it can be included in the list.

Parameters
----------
i : `int`
    Index of the item in the `list`.
x : object
    Item in the `list`.

Raises
------
FieldValidationError
    Raised if an item in the ``value`` parameter does not have the
    appropriate type for this field or does not pass the field's
    `ListField.itemCheck` method.

Definition at line 80 of file listField.py.

80  def validateItem(self, i, x):
81  """Validate an item to determine if it can be included in the list.
82 
83  Parameters
84  ----------
85  i : `int`
86  Index of the item in the `list`.
87  x : object
88  Item in the `list`.
89 
90  Raises
91  ------
92  FieldValidationError
93  Raised if an item in the ``value`` parameter does not have the
94  appropriate type for this field or does not pass the field's
95  `ListField.itemCheck` method.
96  """
97 
98  if not isinstance(x, self._field.itemtype) and x is not None:
99  msg = "Item at position %d with value %s is of incorrect type %s. Expected %s" % \
100  (i, x, _typeStr(x), _typeStr(self._field.itemtype))
101  raise FieldValidationError(self._field, self._config, msg)
102 
103  if self._field.itemCheck is not None and not self._field.itemCheck(x):
104  msg = "Item at position %d is not a valid value: %s" % (i, x)
105  raise FieldValidationError(self._field, self._config, msg)
106 

Property Documentation

◆ history

pex.config.listField.List.history = property(lambda x: x._history)
static

Definition at line 112 of file listField.py.


The documentation for this class was generated from the following file:
ast::append
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33
pex.config.callStack.getCallStack
def getCallStack(skip=0)
Definition: callStack.py:175
list
daf::base::PropertyList * list
Definition: fits.cc:913
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88