Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GuillaumeBroggi opened this issue Jun 13, 2024 · 2 comments

Comments

@GuillaumeBroggi
Copy link
Contributor

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.

@mpvanderschelling
Copy link
Collaborator

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

@GuillaumeBroggi
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants