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

TypeError: Expected float, got numpy.float64 when using Float #336

Open
BrunoBelucci opened this issue Jul 25, 2023 · 7 comments · May be fixed by #346
Open

TypeError: Expected float, got numpy.float64 when using Float #336

BrunoBelucci opened this issue Jul 25, 2023 · 7 comments · May be fixed by #346

Comments

@BrunoBelucci
Copy link

Hello,
It seems like that is an error when trying to use the Float function, more specifically due to the function:

def check_default(self, default_value: Optional[float]) -> float:
        if default_value is None:
            if self.log:
                default_value = np.exp((np.log(self.lower) + np.log(self.upper)) / 2.)
            else:
                default_value = (self.lower + self.upper) / 2.
        default_value = np.round(float(default_value), 10)

        if self.is_legal(default_value):
            return default_value
        else:
            raise ValueError("Illegal default value %s" % str(default_value))

inside class UniformFloatHyperparameter(FloatHyperparameter).
When calling np.round, a numpy.float64 is returned and the function is expecting a 'float'.
I am using configspace 0.7.2 and numpy 1.25

@eismont21
Copy link

Downgrade configspace to version 0.7.1. It has helped me

@eddiebergman
Copy link
Contributor

Hiyo, thanks for the note on downgrading. Turns out it seems to be an issue with a newer version of Cython and simply downgrading Cython seems to cause other issues.

We've removed 0.7.2 from PyPI for now.

@wuxf99
Copy link

wuxf99 commented Aug 23, 2023

I downgraded configspace to version 0.7.1 (pip install configspace==0.7.1) to solve this problem.

@jhj0411jhj
Copy link

This bug also appears when I use python3.11 and ConfigSpace 0.4.20, 0.4.21, 0.5.0, 0.6.0. Version 0.6.1 and 0.7.1 are fine.

@JosuaCarl
Copy link

JosuaCarl commented Apr 10, 2024

Hiyo, thanks for the note on downgrading. Turns out it seems to be an issue with a newer version of Cython and simply downgrading Cython seems to cause other issues.

We've removed 0.7.2 from PyPI for now.

The bug appeared for me in 0.7.1 (as far as mamba and pip are concerned, import ConfigSpace as cs; cs.__version__ shows 0.6.1), but I am also doing poetry shenanigans, so it could be a dependent library. Could you please elaborate, which cython version is causing the issue? I am currently on 3.0.10, but also tested with 3.0.1 to no avail.

@JosuaCarl
Copy link

Hiyo, thanks for the note on downgrading. Turns out it seems to be an issue with a newer version of Cython and simply downgrading Cython seems to cause other issues.
We've removed 0.7.2 from PyPI for now.

The bug appeared for me in 0.7.1 (as far as mamba and pip are concerned, import ConfigSpace as cs; cs.__version__ shows 0.6.1), but I am also doing poetry shenanigans, so it could be a dependent library. Could you please elaborate, which cython version is causing the issue? I am currently on 3.0.10, but also tested with 3.0.1 to no avail.

I think I found my mistake. One of the afore mentioned shenanigans was using python 3.12.2, which has no current configspace implementation. After downgrading to 3.11.8, everything ran smoothly.

@eddiebergman
Copy link
Contributor

Hi,

This will be closed by #346 which removes Cython. Hopefully we can release next week.

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.

6 participants