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: add neighbors #557

Merged
merged 2 commits into from
Mar 21, 2024
Merged

ENH: add neighbors #557

merged 2 commits into from
Mar 21, 2024

Conversation

martinfleis
Copy link
Member

Easy one this time. Hard to time, as cardinalities are cached.

# first run (weighted)
    # CPU times: user 49.5 ms, sys: 121 ms, total: 170 ms
    # Wall time: 179 ms
# timeit
    # 25.7 ms ± 190 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) - new
    # 549 ms ± 2.07 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) - old

Faster esp. if other function before called cardinalities.

@martinfleis martinfleis added this to the 0.8.0 milestone Mar 21, 2024
@martinfleis martinfleis requested a review from jGaboardi March 21, 2024 10:39
@@ -56,7 +56,7 @@ momepy = ["datasets/bubenec.gpkg", "datasets/tests.gpkg"]
[tool.ruff]
line-length = 88
select = ["E", "F", "W", "I", "UP", "N", "B", "A", "C4", "SIM", "ARG"]
ignore = ["B006", "F403"]
ignore = ["B006", "F403", "SIM108"]
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to avoid converting

    if weighted:
        r = graph.cardinalities / geometry.length
    else:
        r = graph.cardinalities

into an inline. I find this way more readable.

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.6%. Comparing base (4037c70) to head (46310e8).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #557     +/-   ##
=======================================
+ Coverage   97.4%   97.6%   +0.3%     
=======================================
  Files         26      30      +4     
  Lines       4328    4818    +490     
=======================================
+ Hits        4214    4704    +490     
  Misses       114     114             
Files Coverage Δ
momepy/functional/_distribution.py 100.0% <100.0%> (ø)
momepy/functional/tests/test_distribution.py 100.0% <100.0%> (ø)

@jGaboardi jGaboardi merged commit a5e30d8 into pysal:main Mar 21, 2024
13 checks passed
@martinfleis martinfleis deleted the neighbors branch March 21, 2024 13:10
@martinfleis martinfleis added enhancement New feature or request and removed refactor labels Jun 16, 2024
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.

2 participants