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

refactor: speed up grouping operation #357

Merged
merged 3 commits into from
Sep 5, 2023

Conversation

RaczeQ
Copy link
Collaborator

@RaczeQ RaczeQ commented Sep 3, 2023

No description provided.

@RaczeQ RaczeQ linked an issue Sep 3, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Sep 3, 2023

Codecov Report

Patch coverage: 95.65% and project coverage change: -0.16% ⚠️

Comparison is base (48c6c67) 91.74% compared to head (99b82bf) 91.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #357      +/-   ##
==========================================
- Coverage   91.74%   91.58%   -0.16%     
==========================================
  Files          60       60              
  Lines        2083     2092       +9     
==========================================
+ Hits         1911     1916       +5     
- Misses        172      176       +4     
Flag Coverage Δ
macos-latest-python3.11 91.58% <95.65%> (-0.16%) ⬇️
ubuntu-latest-python3.10 91.58% <95.65%> (+0.13%) ⬆️
ubuntu-latest-python3.11 91.58% <95.65%> (-0.16%) ⬇️
ubuntu-latest-python3.8 91.52% <95.65%> (-0.21%) ⬇️
ubuntu-latest-python3.9 91.52% <95.65%> (-0.21%) ⬇️

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

Files Changed Coverage Δ
srai/loaders/osm_loaders/_base.py 96.29% <95.65%> (-1.49%) ⬇️

... and 1 file with indirect coverage changes

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

@RaczeQ
Copy link
Collaborator Author

RaczeQ commented Sep 5, 2023

Refactored OSMLoader's internal function _group_features_gdf that parsed flat OsmTagsFilter back into GroupedOsmTagsFilter.

The previous version worked directly in a for loop and was slowing down significantly with a higher number of rows in the data frame.

The current version works on whole groups at once (scales linearly with number of groups in filter) and utilizes boolean filter masks and pandas's apply function to work on all rows that match given group in the filter.

@RaczeQ RaczeQ merged commit 1baeecf into main Sep 5, 2023
9 checks passed
@RaczeQ RaczeQ deleted the 354-improve-osmfilter-grouping-speed branch September 5, 2023 16:48
@RaczeQ RaczeQ restored the 354-improve-osmfilter-grouping-speed branch September 7, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve OsmFilter grouping speed
1 participant