pysal / libpysal

Core components of Python Spatial Analysis Library
http://pysal.org/libpysal
Other
249 stars 79 forks source link

REF: minor performance improvements in Graph #697

Closed martinfleis closed 2 months ago

martinfleis commented 3 months ago

Follow up on #691 and conversion to neighbors and weights dicts as discussed there.

I am also changing the sparse format to CSR which is what we need for lag and generally anything else and what weights is using. That also allows cleaner implementation of _components.

Plus using matrix_power implementation for scipy sparse array (courtesy of @ljwolf) which allows us to skip conversion to sparse matrix.

Note that the change of the sparse representation is technically a hard-breaking change but given we're in experimental phase we can afford it.

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 96.55172% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 85.0%. Comparing base (bcabdbc) to head (438cf5f). Report is 3 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pysal/libpysal/pull/697/graphs/tree.svg?width=650&height=150&src=pr&token=wgnkG5Rj0J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal)](https://app.codecov.io/gh/pysal/libpysal/pull/697?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal) ```diff @@ Coverage Diff @@ ## main #697 +/- ## ======================================= - Coverage 85.0% 85.0% -0.0% ======================================= Files 141 141 Lines 15203 15223 +20 ======================================= + Hits 12924 12941 +17 - Misses 2279 2282 +3 ``` | [Files](https://app.codecov.io/gh/pysal/libpysal/pull/697?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal) | Coverage Δ | | |---|---|---| | [libpysal/graph/\_spatial\_lag.py](https://app.codecov.io/gh/pysal/libpysal/pull/697?src=pr&el=tree&filepath=libpysal%2Fgraph%2F_spatial_lag.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bGlicHlzYWwvZ3JhcGgvX3NwYXRpYWxfbGFnLnB5) | `100.0% <100.0%> (ø)` | | | [libpysal/graph/tests/test\_base.py](https://app.codecov.io/gh/pysal/libpysal/pull/697?src=pr&el=tree&filepath=libpysal%2Fgraph%2Ftests%2Ftest_base.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bGlicHlzYWwvZ3JhcGgvdGVzdHMvdGVzdF9iYXNlLnB5) | `100.0% <100.0%> (ø)` | | | [libpysal/graph/base.py](https://app.codecov.io/gh/pysal/libpysal/pull/697?src=pr&el=tree&filepath=libpysal%2Fgraph%2Fbase.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bGlicHlzYWwvZ3JhcGgvYmFzZS5weQ==) | `97.7% <96.0%> (-0.2%)` | :arrow_down: |