dupin.data.map#

Overview

CustomMap

Wrap a custom mapping callable.

Identity

A identity mapping for use in a data pipeline.

Tee

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 ]

__init__(generator, custom_function)[source]#
compute(data)[source]#

Call the internal function.

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})
    ])
)
__init__()[source]#
compute(data)[source]#

Return the same distribution.

Parameters:

distribution (\((N,)\) numpy.ndarray of float) – The array representing a distribution to map.

Returns:

signals – Returns a dictionary with the key None and the passed in data as a value.

Return type:

dict[str, float]

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.

__init__(maps)[source]#
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.

compute(distribution)[source]#

Run all composed map computes.

remove_logger()[source]#

Remove a logger from this step in the pipeline if it exists.

update(args, kwargs)[source]#

Iterate over composed mappings and call update.