LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst.afw.table.schemaMapper.schemaMapperContinued.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 33 of file schemaMapperContinued.py.

Member Function Documentation

◆ __eq__()

def lsst.afw.table.schemaMapper.schemaMapperContinued.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 90 of file schemaMapperContinued.py.

90  def __eq__(self, other):
91  """SchemaMappers are equal if their respective input and output
92  schemas are identical, and they have the same mappings defined.
93 
94  Note: It was simpler to implement equality in python than in C++.
95  """
96  iSchema = self.getInputSchema()
97  oSchema = self.getOutputSchema()
98  if (not (iSchema.compare(other.getInputSchema(), Schema.IDENTICAL) == Schema.IDENTICAL and
99  oSchema.compare(other.getOutputSchema(), Schema.IDENTICAL) == Schema.IDENTICAL)):
100  return False
101 
102  for item in iSchema:
103  if self.isMapped(item.key) and other.isMapped(item.key):
104  if (self.getMapping(item.key) == other.getMapping(item.key)):
105  continue
106  else:
107  return False
108  elif (not self.isMapped(item.key)) and (not other.isMapped(item.key)):
109  continue
110  else:
111  return False
112 
113  return True
114 

◆ __reduce__()

def lsst.afw.table.schemaMapper.schemaMapperContinued.SchemaMapper.__reduce__ (   self)
To support pickle.

Definition at line 115 of file schemaMapperContinued.py.

115  def __reduce__(self):
116  """To support pickle."""
117  mappings = {}
118  for item in self.getInputSchema():
119  try:
120  key = self.getMapping(item.key)
122  # Not all fields may be mapped, so just continue if a mapping is not found.
123  continue
124  mappings[item.key] = self.getOutputSchema().find(key).field
125  return (makeSchemaMapper, (self.getInputSchema(), self.getOutputSchema(), mappings))
126 
127 
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151

◆ addMapping()

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

Parameters
----------
input : Key
    A Key from the input schema whose values will be mapped to the new
    field.
output : str,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.

Definition at line 65 of file schemaMapperContinued.py.

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

◆ addOutputField()

def lsst.afw.table.schemaMapper.schemaMapperContinued.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,Field
    The string name of the Field, or a fully-constructed Field object.
    If the latter, all other arguments besides doReplace are ignored.
type\n : str,type
    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.

Definition at line 36 of file schemaMapperContinued.py.

36  doReplace=False, parse_strict="raise"):
37  """Add an un-mapped field to the output Schema.
38 
39  Parameters
40  ----------
41  field : str,Field
42  The string name of the Field, or a fully-constructed Field object.
43  If the latter, all other arguments besides doReplace are ignored.
44  type\n : str,type
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  if isinstance(field, str):
61  field = Field[type](field, doc=doc, units=units,
62  size=size, parse_strict=parse_strict)
63  return field._addTo(self.editOutputSchema(), doReplace)
64 

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