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 | Static Public Attributes | List of all members
lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList Class Reference

Public Member Functions

def get (self, name, default=None)
 
def getArray (self, name)
 
def getScalar (self, name)
 
def set (self, name, value, comment=None)
 
def add (self, name, value, comment=None)
 
def setComment (self, name, comment)
 
def toList (self)
 
def toOrderedDict (self)
 
def __eq__ (self, other)
 
def __copy__ (self)
 
def __deepcopy__ (self, memo)
 
def __iter__ (self)
 
def __setitem__ (self, name, value)
 
def __reduce__ (self)
 

Static Public Attributes

string COMMENTSUFFIX = "#COMMENT"
 
def toDict = toOrderedDict
 

Detailed Description

Definition at line 742 of file propertyContainerContinued.py.

Member Function Documentation

◆ __copy__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__copy__ (   self)

Definition at line 955 of file propertyContainerContinued.py.

955  def __copy__(self):
956  # Copy without having to go through pickle state
957  pl = PropertyList()
958  for itemName in self:
959  pl.copy(itemName, self, itemName)
960  return pl
961 

◆ __deepcopy__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__deepcopy__ (   self,
  memo 
)

Definition at line 962 of file propertyContainerContinued.py.

962  def __deepcopy__(self, memo):
963  result = self.deepCopy()
964  memo[id(self)] = result
965  return result
966 
table::Key< int > id
Definition: Detector.cc:162

◆ __eq__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__eq__ (   self,
  other 
)

Definition at line 942 of file propertyContainerContinued.py.

942  def __eq__(self, other):
943  # super() doesn't seem to work properly in @continueClass;
944  # note that super with arguments seems to work at first, but actually
945  # doesn't either.
946  if not PropertySet.__eq__(self, other):
947  return False
948 
949  for name in self:
950  if self.getComment(name) != other.getComment(name):
951  return False
952 
953  return True
954 

◆ __iter__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__iter__ (   self)

Definition at line 967 of file propertyContainerContinued.py.

967  def __iter__(self):
968  for n in self.getOrderedNames():
969  yield n
970 

◆ __reduce__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__reduce__ (   self)

Definition at line 1001 of file propertyContainerContinued.py.

1001  def __reduce__(self):
1002  # It would be a bit simpler to use __setstate__ and __getstate__.
1003  # However, implementing __setstate__ in Python causes segfaults
1004  # because pickle creates a new instance by calling
1005  # object.__new__(PropertyList, *args) which bypasses
1006  # the pybind11 memory allocation step.
1007  return (_makePropertyList, (getPropertyListState(self),))

◆ __setitem__()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.__setitem__ (   self,
  name,
  value 
)
Assigns the supplied value to the container.

Parameters
----------
name : `str`
    Name of item to update. If the name ends with
    `PropertyList.COMMENTSUFFIX`, the comment is updated rather
    than the value.
value : Value to assign
    Can be any value supported by the container's ``set()``
    method. `~collections.abc.Mapping` are converted to
    `PropertySet` before assignment.

Notes
-----
Uses `PropertySet.set`, overwriting any previous value.

Definition at line 971 of file propertyContainerContinued.py.

971  def __setitem__(self, name, value):
972  """Assigns the supplied value to the container.
973 
974  Parameters
975  ----------
976  name : `str`
977  Name of item to update. If the name ends with
978  `PropertyList.COMMENTSUFFIX`, the comment is updated rather
979  than the value.
980  value : Value to assign
981  Can be any value supported by the container's ``set()``
982  method. `~collections.abc.Mapping` are converted to
983  `PropertySet` before assignment.
984 
985  Notes
986  -----
987  Uses `PropertySet.set`, overwriting any previous value.
988  """
989  if name.endswith(self.COMMENTSUFFIX):
990  name = name[:-len(self.COMMENTSUFFIX)]
991  self.setComment(name, value)
992  return
993  if isinstance(value, Mapping):
994  # Create a property set instead
995  ps = PropertySet()
996  for k, v in value.items():
997  ps[k] = v
998  value = ps
999  self.set(name, value)
1000 

◆ add()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.add (   self,
  name,
  value,
  comment = None 
)
Append one or more values to a given item, which need not exist

If the item exists then the new value(s) are appended;
otherwise it is like calling `set`

Parameters
----------
name : `str`
    Name of item
value : any supported type
    Value of item; may be a scalar or array

Notes
-----
If `value` is an `lsst.daf.base.PropertySet` items are added
using dotted names (e.g. if name="a" and value contains
an item "b" which is another PropertySet and contains an
item "c" which is numeric or string, then the value of "c"
is added as "a.b.c", appended to the existing values of
"a.b.c" if any (in which case the types must be compatible).

Raises
------
lsst::pex::exceptions::TypeError
    Raise if the type of ``value`` is incompatible with the existing
    value of the item.

Definition at line 846 of file propertyContainerContinued.py.

846  def add(self, name, value, comment=None):
847  """Append one or more values to a given item, which need not exist
848 
849  If the item exists then the new value(s) are appended;
850  otherwise it is like calling `set`
851 
852  Parameters
853  ----------
854  name : `str`
855  Name of item
856  value : any supported type
857  Value of item; may be a scalar or array
858 
859  Notes
860  -----
861  If `value` is an `lsst.daf.base.PropertySet` items are added
862  using dotted names (e.g. if name="a" and value contains
863  an item "b" which is another PropertySet and contains an
864  item "c" which is numeric or string, then the value of "c"
865  is added as "a.b.c", appended to the existing values of
866  "a.b.c" if any (in which case the types must be compatible).
867 
868  Raises
869  ------
870  lsst::pex::exceptions::TypeError
871  Raise if the type of ``value`` is incompatible with the existing
872  value of the item.
873  """
874  args = []
875  if comment is not None:
876  args.append(comment)
877  return _propertyContainerAdd(self, name, value, self._typeMenu, *args)
878 

◆ get()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.get (   self,
  name,
  default = None 
)
Return an item as a scalar, else default.

Identical to `getScalar` except that a default value is returned
if the requested key is not present.  If an array item is requested
the final value in the array will be returned.

Parameters
----------
name : ``str``
    Name of item
default : `object`, optional
    Default value to use if the named item is not present.

Returns
-------
value : any type supported by container
    Single value of any type supported by the container, else the
    default value if the requested item is not present in the
    container.  For array items the most recently added value is
    returned.

Definition at line 758 of file propertyContainerContinued.py.

758  def get(self, name, default=None):
759  """Return an item as a scalar, else default.
760 
761  Identical to `getScalar` except that a default value is returned
762  if the requested key is not present. If an array item is requested
763  the final value in the array will be returned.
764 
765  Parameters
766  ----------
767  name : ``str``
768  Name of item
769  default : `object`, optional
770  Default value to use if the named item is not present.
771 
772  Returns
773  -------
774  value : any type supported by container
775  Single value of any type supported by the container, else the
776  default value if the requested item is not present in the
777  container. For array items the most recently added value is
778  returned.
779  """
780  try:
781  return _propertyContainerGet(self, name, returnStyle=ReturnStyle.SCALAR)
782  except KeyError:
783  return default
784 

◆ getArray()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.getArray (   self,
  name 
)
Return an item as a list.

Parameters
----------
name : `str`
    Name of item

Returns
-------
values : `list` of values
    The contents of the item, guaranteed to be returned as a `list.`

Raises
------
KeyError
    Raised if the item does not exist.

Definition at line 785 of file propertyContainerContinued.py.

785  def getArray(self, name):
786  """Return an item as a list.
787 
788  Parameters
789  ----------
790  name : `str`
791  Name of item
792 
793  Returns
794  -------
795  values : `list` of values
796  The contents of the item, guaranteed to be returned as a `list.`
797 
798  Raises
799  ------
800  KeyError
801  Raised if the item does not exist.
802  """
803  return _propertyContainerGet(self, name, returnStyle=ReturnStyle.ARRAY)
804 

◆ getScalar()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.getScalar (   self,
  name 
)
Return an item as a scalar

If the item has more than one value then the last value is returned.

Parameters
----------
name : `str`
    Name of item.

Returns
-------
value : scalar item
    Value stored in the item.  If the item refers to an array the
    most recently added value is returned.

Raises
------
KeyError
    Raised if the item does not exist.

Definition at line 805 of file propertyContainerContinued.py.

805  def getScalar(self, name):
806  """Return an item as a scalar
807 
808  If the item has more than one value then the last value is returned.
809 
810  Parameters
811  ----------
812  name : `str`
813  Name of item.
814 
815  Returns
816  -------
817  value : scalar item
818  Value stored in the item. If the item refers to an array the
819  most recently added value is returned.
820 
821  Raises
822  ------
823  KeyError
824  Raised if the item does not exist.
825  """
826  return _propertyContainerGet(self, name, returnStyle=ReturnStyle.SCALAR)
827 

◆ set()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.set (   self,
  name,
  value,
  comment = None 
)
Set the value of an item

If the item already exists it is silently replaced; the types
need not match.

Parameters
----------
name : `str`
    Name of item
value : any supported type
    Value of item; may be a scalar or array

Definition at line 828 of file propertyContainerContinued.py.

828  def set(self, name, value, comment=None):
829  """Set the value of an item
830 
831  If the item already exists it is silently replaced; the types
832  need not match.
833 
834  Parameters
835  ----------
836  name : `str`
837  Name of item
838  value : any supported type
839  Value of item; may be a scalar or array
840  """
841  args = []
842  if comment is not None:
843  args.append(comment)
844  return _propertyContainerSet(self, name, value, self._typeMenu, *args)
845 
daf::base::PropertySet * set
Definition: fits.cc:912

◆ setComment()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.setComment (   self,
  name,
  comment 
)
Set the comment for an existing entry.

Parameters
----------
name : `str`
    Name of the key to receive updated comment.
comment : `comment`
    New comment string.

Definition at line 879 of file propertyContainerContinued.py.

879  def setComment(self, name, comment):
880  """Set the comment for an existing entry.
881 
882  Parameters
883  ----------
884  name : `str`
885  Name of the key to receive updated comment.
886  comment : `comment`
887  New comment string.
888  """
889  # The only way to do this is to replace the existing entry with
890  # one that has the new comment
891  containerType = _propertyContainerElementTypeName(self, name)
892  if self.isArray(name):
893  value = self.getArray(name)
894  else:
895  value = self.getScalar(name)
896  getattr(self, f"set{containerType}")(name, value, comment)
897 

◆ toList()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.toList (   self)
Return a list of tuples of name, value, comment for each property
in the order that they were inserted.

Returns
-------
ret : `list` of `tuple`
    Tuples of name, value, comment for each property in the order
    in which they were inserted.

Definition at line 898 of file propertyContainerContinued.py.

898  def toList(self):
899  """Return a list of tuples of name, value, comment for each property
900  in the order that they were inserted.
901 
902  Returns
903  -------
904  ret : `list` of `tuple`
905  Tuples of name, value, comment for each property in the order
906  in which they were inserted.
907  """
908  orderedNames = self.getOrderedNames()
909  ret = []
910  for name in orderedNames:
911  if self.isArray(name):
912  values = _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO)
913  for v in values:
914  ret.append((name, v, self.getComment(name)))
915  else:
916  ret.append((name, _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO),
917  self.getComment(name)))
918  return ret
919 

◆ toOrderedDict()

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.toOrderedDict (   self)
Return an ordered dictionary with all properties in the order that
they were inserted.

Returns
-------
d : `dict`
    Ordered dictionary with all properties in the order that they
    were inserted. Comments are not included.

Notes
-----
As of Python 3.6 dicts retain their insertion order.

Definition at line 920 of file propertyContainerContinued.py.

920  def toOrderedDict(self):
921  """Return an ordered dictionary with all properties in the order that
922  they were inserted.
923 
924  Returns
925  -------
926  d : `dict`
927  Ordered dictionary with all properties in the order that they
928  were inserted. Comments are not included.
929 
930  Notes
931  -----
932  As of Python 3.6 dicts retain their insertion order.
933  """
934  d = {}
935  for name in self:
936  d[name] = _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO)
937  return d
938 

Member Data Documentation

◆ COMMENTSUFFIX

string lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.COMMENTSUFFIX = "#COMMENT"
static

Definition at line 754 of file propertyContainerContinued.py.

◆ toDict

def lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.toDict = toOrderedDict
static

Definition at line 940 of file propertyContainerContinued.py.


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