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

Add wload kwargs to produce_or_load #412

Conversation

NuclearPowerNerd
Copy link
Contributor

Added the ability to pass keyword arguments to wload within produce_or_load by defining a new kwarg called wload_kwargs. This works the same way as the existing functionality provided by wsave_kwargs. This is useful, for example, if you need to load a data type from file but the type definition has changed. You can pass a typemap to JLD2 that instructs it how to rebuild the object. This is not possible in the current implementation of produce_or_load because there is no way to pass kwargs to wload. This pull request makes it possible.

The default types for both wsave_kwargs and wload_kwargs are now empty named tuples. This seems like the more natural choice than an empty Dict which would only work for kwarg splatting if the keys happened to be of type Symbol. It also seems more consistent because slurping of kwargs results in a named tuple.

All tests were ran and passed with these changes.

An additional keyword argument called wload_kwargs was added to
produce_or_load. This makes it possible to pass arguments to wload. For
example, if you need to load some data type from disk but the type
definition has changed, you need to provide JLD2 a typemap to rebuild
the original object. This makes it possible to pass the typemap to wload
via produce_or_load. wload_kwargs defaults to an emtpy named tuple.

The default type wsave_kwargs was changed to an empty named tuple. This
seems like a more natural choice than as an empty Dict which would only
work with kwarg splatting if all the keys happened to be of type Symbol. Also
slurping kwargs gives a named tuple.
@Datseris Datseris merged commit ba90137 into JuliaDynamics:main Apr 10, 2024
4 checks passed
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 this pull request may close these issues.

2 participants