Public Member Functions | |
def | __init__ (self, name, aliases=(), defaults=None) |
def | from_context (cls, context, **defaults) |
def | from_lines (cls, lines, to_base_func=None) |
def | add_transformation (self, src, dst, func) |
def | remove_transformation (self, src, dst) |
def | transform (self, src, dst, registry, value) |
Static Public Member Functions | |
def | __keytransform__ (src, dst) |
Public Attributes | |
name | |
aliases | |
funcs | |
defaults | |
relation_to_context | |
A specialized container that defines transformation functions from one dimension to another. Each Dimension are specified using a UnitsContainer. Simple transformation are given with a function taking a single parameter. >>> timedim = UnitsContainer({'[time]': 1}) >>> spacedim = UnitsContainer({'[length]': 1}) >>> def f(time): ... 'Time to length converter' ... return 3. * time >>> c = Context() >>> c.add_transformation(timedim, spacedim, f) >>> c.transform(timedim, spacedim, 2) 6 Conversion functions may take optional keyword arguments and the context can have default values for these arguments. >>> def f(time, n): ... 'Time to length converter, n is the index of refraction of the material' ... return 3. * time / n >>> c = Context(n=3) >>> c.add_transformation(timedim, spacedim, f) >>> c.transform(timedim, spacedim, 2) 2
def SUAVE.Plugins.pint.context.Context.add_transformation | ( | self, | |
src, | |||
dst, | |||
func | |||
) |
Add a transformation function to the context.
def SUAVE.Plugins.pint.context.Context.from_context | ( | cls, | |
context, | |||
** | defaults | ||
) |
Creates a new context that shares the funcs dictionary with the original context. The default values are copied from the original context and updated with the new defaults. If defaults is empty, return the same context.
def SUAVE.Plugins.pint.context.Context.remove_transformation | ( | self, | |
src, | |||
dst | |||
) |
Add a transformation function to the context.
def SUAVE.Plugins.pint.context.Context.transform | ( | self, | |
src, | |||
dst, | |||
registry, | |||
value | |||
) |
Transform a value.