bessagroup / f3dasm

Framework for Data-Driven Design & Analysis of Structures & Materials (F3DASM)
https://f3dasm.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
111 stars 29 forks source link

Improving usability by implementing helper function to convert arbitrary functions to DataGenerators #252

Closed mpvanderschelling closed 4 months ago

mpvanderschelling commented 8 months ago

Problem

Constructing a DataGenerator can be quite complex, so in order to improve the usability, it would be great if there was a way to convert the simplest of python functions (e.g. number of arbitraty arguments, number of arbitrary returns) to a DataGenerator object with a helper function:

For example:

def f(x, s):
    return x + s

... where for example x is a parametrized parameter that can be handled by ExperimentSample and s is a parameter that is always given to this function (let's say s=103).

Possible solution

The function should look something like this:

data_generator = convert_function(f=f, input=['x'], output=['y'], kwargs={'s': 103})

The returned object is a f3dasm.DataGenerator that can be used in combination with experiment_data.evaluate()