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

220 df index sort mgtfs #249

Merged
merged 7 commits into from
Feb 19, 2024
Merged

220 df index sort mgtfs #249

merged 7 commits into from
Feb 19, 2024

Conversation

CBROWN-ONS
Copy link
Collaborator

Description

Adds additional sorting options for mgtfs summaries

Fixes #220

Motivation and Context

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)

How Has This Been Tested?

Test configuration details:

  • OS: Windows 10
  • Python version: 3.9.13
  • Java version: N/A
  • Python management system: MiniConda

Advice for reviewer

Checklist:

  • My code follows the intended structure 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

Additional comments

Copy link
Contributor

@SergioRec SergioRec left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this @CBROWN-ONS. All seems to work as intended. There's only a couple of actions to take:

  • Unit tests for _summary_col_sorter.
  • Corrections to type hint and docstring for summarise_trips.

The rest are suggestions/clarifications or maybe misunderstandings on my part. Happy to discuss any of the points!

src/transport_performance/gtfs/multi_validation.py Outdated Show resolved Hide resolved
src/transport_performance/gtfs/multi_validation.py Outdated Show resolved Hide resolved
src/transport_performance/gtfs/multi_validation.py Outdated Show resolved Hide resolved
trip_counts = self.instances[0]._order_dataframe_by_day(trip_counts)
if sort_by == "route_type":
trip_counts = trip_counts.sort_values("route_type")
if to_days:
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that if to_days is set to True, the index after sorting will be messed up. This is nitpicking, but perhaps we could add a reset_index somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good shout. Added this

Copy link
Contributor

Choose a reason for hiding this comment

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

I've changed the reset_index to the return as this wasn't fixing the issue when to_days was True. Let me know if you're not happy with this!

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (92a8e2c) 97.71% compared to head (146fff8) 98.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #249      +/-   ##
==========================================
+ Coverage   97.71%   98.16%   +0.44%     
==========================================
  Files          21       21              
  Lines        1838     1849      +11     
==========================================
+ Hits         1796     1815      +19     
+ Misses         42       34       -8     
Flag Coverage Δ
unittests 98.16% <100.00%> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@CBROWN-ONS
Copy link
Collaborator Author

Hi @SergioRec . I've made some changes based on your comments 😄 .

Copy link
Contributor

@SergioRec SergioRec left a comment

Choose a reason for hiding this comment

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

Thanks for addressing all my comments @CBROWN-ONS.

I've made a small change to the location of the reset_index in _summarise_core. Could you please check if you're happy with it. Other than that, everything else works and this PR can be merged. Thanks!

@CBROWN-ONS
Copy link
Collaborator Author

Looks good to me @SergioRec . Happy for this to be merged

@SergioRec SergioRec merged commit bf5cabd into dev Feb 19, 2024
9 checks passed
@SergioRec SergioRec deleted the 220-df-index-sort-mgtfs branch February 19, 2024 09:50
github-actions bot pushed a commit that referenced this pull request Feb 19, 2024
* feat: sorting params for mgtfs summaries

* feat: additional tests for new sorting features

* fix: restructured param to remove unnecessary sort options

* fix: add reset index after sorting by route type

* fix: update docstring to address sorting conditions

* fix: moved reset_index to return statement

---------

Co-authored-by: Sergio Recio <[email protected]> bf5cabd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multigtfs df attribute row sort
3 participants