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

support msgpack checkpoint of brainunit.Quantity #18

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Conversation

chaoming0625
Copy link
Member

This pull request introduces several enhancements and fixes to the braintools/file/msg_checkpoint.py file, including adding support for brainunit quantities, improving the msgpack_load function, and adding a new unit test. Below are the most important changes:

Enhancements to Serialization:

  • Added support for brainunit quantities by defining _quantity_dict_state and _restore_quantity functions and registering them with register_serialization_state.

Improvements to msgpack_load Function:

  • Added an optional target parameter to the msgpack_load function to allow restoring state directly into an object. Updated the function's docstring and the read_chunk function to handle this new parameter. [1] [2] [3]

Code Cleanup:

  • Removed commented-out code related to array serialization.

Imports and Module Management:

  • Added import for brainunit as u to support the new quantity serialization.
  • Removed unnecessary blank line.

Unit Testing:

  • Added a new unit test TestMsgCheckpoint in braintools/file/msg_checkpoint_test.py to validate the msgpack_save and msgpack_load functions with brainunit quantities.

@chaoming0625 chaoming0625 merged commit 84daae7 into main Nov 15, 2024
24 checks passed
@chaoming0625 chaoming0625 deleted the update branch November 15, 2024 14:03
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.

1 participant