Mapping#

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

Bases: 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)  
(17.0, 14.2)

Attributes Summary

linear

mapping

Integers representing indices of the inputs.

n_inputs

n_outputs

Methods Summary

evaluate(*args)

Evaluate the model on some input variables.

Attributes Documentation

linear = True#
mapping#

Integers representing indices of the inputs.

n_inputs#

The number of inputs.

n_outputs#

The number of outputs.

Methods Documentation

evaluate(*args)[source]#

Evaluate the model on some input variables.