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

ValueError by passing an int instead of a float #528

Closed
mdelozzo opened this issue Mar 6, 2024 · 3 comments
Closed

ValueError by passing an int instead of a float #528

mdelozzo opened this issue Mar 6, 2024 · 3 comments

Comments

@mdelozzo
Copy link

mdelozzo commented Mar 6, 2024

Hi,

I got a ValueError when evaluating a SurrogateModel with an integer (long) instead of a float (double):

ValueError: Buffer dtype mismatch, expected 'double' but got 'long'

Here is the reproducer:

from numpy import array
from numpy import linspace
from smt.surrogate_models import RBF

input_data = linspace(-1, 1, 10)
output_data = input_data**2

smt_model = RBF()
smt_model.set_training_values(input_data, output_data)
smt_model.train()

smt_model.predict_values(array([1])) # KO
# smt_model.predict_values(array([1.0]))  # OK

Is this normal or a bug? If it's normal, what's the explanation for this?

Thank you in advance for your reply,

Best,

Matthias

@relf
Copy link
Member

relf commented Mar 6, 2024

Hi Matthias. I would say it is normal. Historically, SMT only handles numpy arrays of floats.

@mdelozzo
Copy link
Author

mdelozzo commented Mar 6, 2024

Hi Rémi,
Thanks for your quick reply.
The error message surprised me a little and the notion of buffer was not obvious (I was expecting to read input value or something like that). I'm creating a wrapper of SurrogateModel and I think I will force the conversion to float to avoid any problems.
As it is the expected SMT behavior, I close this issue.

@mdelozzo mdelozzo closed this as completed Mar 6, 2024
@relf
Copy link
Member

relf commented Mar 7, 2024

FYI, actually RBF is written in C++ and cythonized which explains the "weird" error message.

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

No branches or pull requests

2 participants