support msgpack checkpoint of brainunit.Quantity
#18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several enhancements and fixes to the
braintools/file/msg_checkpoint.py
file, including adding support forbrainunit
quantities, improving themsgpack_load
function, and adding a new unit test. Below are the most important changes:Enhancements to Serialization:
brainunit
quantities by defining_quantity_dict_state
and_restore_quantity
functions and registering them withregister_serialization_state
.Improvements to
msgpack_load
Function:target
parameter to themsgpack_load
function to allow restoring state directly into an object. Updated the function's docstring and theread_chunk
function to handle this new parameter. [1] [2] [3]Code Cleanup:
Imports and Module Management:
brainunit
asu
to support the new quantity serialization.Unit Testing:
TestMsgCheckpoint
inbraintools/file/msg_checkpoint_test.py
to validate themsgpack_save
andmsgpack_load
functions withbrainunit
quantities.