Add macro and functions for named tuple updates#440
Add macro and functions for named tuple updates#440aquaresima wants to merge 7 commits intoJuliaDynamics:mainfrom
Conversation
This file introduces a macro for updating named tuples and a deep merge function to handle nested updates. It also includes a pretty print function for displaying named tuples.
|
Before merging, if you are interested anyway, one should decide whether to maintain or not the warning for the creation/deletion of fields. Currently, creating a nested field that was not previously there or replacing a field with a value using a named tuple generates a warning. In the context of the example I get: However, I am uncertain about the practicality of this feature within the library's broader context. Because the user is modifying the named tuples "in batch", this framework is as useful as prone to errors. Thus, the warnings are convenient to avoid making the most common mistake:
Tho, this can be done on purpose, and in that case, having the warning at run-time can be pretty annoying. |
|
Hi there, thanks for the contribution! I agree that this is generally useful functionality, however it is probably a better fit for https://github.com/JeffreySarnoff/NamedTupleTools.jl . There is some functionality overlap there as well. Can you try to add it as a contribution there? |
Hello,
This file introduces a macro for updating named tuples and a deep merge function to handle nested updates. It also includes a pretty print function for displaying named tuples.
I wrote this macro for my personal use, but because I use DrWatson in all my scientific projects, and I believe that this is a valuable tool for anyone working with nested tuples, I think it would be nice to have it here! I added tests and a an example case (in the test file) that you can add in the doc.
The idea is to use it to update experiment configurations within loops:
It works like this:
There is also an in-place
@update!version