-
Notifications
You must be signed in to change notification settings - Fork 645
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
make flax.core.copy add_or_replace
optional
#3241
Conversation
ignore .envrc (direnv files) format add test fix
flax/core/frozen_dict.py
Outdated
if add_or_replace is not None: | ||
new_dict.update(add_or_replace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if add_or_replace is not None: | |
new_dict.update(add_or_replace) | |
if isinstance(add_or_replace, dict): | |
add_or_replace = jax.tree_map(lambda x: x, add_or_replace) | |
new_dict.update(add_or_replace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the logic here.
Using your MappingProxy idea, I can just remove this change, and wouldn't need to touch those lines.
Thanks @PhilipVinc! Added some suggestions. cc @chiamp |
Co-authored-by: Cristian Garcia <cgarcia.e88@gmail.com>
thanks @cgarciae . I implemented your suggestions except for the one above where I just removed by edits. Let me know if this looks good for you. |
This looks great, thanks @PhilipVinc! |
It makes the API easier to use when you just want to have a copy of a dictionary.