DataTransform

class utilipy.data_utils.DataTransform(func: Callable, fromtype, totype, priority: int = 1, register_graph=None, func_args: Optional[Sequence] = None, func_kwargs: Optional[Mapping] = None)[source]

Bases: utilipy.data_utils.xfm.transformations.DataTransformBase

A transformation defined by a function.

A transformation defined by a function that accepts a type and returns the transformed object.

Parameters
funccallable

The transformation function. Should have a call signature func(fromdata, *args, **kwargs).

fromtypeclass

The coordinate frame class to start from.

totypeclass

The coordinate frame class to transform into.

prioritynumber

The priority if this transform when finding the shortest coordinate transform path - large numbers are lower priorities.

register_graphTransformGraph or None

A graph to register this transformation with on creation, or None to leave it unregistered.

Raises
TypeError

If func is not callable.

ValueError

If func cannot accept two arguments.

Create a data transformer.

Methods Summary

__call__(fromdata, *args[, _override_kws])

Run transformation.

Methods Documentation

__call__(fromdata, *args, _override_kws: bool = False, **kwargs)[source]

Run transformation.

Parameters
fromdataAny
*argsAny

arguments into the transformation

_override_kwsbool

whether to permit the default kwargs, or completely override by any supplied kwargs (if any are given here). If they are permitted, individual arguments are still overriden by ones supplied here.

**kwargsAny

keyword argument into the transformation

Returns
todataAny

The result of running fromdata through the transformation