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

REF: functional implementation of shape module #550

Merged
merged 12 commits into from
Feb 9, 2024

Conversation

martinfleis
Copy link
Member

@martinfleis martinfleis commented Feb 8, 2024

Completely refactored shape.py. This was probably the easiest of them all.

Performance comparison on data covering whole Prague:

old (s) new (s) comparison
form_factor 0.0177744 0.0144857 0.814978
fractal_dimension 0.011218 0.00919267 0.81946
facade_ratio 0.010366 0.00798157 0.769973
circular_compactness 3.75679 1.46005 0.388644
square_compactness 0.0107254 0.0082286 0.767205
convexity 0.491798 0.496109 1.00876
courtyard_index 0.141855 0.141236 0.99564
rectangularity 0.73733 0.738049 1.00097
shape_index 1.51152 1.50104 0.993067
corners 13.3684 4.04417 0.302518
squareness 13.595 5.92453 0.435787
equivalent_rectangular_index 0.872975 0.751531 0.860885
elongation 0.867414 0.735372 0.847775
centroid_corner_distance 31.7199 21.2256 0.669158
linearity 0.356025 0.0215537 0.0605398
compactness_weighted_axis 4.12308 1.68417 0.408473

Total speedup, to run all on a single city is 0.54, so we are now nearly twice as fast to compute the same.

@jGaboardi I am aware it is a loooong PR so can split it if you prefer that, but there's a ton of repetition in docstrings and tests so it is not that much.

I am also quite happy how the code looks compared to the original shape.py.

@martinfleis martinfleis changed the title Shape REF: functional implementation of shape module Feb 8, 2024
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4037c70) 97.4% compared to head (176b4b2) 97.5%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #550     +/-   ##
=======================================
+ Coverage   97.4%   97.5%   +0.2%     
=======================================
  Files         26      28      +2     
  Lines       4328    4633    +305     
=======================================
+ Hits        4214    4519    +305     
  Misses       114     114             
Files Coverage Δ
momepy/__init__.py 100.0% <100.0%> (ø)
momepy/functional/_dimension.py 100.0% <100.0%> (ø)
momepy/functional/_shape.py 100.0% <100.0%> (ø)
momepy/functional/tests/test_shape.py 100.0% <100.0%> (ø)

@martinfleis martinfleis marked this pull request as ready for review February 8, 2024 21:46
@martinfleis martinfleis self-assigned this Feb 8, 2024
@martinfleis martinfleis added enhancement New feature or request refactor labels Feb 8, 2024
@martinfleis martinfleis added this to the 0.8.0 milestone Feb 8, 2024
@jGaboardi
Copy link
Member

Total speedup, to run all on a single city is 0.54, so we are now nearly twice as fast to compute the same.

Amazing. Very cool work.

@jGaboardi I am aware it is a loooong PR so can split it if you prefer that, but there's a ton of repetition in docstrings and tests so it is not that much.

No need to split. I will hunker down and get it down.

Copy link
Member

@jGaboardi jGaboardi 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 couple small comments. Otherwise, v nice.

momepy/__init__.py Show resolved Hide resolved
momepy/functional/_shape.py Outdated Show resolved Hide resolved
Co-authored-by: James Gaboardi <jgaboardi@gmail.com>
@martinfleis martinfleis merged commit 2cb1b38 into pysal:main Feb 9, 2024
13 checks passed
@martinfleis martinfleis deleted the shape branch February 9, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants