dupin.data.map#
Overview
Wrap a custom mapping callable. |
|
A identity mapping for use in a data pipeline. |
|
Combine mutliple maps into one acting on the same generator object. |
Details
dupin.data.base.DataMap
subclasses to transform distributional data.
Mapping in dupin is the idea of taking one distribution and transforming it
into another. This is distinct from the mathematical view of functions as maps
and is more general than Python’s map builtin. A distribution/array can be
mapped to a new array of any size. A common example in molecular simulations is
spatial averaging which reduces local fluctuations of features. This particular
map can be found in dupin.data.spatial.NeighborAveraging
.
- class dupin.data.map.CustomMap(generator, custom_function)[source]#
Wrap a custom mapping callable.
- Parameters:
generator (
GeneratorLike
) – A generator like object to transform.custom_function (
callable
[numpy.ndarray
,dict
]) – A custom callable that takes in a NumPy array and returns a dictionary with keys indicating the tranformation and values the transformed distribution (array).
- function#
The provided callable.
- Type:
callable
[[numpy.ndarray
],dict
]
- class dupin.data.map.Identity[source]#
A identity mapping for use in a data pipeline.
This class maps a distribution to itself. This is useful when using with
Tee
.Example:
generator.pipe( du.data.map.Tee([ du.data.map.Identity() du.data.map.CustomMap(lambda x: {"new_dist": x + 2}) ]) )
- class dupin.data.map.Tee(maps)[source]#
Combine mutliple maps into one acting on the same generator object.
Example:
generator.pipe( du.data.map.Tee([ du.data.map.Identity(), du.data.map.CustomMap(lambda x: {"new_dist": x + 2}) ]) )
- Parameters:
reducers (
list
[dupin.data.base.DataReducer
]) – A sequence of data modifiers.
- attach_logger(logger)[source]#
Add a logger to this step in the data pipeline.
- Parameters:
logger (dupin.data.logging.Logger) – A logger object to store data from the data pipeline for individual elements of the composed maps.