pymor.functions package¶
Submodules¶
basic module¶
-
class
pymor.functions.basic.ConstantFunction(value=array(1.), dim_domain=1, name=None)[source]¶ Bases:
pymor.functions.basic.FunctionBaseA constant
Functionf: R^d -> R^shape(c), f(x) = c
Parameters
- value
The constant c.
- dim_domain
The dimension d.
- name
The name of the function.
Attributes
-
class
pymor.functions.basic.ExpressionFunction(expression, dim_domain=1, shape_range=(), parameter_type=None, values=None, name=None)[source]¶ Bases:
pymor.functions.basic.GenericFunctionTurns a Python expression given as a string into a
Function.Some
NumPyarithmetic functions like ‘sin’, ‘log’, ‘min’ are supported. For a full list see thefunctionsclass attribute.Warning
evalis used to evaluate the given expression. Using this class with expression strings from untrusted sources will cause mayhem and destruction!Parameters
- expression
A Python expression of one variable
xand a parametermugiven as a string.- dim_domain
The dimension of the domain.
- shape_range
The shape of the values returned by the expression.
- parameter_type
The
ParameterTypethe expression accepts.- values
Dictionary of additional constants that can be used in
expressionwith their corresponding value.- name
The name of the function.
Attributes
functions
-
class
pymor.functions.basic.FunctionBase[source]¶ Bases:
pymor.functions.interfaces.FunctionInterfaceBase class for
Functionsproviding some common functionality.
-
class
pymor.functions.basic.GenericFunction(mapping, dim_domain=1, shape_range=(), parameter_type=None, name=None)[source]¶ Bases:
pymor.functions.basic.FunctionBaseWrapper making an arbitrary Python function between
NumPy arraysa properFunction.Note that a
GenericFunctioncan only bepickledif the function it is wrapping can be pickled (cf.dumps_function). For this reason, it is usually preferable to useExpressionFunctioninstead ofGenericFunction.Parameters
- mapping
The function to wrap. If
parameter_typeisNone, the function is of the formmapping(x). Ifparameter_typeis notNone, the function has to have the signaturemapping(x, mu). Moreover, the function is expected to be vectorized, i.e.:mapping(x).shape == x.shape[:-1] + shape_range.
- dim_domain
The dimension of the domain.
- shape_range
The shape of the values returned by the mapping.
- parameter_type
The
ParameterTypethe mapping accepts.- name
The name of the function.
Attributes
-
class
pymor.functions.basic.LincombFunction(functions, coefficients, name=None)[source]¶ Bases:
pymor.functions.basic.FunctionBaseA
Functionrepresenting a linear combination ofFunctions.The linear coefficients can be provided either as scalars or as
ParameterFunctionals.Parameters
- functions
List of
Functionswhose linear combination is formed.- coefficients
A list of linear coefficients. A linear coefficient can either be a fixed number or a
ParameterFunctional.- name
Name of the function.
Attributes
-
functions¶
-
coefficients¶
bitmap module¶
-
class
pymor.functions.bitmap.BitmapFunction(filename, bounding_box=None, range=None)[source]¶ Bases:
pymor.functions.basic.FunctionBaseDefine a 2D
Functionvia a grayscale image.Parameters
- filename
Path of the image representing the function.
- bounding_box
Lower left and upper right coordinates of the domain of the function.
- range
A pixel of value p is mapped to
(p / 255.) * range[1] + range[0].
Attributes
interfaces module¶
-
class
pymor.functions.interfaces.FunctionInterface[source]¶ Bases:
pymor.core.interfaces.ImmutableInterface,pymor.parameters.base.ParametricInterface for
Parameterdependent analytical functions.Every
Functionis a map of the formf(μ): Ω ⊆ R^d -> R^(shape_range)
The returned values are
NumPy arraysof arbitrary (but fixed) shape. Note that NumPy distinguishes between one-dimensional arrays of length 1 (with shape(1,)) and zero-dimensional scalar arrays (with shape()). In pyMOR, we usually expect scalar-valued functions to haveshape_range == ().While the function might raise an error if it is evaluated for an argument not in the domain Ω, the exact behavior is left undefined.
Functions are vectorized in the sense, that if
x.ndim == k, thenf(x, μ)[i0, i1, ..., i(k-2)] == f(x[i0, i1, ..., i(k-2)], μ).
In particular,
f(x, μ).shape == x.shape[:-1] + shape_range.Attributes
-
dim_domain¶ The dimension d > 0.
-
shape_range¶ The shape of the function values.
-