f3dasm icon indicating copy to clipboard operation
f3dasm copied to clipboard

Evaluating experimental data with a function whose signature does not strictly match the input variables will raise an error

Open GuillaumeBroggi opened this issue 1 year ago • 2 comments

For instance, replicating the own data generator example will raise TypeError: cannot unpack non-iterable NoneType object.

import numpy as np
from scipy.stats import norm

from f3dasm import ExperimentData
from f3dasm.datageneration import DataGenerator
from f3dasm.design import Domain

def y(seed):
    z = norm.rvs(1.5, 0.5, size=1)
    y = z*seed + 0.1*seed**2
    return y

domain = Domain()
domain.add_float('x', low=0., high=100.)
domain.add_float('z', low=0., high=100.)

N = 33  # number of points to generate
Data_x = np.linspace(3, 83, 100)

experiment_data = ExperimentData(input_data=Data_x, domain=domain)

experiment_data.evaluate(data_generator=y, output_names=['y'])

The only change is the addition of the variable z to the input space.

Likewise, modifying the variable name will raise the same error.

import numpy as np
from scipy.stats import norm

from f3dasm import ExperimentData
from f3dasm.datageneration import DataGenerator
from f3dasm.design import Domain

def y(seed):
    z = norm.rvs(1.5, 0.5, size=1)
    y = z*seed + 0.1*seed**2
    return y

domain = Domain()
domain.add_float('xx', low=0., high=100.)

N = 33  # number of points to generate
Data_x = np.linspace(3, 83, 100)

experiment_data = ExperimentData(input_data=Data_x, domain=domain)

experiment_data.evaluate(data_generator=y, output_names=['y'])

If this behavior is intentional, it is not documented. Raising an explicit error might also help.

GuillaumeBroggi avatar Jun 13 '24 19:06 GuillaumeBroggi

Hey Guillaume,

If I understand it correctly, it is not documented that the input arguments of the user-defined data generator function need to correspond to the input domain parameters described in the Domain object

mpvanderschelling avatar Jun 20 '24 08:06 mpvanderschelling

Hi Martin,

Exactly. I don't know if this behavior is intended or should be reworked for more flexibility, but documenting it explicitly will help new users.

GuillaumeBroggi avatar Jun 20 '24 15:06 GuillaumeBroggi