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 | List of all members
lsst.afw.table._schemaMapper.SchemaMapper Class Reference

Public Member Functions

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

Detailed Description

Definition at line 32 of file _schemaMapper.py.

Member Function Documentation

◆ __eq__()

def 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__()

def 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()

def 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()

def 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: