Source code for pymt.mappers.imapper
[docs]class MapperError(Exception):
"""Base class for error in this package."""
pass
[docs]class IncompatibleGridError(MapperError):
"""Error to indicate that the source grid cannot be mapped to the
destination.
"""
def __init__(self, dst, src):
self._src = src
self._dst = dst
def __str__(self):
return f"Unable to map {self._src} to {self._dst}"
[docs]class NoMapperError(MapperError):
def __init__(self, dst, src):
self._src = src
self._dst = dst
def __str__(self):
return f"No mapper to map {self._src} to {self._dst}"
[docs]class IGridMapper:
"""Interface for a grid mapper."""
[docs] def initialize(self, dest_grid, src_grid, **kwds):
"""Initialize the mapper to map from a source grid to a destination
grid.
"""
pass
[docs] def run(self, src_values, **kwds):
"""Map values on the source grid to the destination grid."""
pass