pysal / libpysal

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

Categorical spatial lag using the Graph #716

Closed sjsrey closed 3 months ago

sjsrey commented 4 months ago

This has two changes from the creation of categorical spatial lags using W

  1. categorical is now an option in _lag_spatial, to unify treatment of the lag.
  2. This will raise an exception in the case where categorical=True , ties=raise, and ties are encountered. "Explicit is better than implicit."
codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.0%. Comparing base (bcabdbc) to head (82147e8). Report is 18 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pysal/libpysal/pull/716/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/716?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal) ```diff @@ Coverage Diff @@ ## main #716 +/- ## ====================================== Coverage 85.0% 85.0% ====================================== Files 141 145 +4 Lines 15203 15462 +259 ====================================== + Hits 12924 13149 +225 - Misses 2279 2313 +34 ``` | [Files](https://app.codecov.io/gh/pysal/libpysal/pull/716?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/base.py](https://app.codecov.io/gh/pysal/libpysal/pull/716?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.0% <ø> (-1.0%)` | :arrow_down: | | [libpysal/graph/tests/test\_spatial\_lag.py](https://app.codecov.io/gh/pysal/libpysal/pull/716?src=pr&el=tree&filepath=libpysal%2Fgraph%2Ftests%2Ftest_spatial_lag.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal#diff-bGlicHlzYWwvZ3JhcGgvdGVzdHMvdGVzdF9zcGF0aWFsX2xhZy5weQ==) | `100.0% <100.0%> (ø)` | | | [libpysal/graph/\_spatial\_lag.py](https://app.codecov.io/gh/pysal/libpysal/pull/716?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) | `97.7% <97.4%> (-2.3%)` | :arrow_down: | ... and [10 files with indirect coverage changes](https://app.codecov.io/gh/pysal/libpysal/pull/716/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pysal)
ljwolf commented 4 months ago

What would you think about dispatching to categorical lag if the type is categorical?

I can appreciate that this might make the lag type implicit, but if someone has cast the variable to a categorical already, I think we can infer that they need the appropriate lag function?

martinfleis commented 4 months ago

@ljwolf that is what we do on l. 87, no?

martinfleis commented 3 months ago

pre-commit.ci autofix