LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList Class Reference

Public Member Functions

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

Public Attributes

 COMMENTSUFFIX
 

Static Public Attributes

str COMMENTSUFFIX = "#COMMENT"
 
 toDict = toOrderedDict
 

Protected Attributes

 _typeMenu
 

Static Protected Attributes

dict _typeMenu
 

Detailed Description

Definition at line 849 of file propertyContainerContinued.py.

Member Function Documentation

◆ __copy__()

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

Definition at line 1062 of file propertyContainerContinued.py.

1062 def __copy__(self):
1063 # Copy without having to go through pickle state
1064 pl = PropertyList()
1065 for itemName in self:
1066 pl.copy(itemName, self, itemName)
1067 return pl
1068

◆ __deepcopy__()

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

Definition at line 1069 of file propertyContainerContinued.py.

1069 def __deepcopy__(self, memo):
1070 result = self.deepCopy()
1071 memo[id(self)] = result
1072 return result
1073
table::Key< int > id
Definition Detector.cc:162

◆ __eq__()

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

Definition at line 1049 of file propertyContainerContinued.py.

1049 def __eq__(self, other):
1050 # super() doesn't seem to work properly in @continueClass;
1051 # note that super with arguments seems to work at first, but actually
1052 # doesn't either.
1053 if not PropertySet.__eq__(self, other):
1054 return False
1055
1056 for name in self:
1057 if self.getComment(name) != other.getComment(name):
1058 return False
1059
1060 return True
1061

◆ __iter__()

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

Definition at line 1074 of file propertyContainerContinued.py.

1074 def __iter__(self):
1075 for n in self.getOrderedNames():
1076 yield n
1077

◆ __reduce__()

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

Definition at line 1108 of file propertyContainerContinued.py.

1108 def __reduce__(self):
1109 # It would be a bit simpler to use __setstate__ and __getstate__.
1110 # However, implementing __setstate__ in Python causes segfaults
1111 # because pickle creates a new instance by calling
1112 # object.__new__(PropertyList, *args) which bypasses
1113 # the pybind11 memory allocation step.
1114 return (_makePropertyList, (getPropertyListState(self),))
1115

◆ __setitem__()

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 1078 of file propertyContainerContinued.py.

1078 def __setitem__(self, name, value):
1079 """Assigns the supplied value to the container.
1080
1081 Parameters
1082 ----------
1083 name : `str`
1084 Name of item to update. If the name ends with
1085 `PropertyList.COMMENTSUFFIX`, the comment is updated rather
1086 than the value.
1087 value : Value to assign
1088 Can be any value supported by the container's ``set()``
1089 method. `~collections.abc.Mapping` are converted to
1090 `PropertySet` before assignment.
1091
1092 Notes
1093 -----
1094 Uses `PropertySet.set`, overwriting any previous value.
1095 """
1096 if name.endswith(self.COMMENTSUFFIX):
1097 name = name[:-len(self.COMMENTSUFFIX)]
1098 self.setComment(name, value)
1099 return
1100 if isinstance(value, Mapping):
1101 # Create a property set instead
1102 ps = PropertySet()
1103 for k, v in value.items():
1104 ps[k] = v
1105 value = ps
1106 self.set(name, value)
1107

◆ add()

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 953 of file propertyContainerContinued.py.

953 def add(self, name, value, comment=None):
954 """Append one or more values to a given item, which need not exist
955
956 If the item exists then the new value(s) are appended;
957 otherwise it is like calling `set`
958
959 Parameters
960 ----------
961 name : `str`
962 Name of item
963 value : any supported type
964 Value of item; may be a scalar or array
965
966 Notes
967 -----
968 If `value` is an `lsst.daf.base.PropertySet` items are added
969 using dotted names (e.g. if name="a" and value contains
970 an item "b" which is another PropertySet and contains an
971 item "c" which is numeric or string, then the value of "c"
972 is added as "a.b.c", appended to the existing values of
973 "a.b.c" if any (in which case the types must be compatible).
974
975 Raises
976 ------
977 lsst::pex::exceptions::TypeError
978 Raise if the type of ``value`` is incompatible with the existing
979 value of the item.
980 """
981 args = []
982 if comment is not None:
983 args.append(comment)
984 return _propertyContainerAdd(self, name, value, self._typeMenu, *args)
985

◆ get()

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 865 of file propertyContainerContinued.py.

865 def get(self, name, default=None):
866 """Return an item as a scalar, else default.
867
868 Identical to `getScalar` except that a default value is returned
869 if the requested key is not present. If an array item is requested
870 the final value in the array will be returned.
871
872 Parameters
873 ----------
874 name : ``str``
875 Name of item
876 default : `object`, optional
877 Default value to use if the named item is not present.
878
879 Returns
880 -------
881 value : any type supported by container
882 Single value of any type supported by the container, else the
883 default value if the requested item is not present in the
884 container. For array items the most recently added value is
885 returned.
886 """
887 try:
888 return _propertyContainerGet(self, name, returnStyle=ReturnStyle.SCALAR)
889 except KeyError:
890 return default
891

◆ get_dict()

NestedMetadataDict lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.get_dict ( self,
str key )
Return a possibly-hierarchical nested `dict`.

This implements the `lsst.pipe.base.GetDictMetadata` protocol for
consistency with `lsst.pipe.base.TaskMetadata` and `PropertySet`.

Parameters
----------
key : `str`
    String key associated with the mapping.  May not have a ``.``
    character.

Returns
-------
value : `~collections.abc.Mapping`
    Possibly-nested mapping, with `str` keys and values that are `int`,
    `float`, `str`, `bool`, or another `dict` with the same key and
    value types.  Will be empty if ``key`` does not exist.

Definition at line 1116 of file propertyContainerContinued.py.

1116 def get_dict(self, key: str) -> NestedMetadataDict:
1117 """Return a possibly-hierarchical nested `dict`.
1118
1119 This implements the `lsst.pipe.base.GetDictMetadata` protocol for
1120 consistency with `lsst.pipe.base.TaskMetadata` and `PropertySet`.
1121
1122 Parameters
1123 ----------
1124 key : `str`
1125 String key associated with the mapping. May not have a ``.``
1126 character.
1127
1128 Returns
1129 -------
1130 value : `~collections.abc.Mapping`
1131 Possibly-nested mapping, with `str` keys and values that are `int`,
1132 `float`, `str`, `bool`, or another `dict` with the same key and
1133 value types. Will be empty if ``key`` does not exist.
1134 """
1135 result: NestedMetadataDict = {}
1136 name: str
1137 for name in self.getOrderedNames():
1138 levels = name.split(".")
1139 if levels[0] == key:
1140 nested = result
1141 for level_key in levels[1:-1]:
1142 nested = result.setdefault(level_key, {})
1143 nested[levels[-1]] = self[name]
1144 return result
1145

◆ getArray()

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 892 of file propertyContainerContinued.py.

892 def getArray(self, name):
893 """Return an item as a list.
894
895 Parameters
896 ----------
897 name : `str`
898 Name of item
899
900 Returns
901 -------
902 values : `list` of values
903 The contents of the item, guaranteed to be returned as a `list.`
904
905 Raises
906 ------
907 KeyError
908 Raised if the item does not exist.
909 """
910 return _propertyContainerGet(self, name, returnStyle=ReturnStyle.ARRAY)
911

◆ getScalar()

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 912 of file propertyContainerContinued.py.

912 def getScalar(self, name):
913 """Return an item as a scalar
914
915 If the item has more than one value then the last value is returned.
916
917 Parameters
918 ----------
919 name : `str`
920 Name of item.
921
922 Returns
923 -------
924 value : scalar item
925 Value stored in the item. If the item refers to an array the
926 most recently added value is returned.
927
928 Raises
929 ------
930 KeyError
931 Raised if the item does not exist.
932 """
933 return _propertyContainerGet(self, name, returnStyle=ReturnStyle.SCALAR)
934

◆ set()

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 935 of file propertyContainerContinued.py.

935 def set(self, name, value, comment=None):
936 """Set the value of an item
937
938 If the item already exists it is silently replaced; the types
939 need not match.
940
941 Parameters
942 ----------
943 name : `str`
944 Name of item
945 value : any supported type
946 Value of item; may be a scalar or array
947 """
948 args = []
949 if comment is not None:
950 args.append(comment)
951 return _propertyContainerSet(self, name, value, self._typeMenu, *args)
952
daf::base::PropertySet * set
Definition fits.cc:931

◆ set_dict()

None lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.set_dict ( self,
str key,
NestedMetadataDict value )
Assign a possibly-hierarchical nested `dict`.

This implements the `lsst.pipe.base.SetDictMetadata` protocol for
consistency with `lsst.pipe.base.TaskMetadata` and `PropertySet`.

Parameters
----------
key : `str`
    String key associated with the mapping.  May not have a ``.``
    character.
value : `~collections.abc.Mapping`
    Possibly-nested mapping, with `str` keys and values that are `int`,
    `float`, `str`, `bool`, or another `dict` with the same key and
    value types.  Nested keys may not have a ``.`` character.

Definition at line 1146 of file propertyContainerContinued.py.

1146 def set_dict(self, key: str, value: NestedMetadataDict) -> None:
1147 """Assign a possibly-hierarchical nested `dict`.
1148
1149 This implements the `lsst.pipe.base.SetDictMetadata` protocol for
1150 consistency with `lsst.pipe.base.TaskMetadata` and `PropertySet`.
1151
1152 Parameters
1153 ----------
1154 key : `str`
1155 String key associated with the mapping. May not have a ``.``
1156 character.
1157 value : `~collections.abc.Mapping`
1158 Possibly-nested mapping, with `str` keys and values that are `int`,
1159 `float`, `str`, `bool`, or another `dict` with the same key and
1160 value types. Nested keys may not have a ``.`` character.
1161 """
1162 self.set(key, PropertySet.from_mapping(value))

◆ setComment()

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 986 of file propertyContainerContinued.py.

986 def setComment(self, name, comment):
987 """Set the comment for an existing entry.
988
989 Parameters
990 ----------
991 name : `str`
992 Name of the key to receive updated comment.
993 comment : `comment`
994 New comment string.
995 """
996 # The only way to do this is to replace the existing entry with
997 # one that has the new comment
998 containerType = _propertyContainerElementTypeName(self, name)
999 if self.isArray(name):
1000 value = self.getArray(name)
1001 else:
1002 value = self.getScalar(name)
1003 getattr(self, f"set{containerType}")(name, value, comment)
1004

◆ toList()

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 1005 of file propertyContainerContinued.py.

1005 def toList(self):
1006 """Return a list of tuples of name, value, comment for each property
1007 in the order that they were inserted.
1008
1009 Returns
1010 -------
1011 ret : `list` of `tuple`
1012 Tuples of name, value, comment for each property in the order
1013 in which they were inserted.
1014 """
1015 orderedNames = self.getOrderedNames()
1016 ret = []
1017 for name in orderedNames:
1018 if self.isArray(name):
1019 values = _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO)
1020 for v in values:
1021 ret.append((name, v, self.getComment(name)))
1022 else:
1023 ret.append((name, _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO),
1024 self.getComment(name)))
1025 return ret
1026

◆ toOrderedDict()

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 1027 of file propertyContainerContinued.py.

1027 def toOrderedDict(self):
1028 """Return an ordered dictionary with all properties in the order that
1029 they were inserted.
1030
1031 Returns
1032 -------
1033 d : `dict`
1034 Ordered dictionary with all properties in the order that they
1035 were inserted. Comments are not included.
1036
1037 Notes
1038 -----
1039 As of Python 3.6 dicts retain their insertion order.
1040 """
1041 d = {}
1042 for name in self:
1043 d[name] = _propertyContainerGet(self, name, returnStyle=ReturnStyle.AUTO)
1044 return d
1045

Member Data Documentation

◆ _typeMenu [1/2]

dict lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList._typeMenu
staticprotected
Initial value:
= {bool: "Bool",
int: "Int",
float: "Double",
str: "String",
DateTime: "DateTime",
PropertySet: "PropertySet",
PropertyList: "PropertySet",
None: "Undef",
}

Definition at line 851 of file propertyContainerContinued.py.

◆ _typeMenu [2/2]

lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList._typeMenu
protected

Definition at line 951 of file propertyContainerContinued.py.

◆ COMMENTSUFFIX [1/2]

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

Definition at line 861 of file propertyContainerContinued.py.

◆ COMMENTSUFFIX [2/2]

lsst.daf.base.propertyContainer.propertyContainerContinued.PropertyList.COMMENTSUFFIX

Definition at line 1096 of file propertyContainerContinued.py.

◆ toDict

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

Definition at line 1047 of file propertyContainerContinued.py.


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