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

feat: split TextStimulus by column values #879

Merged
merged 21 commits into from
Jan 8, 2025
Merged

feat: split TextStimulus by column values #879

merged 21 commits into from
Jan 8, 2025

Conversation

izaskr
Copy link
Collaborator

@izaskr izaskr commented Oct 24, 2024

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.

  • Add a method to split the aoi dataframe by some criteria into a list of dataframes.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change is or requires a documentation update

How Has This Been Tested?

  • Test test_text_stimulus_splitting checks if the number of resulting dataframes equals the expected length.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (29b806d) to head (bfafab9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #879   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           74        74           
  Lines         3419      3422    +3     
  Branches       613       613           
=========================================
+ Hits          3419      3422    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@dkrako dkrako left a 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.

tests/unit/stimulus/text_test.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dkrako dkrako left a 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!

tests/unit/stimulus/text_test.py Show resolved Hide resolved
Copy link
Contributor

@dkrako dkrako left a 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

tests/unit/stimulus/text_test.py Outdated Show resolved Hide resolved
tests/unit/stimulus/text_test.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dkrako dkrako left a 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.

src/pymovements/stimulus/text.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dkrako dkrako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, finally we got there! Thank you so much @izaskr and @SiQube for your work!

@dkrako dkrako changed the title Split aoi dataframe by chosen criteria feat: split TextStimulus by column values Jan 8, 2025
@dkrako dkrako merged commit a0ce2e1 into main Jan 8, 2025
24 checks passed
@dkrako dkrako deleted the aoi_events branch January 8, 2025 12:23
@dkrako dkrako added the enhancement New feature or request label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants