-
Notifications
You must be signed in to change notification settings - Fork 0
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
Series
class accepts .slp files
#79
Conversation
WalkthroughThe recent updates focus on enhancing compatibility with newer Python versions, refining the handling of series data in the Changes
Poem
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:
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.
Actionable comments posted: 2
Out of diff range and nitpick comments (2)
sleap_roots/series.py (2)
45-45
: Ensure the new attributeseries_name
is properly documented.Consider adding a brief description in the class docstring for the
series_name
attribute to explain its purpose and usage.
Line range hint
387-387
: Useisinstance()
for type checking.- if type(data_folders) != list: + if not isinstance(data_folders, list):Using
isinstance()
is more Pythonic and supports subclass checking.
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- sleap_roots/series.py (8 hunks)
Additional Context Used
Ruff (2)
sleap_roots/series.py (2)
387-387: Do not compare types, use
isinstance()
405-405: Do not compare types, use
isinstance()
Additional comments not posted (2)
sleap_roots/series.py (2)
56-57
: Updated method signature forload
to includeseries_name
.The inclusion of
series_name
as an optional parameter enhances flexibility in data handling.
396-412
: Functionfind_all_slp_series
correctly extracts unique series names from .slp files.This function enhances the software's capability to handle .slp files, aligning with the PR's objectives.
if series_name is None: | ||
if h5_path is not None: | ||
series_name = Path(h5_path).name.split(".")[0] | ||
else: | ||
raise ValueError("series_name or h5_path must be provided.") |
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.
Add error handling for both series_name
and h5_path
being None
.
- raise ValueError("series_name or h5_path must be provided.")
+ raise ValueError("Either 'series_name' or 'h5_path' must be provided.")
This change clarifies the error message, making it more informative.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if series_name is None: | |
if h5_path is not None: | |
series_name = Path(h5_path).name.split(".")[0] | |
else: | |
raise ValueError("series_name or h5_path must be provided.") | |
if series_name is None: | |
if h5_path is not None: | |
series_name = Path(h5_path).name.split(".")[0] | |
else: | |
raise ValueError("Either 'series_name' or 'h5_path' must be provided.") |
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.
Actionable comments posted: 0
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- environment.yml (1 hunks)
- pyproject.toml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- pyproject.toml
Additional comments not posted (1)
environment.yml (1)
8-8
: Update to Python 3.11 noted. Ensure compatibility of all dependencies with this Python version.
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.
Actionable comments posted: 5
Out of diff range and nitpick comments (10)
sleap_roots/__init__.py (2)
Line range hint
14-14
: Consider removing or using thesleap_roots.trait_pipelines
import as it is currently unused.
Line range hint
16-20
: The specific imports fromsleap_roots.trait_pipelines
are unused. Consider removing them or adding them to__all__
if they need to be exposed as public API.tests/test_series.py (1)
Line range hint
79-79
: The functiontest_series_name
is redefined. This could lead to unexpected behavior in testing. Consider renaming one of the functions or combining their logic if applicable.README.md (6)
Line range hint
24-24
: It seems there might be a missing closing bracket]
for the markdown link. Please check and correct if necessary.
Line range hint
141-141
: Consider adding a comma after "environment" for better readability: "activate your conda environment, which includes JupyterLab (recommended)".
Line range hint
157-157
: Remove the trailing space at the end of this line to maintain clean and consistent formatting.
Line range hint
207-207
: Remove the trailing space at the end of this line to maintain clean and consistent formatting.
Line range hint
27-27
: Multiple consecutive blank lines found. Consider reducing to a single blank line to maintain clean formatting.
Line range hint
160-160
: Multiple consecutive blank lines found. Consider reducing to a single blank line to maintain clean formatting.sleap_roots/series.py (1)
Line range hint
388-388
: Useisinstance()
for type checking instead of comparing types directly. This is more Pythonic and supports subclass checking.- if type(data_folders) != list: + if not isinstance(data_folders, list):
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- README.md (1 hunks)
- sleap_roots/init.py (1 hunks)
- sleap_roots/series.py (8 hunks)
- tests/test_series.py (4 hunks)
- tests/test_trait_pipelines.py (5 hunks)
Additional Context Used
LanguageTool (2)
README.md (2)
Near line 24: Unpaired symbol: ‘]’ seems to be missing
Context: ...ntation per pipeline is available here: [sleap-roots HackMD](https://hackmd.io/DM...
Near line 141: Possible missing comma found.
Context: ...oks`. To use them, activate your conda environment which includes JupyterLab (recommended)...
Ruff (15)
sleap_roots/__init__.py (9)
14-14:
sleap_roots.trait_pipelines
imported but unused; consider removing, adding to__all__
, or using a redundant alias
16-16:
sleap_roots.trait_pipelines.DicotPipeline
imported but unused; consider removing, adding to__all__
, or using a redundant alias
17-17:
sleap_roots.trait_pipelines.TraitDef
imported but unused; consider removing, adding to__all__
, or using a redundant alias
18-18:
sleap_roots.trait_pipelines.YoungerMonocotPipeline
imported but unused; consider removing, adding to__all__
, or using a redundant alias
19-19:
sleap_roots.trait_pipelines.OlderMonocotPipeline
imported but unused; consider removing, adding to__all__
, or using a redundant alias
20-20:
sleap_roots.trait_pipelines.MultipleDicotPipeline
imported but unused; consider removing, adding to__all__
, or using a redundant alias
22-22:
sleap_roots.series.Series
imported but unused; consider removing, adding to__all__
, or using a redundant alias
22-22:
sleap_roots.series.find_all_h5_series
imported but unused; consider removing, adding to__all__
, or using a redundant alias
22-22:
sleap_roots.series.find_all_slp_series
imported but unused; consider removing, adding to__all__
, or using a redundant aliassleap_roots/series.py (2)
388-388: Do not compare types, use
isinstance()
406-406: Do not compare types, use
isinstance()
tests/test_series.py (3)
2-2:
numpy
imported but unused
4-4:
sleap_roots.series.find_all_slp_series
imported but unused
79-79: Redefinition of unused
test_series_name
from line 60tests/test_trait_pipelines.py (1)
9-9:
sleap_roots.series.find_all_slp_series
imported but unused
@@ -19,7 +19,7 @@ | |||
OlderMonocotPipeline, | |||
MultipleDicotPipeline, | |||
) | |||
from sleap_roots.series import Series, find_all_series | |||
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series |
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.
The imports from sleap_roots.series
are unused in this file. Consider removing them or using them appropriately.
@@ -1,7 +1,7 @@ | |||
import sleap_io as sio | |||
import numpy as np |
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.
The numpy
import is unused in this file. Consider removing it unless it's needed for future tests.
@@ -1,7 +1,7 @@ | |||
import sleap_io as sio | |||
import numpy as np | |||
import pytest | |||
from sleap_roots.series import Series, find_all_series | |||
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series |
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.
The import find_all_slp_series
is unused in this file. Consider removing it to clean up the code.
@@ -6,13 +6,19 @@ | |||
OlderMonocotPipeline, | |||
MultipleDicotPipeline, | |||
) | |||
from sleap_roots.series import Series, find_all_series | |||
from sleap_roots.series import Series, find_all_h5_series, find_all_slp_series |
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.
The import find_all_slp_series
is unused in this file. Consider removing it to clean up the code.
Returns: | ||
A list of unique series names derived from the filenames. | ||
""" | ||
if type(data_folders) != list: |
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.
Use isinstance()
for type checking instead of comparing types directly. This is more Pythonic and supports subclass checking.
- if type(data_folders) != list:
+ if not isinstance(data_folders, list):
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
if type(data_folders) != list: | |
if not isinstance(data_folders, list): |
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- notebooks/Series.ipynb (1 hunks)
- sleap_roots/series.py (9 hunks)
- tests/test_series.py (4 hunks)
- tests/test_trait_pipelines.py (5 hunks)
Files not reviewed due to errors (3)
- notebooks/Series.ipynb (no review received)
- tests/test_trait_pipelines.py (no review received)
- sleap_roots/series.py (no review received)
Additional Context Used
Ruff (6)
sleap_roots/series.py (2)
388-388: Do not compare types, use
isinstance()
406-406: Do not compare types, use
isinstance()
tests/test_series.py (3)
2-2:
numpy
imported but unused
4-4:
sleap_roots.series.find_all_slp_series
imported but unused
74-74: Redefinition of unused
test_series_name
from line 60tests/test_trait_pipelines.py (1)
9-9:
sleap_roots.series.find_all_slp_series
imported but unused
Additional comments not posted (12)
tests/test_series.py (12)
12-12
: LGTM! The fixture correctly initializes aSeries
instance with dummy data.
17-17
: LGTM! The fixture correctly creates a dummy video file path.
Line range hint
25-25
: LGTM! The fixture correctly creates a dummy labels file path.
Line range hint
33-33
: LGTM! The fixture correctly creates aSeries
instance using dummy paths.
Line range hint
41-41
: LGTM! The fixture correctly creates a dummy CSV file path.
Line range hint
49-49
: LGTM! The test correctly checks theseries_name
attribute.
Line range hint
57-57
: LGTM! The test correctly checks theget_frame
method.
89-89
: LGTM! The test correctly checks theload
method with specific parameters.
97-97
: LGTM! The test correctly checks thefind_all_h5_series
function with a specific folder.
Line range hint
105-105
: LGTM! The test correctly checks theload
method with specific parameters for rice data.
Line range hint
113-113
: LGTM! The test correctly checks theget_frame
method with specific parameters for rice data.
136-136
: LGTM! The test correctly checks thefind_all_h5_series
function with a specific folder for rice data.
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- notebooks/Series.ipynb (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- notebooks/Series.ipynb
Series
class but necessary for the plotting functionseries_name
is now an attribute that uniquely identifies the sampleseries_name
can be found using theh5_path
or directly inputfind_all_slp_series
added to find uniqueseries_name
from .slp files in a list of data foldersSummary by CodeRabbit
New Features
Series
class with a new attribute for series naming and improved parameter handling in the loading method.Series.ipynb
for managing series data using thesleap_roots
package.Enhancements
Refactor
find_all_h5_series
tofind_all_slp_series
.Documentation
Bug Fixes