-
Notifications
You must be signed in to change notification settings - Fork 97
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 loading slp files with non-compound types and str in metadata #1566
Conversation
WalkthroughThe changes primarily focus on enhancing data handling in the HDF5 format. They introduce checks for data types, conversion of JSON attributes, and casting of arrays into complex data types. The modifications ensure robustness and consistency in data processing. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit's AI:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (1)
- sleap/io/format/hdf5.py (3 hunks)
Additional comments: 4
sleap/io/format/hdf5.py (4)
84-87: The new code checks if the
json
attribute is a string before decoding it. This is a good practice as it prevents potential errors that could occur if the attribute is already a string. This change is backward compatible and should not affect the functionality of the code.157-163: The
cast_as_compound
function is a new addition that casts an array into a complex data type. This function is used later in the code to cast points, instances, and frames into complex data types if they are not already. This change enhances the robustness of the loading process by allowing these arrays to be stored as non-compound types in the h5 file.166-194: The new code uses the
cast_as_compound
function to cast points, instances, and frames into complex data types if they are not already. This change enhances the robustness of the loading process by allowing these arrays to be stored as non-compound types in the h5 file. However, it's important to ensure that the casting process does not alter the data in a way that could affect the functionality of the code.328-331: Similar to the change in lines 84-87, the new code checks if the
json
attribute is a string before decoding it. This is a good practice as it prevents potential errors that could occur if the attribute is already a string. This change is backward compatible and should not affect the functionality of the code.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #1566 +/- ##
===========================================
- Coverage 73.38% 73.36% -0.02%
===========================================
Files 134 134
Lines 24024 24048 +24
===========================================
+ Hits 17629 17643 +14
- Misses 6395 6405 +10 ☔ View full report in Codecov by Sentry. |
@roomrys @talmo Any chance you could merge this? This would allow people to export slp datasets from a web annotation system (such as https://lambdaloop.com/anivia/ ) and then load them into SLEAP. |
Description
This makes the loading of slp files more robust. Specifically, it allows storing points, pred_points, frames, and instances as non-compound types in the h5 file, by casting them as needed.
It is backwards compatible with the previous code, so that the default slp files load fine.
Types of changes
Does this address any currently open issues?
[list open issues here]
Outside contributors checklist
Thank you for contributing to SLEAP!
❤️
Summary by CodeRabbit