LSST Applications g0d97872fb5+4fd969bb9d,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+c0e3b27cd8,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+367733290c,g80478fca09+17051a22cc,g82479be7b0+f2f1ea0a87,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+cb167bac99,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+9faa5c5784,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | List of all members
lsst.afw.table._schemaMapper.SchemaMapper Class Reference

Public Member Functions

 addOutputField (self, field, type=None, doc=None, units="", size=None, doReplace=False, parse_strict="raise")
 
 addMapping (self, input, output=None, doReplace=True)
 
 __eq__ (self, other)
 
 __reduce__ (self)
 

Detailed Description

Definition at line 32 of file _schemaMapper.py.

Member Function Documentation

◆ __eq__()

lsst.afw.table._schemaMapper.SchemaMapper.__eq__ ( self,
other )
SchemaMappers are equal if their respective input and output
schemas are identical, and they have the same mappings defined.

Note: It was simpler to implement equality in python than in C++.

Definition at line 100 of file _schemaMapper.py.

100 def __eq__(self, other):
101 """SchemaMappers are equal if their respective input and output
102 schemas are identical, and they have the same mappings defined.
103
104 Note: It was simpler to implement equality in python than in C++.
105 """
106 iSchema = self.getInputSchema()
107 oSchema = self.getOutputSchema()
108 if (not (iSchema.compare(other.getInputSchema(), Schema.IDENTICAL) == Schema.IDENTICAL
109 and oSchema.compare(other.getOutputSchema(), Schema.IDENTICAL) == Schema.IDENTICAL)):
110 return False
111
112 for item in iSchema:
113 if self.isMapped(item.key) and other.isMapped(item.key):
114 if (self.getMapping(item.key) == other.getMapping(item.key)):
115 continue
116 else:
117 return False
118 elif (not self.isMapped(item.key)) and (not other.isMapped(item.key)):
119 continue
120 else:
121 return False
122
123 return True
124

◆ __reduce__()

lsst.afw.table._schemaMapper.SchemaMapper.__reduce__ ( self)
To support pickle.

Definition at line 125 of file _schemaMapper.py.

125 def __reduce__(self):
126 """To support pickle."""
127 mappings = {}
128 for item in self.getInputSchema():
129 try:
130 key = self.getMapping(item.key)
132 # Not all fields may be mapped, so just continue if a mapping is not found.
133 continue
134 mappings[item.key] = self.getOutputSchema().find(key).field
135 return (makeSchemaMapper, (self.getInputSchema(), self.getOutputSchema(), mappings))
136
137
Reports attempts to access elements using an invalid key.
Definition Runtime.h:151

◆ addMapping()

lsst.afw.table._schemaMapper.SchemaMapper.addMapping ( self,
input,
output = None,
doReplace = True )
Add a mapped field to the output schema.

Parameters
----------
input : `~lsst.afw.table.Key`
    A `Key` from the input schema whose values will be mapped to the new
    field.
output : `str` or `~lsst.afw.table.Field`
    A `Field` object that describes the new field to be added to the
    output schema, or the name of the field (with documentation and
    units copied from the input schema).  May be None to copy everything
    from the input schema.
doReplace : `bool`
    If a field with this name already exists in the output schema,
    replace it instead of raising `pex.exceptions.InvalidParameterError`.

Returns
-------
key : `~lsst.afw.table.Key`
    The key for the new mapped field.

Definition at line 70 of file _schemaMapper.py.

70 def addMapping(self, input, output=None, doReplace=True):
71 """Add a mapped field to the output schema.
72
73 Parameters
74 ----------
75 input : `~lsst.afw.table.Key`
76 A `Key` from the input schema whose values will be mapped to the new
77 field.
78 output : `str` or `~lsst.afw.table.Field`
79 A `Field` object that describes the new field to be added to the
80 output schema, or the name of the field (with documentation and
81 units copied from the input schema). May be None to copy everything
82 from the input schema.
83 doReplace : `bool`
84 If a field with this name already exists in the output schema,
85 replace it instead of raising `pex.exceptions.InvalidParameterError`.
86
87 Returns
88 -------
89 key : `~lsst.afw.table.Key`
90 The key for the new mapped field.
91 """
92 # Workaround for calling positional arguments; avoids an API change during pybind11 conversion,
93 # but we should just make that change and encourage using kwargs in the
94 # future.
95 if output is True or output is False:
96 doReplace = output
97 output = None
98 return input._addMappingTo(self, output, doReplace)
99

◆ addOutputField()

lsst.afw.table._schemaMapper.SchemaMapper.addOutputField ( self,
field,
type = None,
doc = None,
units = "",
size = None,
doReplace = False,
parse_strict = "raise" )
Add an un-mapped field to the output Schema.

Parameters
----------
field : `str` or `~lsst.afw.table.Field`
    The string name of the `Field`, or a fully-constructed
    `Field` object.  If the latter, all other arguments
    besides doReplace are ignored.
type : `str`
    The type of field to create.  Valid types are the keys of the
    afw.table.Field dictionary.
doc : `str`
    Documentation for the field.
unit : `str`
    Units for the field, or an empty string if unitless.
size : `int`
    Size of the field; valid for string and array fields only.
doReplace : `bool`
    If a field with this name already exists, replace it instead of
    raising pex.exceptions.InvalidParameterError.
parse_strict : `str`
    One of 'raise' (default), 'warn', or 'strict', indicating how to
    handle unrecognized unit strings.  See also astropy.units.Unit.

Returns
-------
key : `~lsst.afw.table.Key`
    The key of the field added.

Definition at line 34 of file _schemaMapper.py.

35 doReplace=False, parse_strict="raise"):
36 """Add an un-mapped field to the output Schema.
37
38 Parameters
39 ----------
40 field : `str` or `~lsst.afw.table.Field`
41 The string name of the `Field`, or a fully-constructed
42 `Field` object. If the latter, all other arguments
43 besides doReplace are ignored.
44 type : `str`
45 The type of field to create. Valid types are the keys of the
46 afw.table.Field dictionary.
47 doc : `str`
48 Documentation for the field.
49 unit : `str`
50 Units for the field, or an empty string if unitless.
51 size : `int`
52 Size of the field; valid for string and array fields only.
53 doReplace : `bool`
54 If a field with this name already exists, replace it instead of
55 raising pex.exceptions.InvalidParameterError.
56 parse_strict : `str`
57 One of 'raise' (default), 'warn', or 'strict', indicating how to
58 handle unrecognized unit strings. See also astropy.units.Unit.
59
60 Returns
61 -------
62 key : `~lsst.afw.table.Key`
63 The key of the field added.
64 """
65 if isinstance(field, str):
66 field = Field[type](field, doc=doc, units=units,
67 size=size, parse_strict=parse_strict)
68 return field._addTo(self.editOutputSchema(), doReplace)
69

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