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

ENH: rework geogr module #537

Merged
merged 1 commit into from
Sep 23, 2023
Merged

Conversation

bifbof
Copy link
Collaborator

@bifbof bifbof commented Sep 22, 2023

I had the following problem:
I wanted to import Positionfixes into the file distances.py to use the class there.
But this created a circular import, positionfixes.py imports util.py which imports distances.py which now newly imports positionfixes.py, and with that python gave up.
To fix this I moved all the speed calculations out of util.py into distances.py, thus util.py does not have to import distances.py anymore. Further I have reworked the geogr module a bit.
What is part of this PR:

  • moved get_speed_positionfixes and get_speed_triplegs to geogr/distances.py
  • moved haversine_dist to geogr/distances.py and renamed to point_haversine_dist to make clear that is still about points, even without the ti.geogr.point_distance.haversine_dist path.
  • reimported all distance functions to ti.geogr such that we now can use ti.geogr.check_gdf vs. ti.geogr.distances.check_gdf.

@bifbof
Copy link
Collaborator Author

bifbof commented Sep 22, 2023

I am sorry for these big PR. Normally I keep them under 400 LOC, on the other hand this PR only moves code around, I've not written any additional code.

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (93ad546) 93.35% compared to head (d37720c) 93.35%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #537   +/-   ##
=======================================
  Coverage   93.35%   93.35%           
=======================================
  Files          33       32    -1     
  Lines        2136     2136           
  Branches      410      410           
=======================================
  Hits         1994     1994           
  Misses        129      129           
  Partials       13       13           
Files Changed Coverage Δ
trackintel/model/util.py 100.00% <ø> (ø)
trackintel/preprocessing/staypoints.py 99.08% <ø> (ø)
trackintel/analysis/labelling.py 96.77% <100.00%> (ø)
trackintel/geogr/__init__.py 100.00% <100.00%> (ø)
trackintel/geogr/distances.py 96.66% <100.00%> (+2.16%) ⬆️
trackintel/model/positionfixes.py 100.00% <100.00%> (ø)
trackintel/model/triplegs.py 100.00% <100.00%> (ø)
trackintel/preprocessing/positionfixes.py 98.80% <100.00%> (ø)
trackintel/preprocessing/trips.py 97.50% <100.00%> (ø)

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

Copy link
Member

@hongyeehh hongyeehh 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 the rearrangement; this makes the code more structured, especially moving the speed calculation to geogr.

@hongyeehh hongyeehh merged commit 9dd980e into mie-lab:master Sep 23, 2023
7 checks passed
@bifbof bifbof deleted the move_speed_calculations branch September 23, 2023 20:38
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.

2 participants