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

Value 'float64' is not a supported primitive type #805

Closed
joamatab opened this issue Oct 14, 2021 · 2 comments
Closed

Value 'float64' is not a supported primitive type #805

joamatab opened this issue Oct 14, 2021 · 2 comments
Labels
question Request for help, not a bug or feature request

Comments

@joamatab
Copy link

What is the best work around for supporting float64 objects?


import numpy as np
from omegaconf import OmegaConf

d = OmegaConf.create(dict(a=np.float64(3.2)))
d

raises

Value 'float64' is not a supported primitive type  
@joamatab joamatab added the bug Something isn't working label Oct 14, 2021
@pixelb
Copy link
Collaborator

pixelb commented Oct 14, 2021

Well float64 and python float are c doubles underneath, so one should not lose info by converting to/from python floats, like:

d = OmegaConf.create(dict(a=np.float64(3.2).item()))

Alternatively if you didn't mind conversion overhead but wanted a non lossy intermediate string representation, one could use hex float strings like:

d = OmegaConf.create(dict(a=np.float64(3.2).hex()))

@omry omry added question Request for help, not a bug or feature request and removed bug Something isn't working labels Oct 15, 2021
@omry
Copy link
Owner

omry commented Oct 15, 2021

np.floats are not supported by OmegaConf. as @pixelb pointed out you have to convert them to a python float.

There is a feature request to attempt supporting them by casting them to float (#725).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Request for help, not a bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants