Mapping

class astropy.modeling.mappings.Mapping(mapping, n_inputs=None, name=None, meta=None)[source]

Bases: astropy.modeling.FittableModel

Allows inputs to be reordered, duplicated or dropped.

Parameters
mappingtuple

A tuple of integers representing indices of the inputs to this model to return and in what order to return them. See Advanced mappings for more details.

n_inputsint

Number of inputs; if None (default) then max(mapping) + 1 is used (i.e. the highest input index used in the mapping).

namestr, optional

A human-friendly name associated with this model instance (particularly useful for identifying the individual components of a compound model).

metadict-like

Free-form metadata to associate with this model.

Raises
TypeError

Raised when number of inputs is less that max(mapping).

Examples

>>> from astropy.modeling.models import Polynomial2D, Shift, Mapping
>>> poly1 = Polynomial2D(1, c0_0=1, c1_0=2, c0_1=3)
>>> poly2 = Polynomial2D(1, c0_0=1, c1_0=2.4, c0_1=2.1)
>>> model = (Shift(1) & Shift(2)) | Mapping((0, 1, 0, 1)) | (poly1 & poly2)
>>> model(1, 2)  # doctest: +FLOAT_CMP
(17.0, 14.2)

Attributes Summary

inputs

The name(s) of the input variable(s) on which a model is evaluated.

linear

mapping

Integers representing indices of the inputs.

outputs

The name(s) of the output(s) of the model.

Methods Summary

evaluate(self, \*args)

Evaluate the model on some input variables.

Attributes Documentation

inputs

The name(s) of the input variable(s) on which a model is evaluated.

linear = True
mapping

Integers representing indices of the inputs.

outputs

The name(s) of the output(s) of the model.

Methods Documentation

evaluate(self, *args)[source]

Evaluate the model on some input variables.