pysal / momepy

Urban Morphology Measuring Toolkit
https://docs.momepy.org
BSD 3-Clause "New" or "Revised" License
496 stars 59 forks source link

Faster node density #609

Closed u3ks closed 5 months ago

u3ks commented 5 months ago

I moved the node density functionality to the graph module and use networkx to compute it. The current implementation scales horribly and on larger graphs takes hours, since all edges have to be filtered multiple times with np.in1d. Getting the exact timing is a bit messy since subgraphs and higher order pysal have to be precomuted and affect the time. The new implementation takes around <20ish mintues on a graph with ~500k nodes and 2mil edges, together with the other mm.subgraph computations. For smaller datasets the current implementation + calculating a higher order graph ~ the new networkx implementation.

codecov[bot] commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.0%. Comparing base (4037c70) to head (9ed20b3). Report is 85 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pysal/momepy/pull/609/graphs/tree.svg?width=650&height=150&src=pr&token=VNn0WR5JWT&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal)](https://app.codecov.io/gh/pysal/momepy/pull/609?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal) ```diff @@ Coverage Diff @@ ## main #609 +/- ## ======================================= + Coverage 97.4% 98.0% +0.6% ======================================= Files 26 37 +11 Lines 4328 6079 +1751 ======================================= + Hits 4214 5957 +1743 - Misses 114 122 +8 ``` | [Files with missing lines](https://app.codecov.io/gh/pysal/momepy/pull/609?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal) | Coverage Δ | | |---|---|---| | [momepy/functional/\_intensity.py](https://app.codecov.io/gh/pysal/momepy/pull/609?src=pr&el=tree&filepath=momepy%2Ffunctional%2F_intensity.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bW9tZXB5L2Z1bmN0aW9uYWwvX2ludGVuc2l0eS5weQ==) | `100.0% <100.0%> (ø)` | | | [momepy/functional/tests/test\_intensity.py](https://app.codecov.io/gh/pysal/momepy/pull/609?src=pr&el=tree&filepath=momepy%2Ffunctional%2Ftests%2Ftest_intensity.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bW9tZXB5L2Z1bmN0aW9uYWwvdGVzdHMvdGVzdF9pbnRlbnNpdHkucHk=) | `100.0% <100.0%> (ø)` | | | [momepy/graph.py](https://app.codecov.io/gh/pysal/momepy/pull/609?src=pr&el=tree&filepath=momepy%2Fgraph.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bW9tZXB5L2dyYXBoLnB5) | `98.9% <100.0%> (+0.1%)` | :arrow_up: |
martinfleis commented 5 months ago

One more thing, can you update API docs? Removing the old one and adding the new to the proper section.