-
Notifications
You must be signed in to change notification settings - Fork 86
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
[Feature Request] Support json read for Categorical with tuple entries. #357
Comments
Hi there, Yeah unfortunatly json doesn't keep Some updates from #346 which might be relevant:
We hope to release this sometime next week :) |
Awesome, the ability to pass a decoder that targets a particular key especially will make the process less prone to side-effects compared to using a |
Version & copy-pastable script
This works:
But a round-trip to JSON doesn't.
The stacktrace is:
In short, the json write converts the tuples to lists, but this isn't restored on the read. The CategoricalHyperparameter constructor requires that choices be hashable, and lists are not. I can thing of a few possible solutions; none would be very intensive.
cls
kwarg fromjson.{dumps,loads}
inread_and_write.json.{read,write}
so users can pass a customJSONEncoder
orJSONDecoder
, respectively. This would also allow for serialization/deserialization of other types of interest.ConfigSpace.read_and_write.json._construct_hyperparameter
to convert thelist
-typed elements ofhyperparameter[{"choices", "sequence"}]
andhyperparameter["default"]
to atuple
, if needed, for categorical and ordinal hyperparameters.The third option is the hack I'm doing for my use-case, but the second seems more robust and forward-looking. I'm filing the issue because I don't like option 1, of course :)
I can make a PR if there's interest. Cheers~
The text was updated successfully, but these errors were encountered: