22 from __future__
import absolute_import, division, print_function
26 from past.builtins
import basestring
30 from lsst.utils
import continueClass
31 from ..schema
import KeyFlag
32 from .baseColumnView
import _BaseColumnViewBase
43 """Get the bits associated with the specified keys 45 Unlike the C++ version, each key may be a field name or a key, 46 and if keys is None then all bits are returned. 49 return self.getAllBits()
52 if isinstance(k, basestring):
53 arg.append(self.schema.find(k).key)
56 return self._getBits(arg)
59 """Get a column view; key may be a key object or the name of a field. 61 if isinstance(key, basestring):
62 keyobj = self.schema.find(key).key
65 return self._basicget(keyobj)
70 """Set a full column to an array or scalar; key may be a key object or 73 self.
get(key)[:] = value
78 """Get the value of a flag column as a boolean array; key must be a 79 key object or the name of a field. 81 if isinstance(key, KeyFlag):
83 raise TypeError(
"key={} not an lsst.afw.table.KeyFlag".format(key))
86 """Extract a dictionary of {<name>: <column-array>} in which the field 87 names match the given shell-style glob pattern(s). 89 Any number of glob patterns may be passed (including none); the result 90 will be the union of all the result of each glob considered 93 Note that extract("*", copy=True) provides an easy way to transform a 94 row-major ColumnView into a possibly more efficient set of contiguous 97 This routines unpacks `Flag` columns into full boolean arrays and 98 covariances into dense (i.e. non-triangular packed) arrays with 99 dimension (N,M,M), where N is the number of records and M is the 100 dimension of the covariance matrix. String fields are silently 103 Additional Keyword Arguments 104 ---------------------------- 105 items : `list` The result of a call to self.schema.extract(); this 106 will be used instead of doing any new matching, and allows the 107 pattern matching to be reused to extract values from multiple 108 records. This keyword is incompatible with any position arguments 109 and the regex, sub, and ordered keyword arguments. 111 where : array index expression 112 Any expression that can be passed as indices to a NumPy array, 113 including slices, boolean arrays, and index arrays, that will be 114 used to index each column array. This is applied before arrays 115 are copied when copy is True, so if the indexing results in an 116 implicit copy no unnecessary second copy is performed. 119 If True, the returned arrays will be contiguous copies rather than 120 strided views into the catalog. This ensures that the lifetime of 121 the catalog is not tied to the lifetime of a particular catalog, 122 and it also may improve the performance if the array is used 123 repeatedly. Default is False. 125 regex : `str` or `re` pattern 126 A regular expression to be used in addition to any glob patterns 127 passed as positional arguments. Note that this will be compared 128 with re.match, not re.search. 131 A replacement string (see re.MatchObject.expand) used to set the 132 dictionary keys of any fields matched by regex. 135 If True, a collections.OrderedDict will be returned instead of a 136 standard dict, with the order corresponding to the definition 137 order of the Schema. Default is False. 139 copy = kwds.pop(
"copy",
False)
140 where = kwds.pop(
"where",
None)
141 d = kwds.pop(
"items",
None)
146 d = self.schema.
extract(*patterns, **kwds).copy()
149 "kwd 'items' was specified, which is not compatible with additional keywords")
152 if where
is not None:
155 a = np.ascontiguousarray(a)
159 for name, schemaItem
in list(d.items()):
161 if key.getTypeString() ==
"String":
164 d[name] = processArray(self.
get(schemaItem.key))
def getBits(self, keys=None)
def __setitem__(self, key, value)
def get_bool_array(self, key)
def extract(self, patterns, kwds)
def __getitem__(self, key)