-
Notifications
You must be signed in to change notification settings - Fork 17
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
Split aoi dataframe by chosen criteria #879
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #879 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 74 74
Lines 3372 3374 +2
Branches 594 594
=========================================
+ Hits 3372 3374 +2 ☔ View full report in Codecov by Sentry. |
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.
I'm not sure if the Textstimulus.aois
attribute should change types.
Before calling split_aois_by()
the type is pl.DataFrame
afterwards it's a list of dataframes. It would be nice to have just one type for the aois
field.
Also, when you just split the data, you won't know the splitting criteria anymore, i.e. you won't know which dataframe is which belonging to which page.
Can you include a short code example where and how you expect the method to be used? It is probably part of a greater plan.
pytest.param( | ||
Path('tests/files/toy_text_1_1_aoi.csv'), | ||
{'separator': ','}, | ||
id='toy_text_1_1_aoi', |
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.
avoid having the same id for different test parametrizations.
you could use something like: toy_text_1_1_aoi_sep
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.
just a few things about the testing and we're ready to go!
…into aoi_events x
…into aoi_events x
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.
thanks a lot! just some more details on the tests and we're ready to merge
…into aoi_events x
…into aoi_events x
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.
Thank you @izaskr for your work!
Unfortunately I have missed a crucial line during my review two weeks ago as the split()
method doesn't return list[TextStimulus]
.
I have posted a small code snippet how to change the logic accordingly, shouldn't be much work.
This change would also need an additional test: please check that all fields (e.g. aoi_column
, width_column
, etc.) in the returned TextStimulus
splits are equal to the original TextStimulus
.
list[TextStimulus] | ||
A list of TextStimulus objects. | ||
""" | ||
return self.aois.partition_by(by=by, as_dict=False) |
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.
I must have missed this in my review two weeks ago.
this line returns a list of polars.DataFrame
not a list of TextStimulus
objects.
You should probably do something like this:
return [
TextStimulus(
aois=df,
aoi_column=self.aoi_column,
width_column=self.width_column,
..., # remaining fields
page_column=self.page_column,
)
for df in self.aois.partition_by(by=by, as_dict=False)
]
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.
@SiQube I am confused why mypy didn't complain here, as I would expect a type mismatch. I am clueless. Do you have an explanation? I am a bit worried that there's something wrong in our CI.
Description
The change introduces a splitting function for the aoi dataframe in the TextStimulus class. This allows for the aoi file to be split according to some criteria, e.g. pages.
Implemented changes
Insert a description of the changes implemented in the pull request.
Type of change
How Has This Been Tested?
test_text_stimulus_splitting
checks if the number of resulting dataframes equals the expected length.Checklist: