LSST Applications g0265f82a02+093ff98f47,g02d81e74bb+10352d6f39,g1f3e9fa97e+40b0fc677d,g2079a07aa2+14824f138e,g2bbee38e9b+093ff98f47,g337abbeb29+093ff98f47,g3ddfee87b4+064c02c7ee,g487adcacf7+7e842ebf4b,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g568d43a26c+1d7ac31cb0,g591dd9f2cf+fb1f69e2ea,g858d7b2824+10352d6f39,g8a8a8dda67+a6fc98d2e7,g8cdfe0ae6a+66d966b544,g99cad8db69+7ce8a7c20a,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga2e4dd1c03+064c02c7ee,ga8c6da7877+04f6ba86dc,gae46bcf261+093ff98f47,gb0e22166c9+3863383f4c,gba4ed39666+9664299f35,gbb8dafda3b+db40f59a7d,gbeb006f7da+e6a448e96d,gbf5cecdb8a+10352d6f39,gc0f3af6251+10a3fd39cd,gc120e1dc64+5839e50a77,gc28159a63d+093ff98f47,gcf0d15dbbd+064c02c7ee,gd2a12a3803+0c2c227a2b,gdaeeff99f8+a38ce5ea23,ge79ae78c31+093ff98f47,gee10cc3b42+a6fc98d2e7,gf1cff7945b+10352d6f39,w.2024.15
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lsst.afw.table._base.BaseRecord Class Reference

Public Member Functions

 extract (self, *patterns, **kwargs)
 
 __repr__ (self)
 

Detailed Description

Definition at line 32 of file _base.py.

Member Function Documentation

◆ __repr__()

lsst.afw.table._base.BaseRecord.__repr__ ( self)

Definition at line 69 of file _base.py.

69 def __repr__(self):
70 return f"{type(self)}\n{self}"
71
72

◆ extract()

lsst.afw.table._base.BaseRecord.extract ( self,
* patterns,
** kwargs )
Extract a dictionary of {<name>: <field-value>} in which the field
names match the given shell-style glob pattern(s).

Any number of glob patterns may be passed; the result will be the union
of all the result of each glob considered separately.

Parameters
----------
items : `dict`
    The result of a call to self.schema.extract(); this will be used
    instead of doing any new matching, and allows the pattern matching
    to be reused to extract values from multiple records.  This
    keyword is incompatible with any position arguments and the regex,
    sub, and ordered keyword arguments.
regex : `str` or `re` pattern object
    A regular expression to be used in addition to any glob patterns
    passed as positional arguments.  Note that this will be compared
    with re.match, not re.search.
sub : `str`
    A replacement string (see `re.MatchObject.expand`) used to set the
    dictionary keys of any fields matched by regex.
ordered : `bool`
    If `True`, a `collections.OrderedDict` will be returned instead of
    a standard dict, with the order corresponding to the definition
    order of the `Schema`. Default is `False`.

Definition at line 34 of file _base.py.

34 def extract(self, *patterns, **kwargs):
35 """Extract a dictionary of {<name>: <field-value>} in which the field
36 names match the given shell-style glob pattern(s).
37
38 Any number of glob patterns may be passed; the result will be the union
39 of all the result of each glob considered separately.
40
41 Parameters
42 ----------
43 items : `dict`
44 The result of a call to self.schema.extract(); this will be used
45 instead of doing any new matching, and allows the pattern matching
46 to be reused to extract values from multiple records. This
47 keyword is incompatible with any position arguments and the regex,
48 sub, and ordered keyword arguments.
49 regex : `str` or `re` pattern object
50 A regular expression to be used in addition to any glob patterns
51 passed as positional arguments. Note that this will be compared
52 with re.match, not re.search.
53 sub : `str`
54 A replacement string (see `re.MatchObject.expand`) used to set the
55 dictionary keys of any fields matched by regex.
56 ordered : `bool`
57 If `True`, a `collections.OrderedDict` will be returned instead of
58 a standard dict, with the order corresponding to the definition
59 order of the `Schema`. Default is `False`.
60 """
61 d = kwargs.pop("items", None)
62 if d is None:
63 d = self.schema.extract(*patterns, **kwargs).copy()
64 elif kwargs:
65 kwargsStr = ", ".join(kwargs.keys())
66 raise ValueError(f"Unrecognized keyword arguments for extract: {kwargsStr}")
67 return {name: self.get(schemaItem.key) for name, schemaItem in d.items()}
68

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