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
[WIP]: Optimized raster-based weights builder #343
Conversation
Codecov Report
@@ Coverage Diff @@
## master #343 +/- ##
========================================
+ Coverage 80.3% 80.9% +0.7%
========================================
Files 117 117
Lines 12163 12044 -119
========================================
- Hits 9765 9748 -17
+ Misses 2398 2296 -102
|
I can see the logic of offering the option for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there!!! Mostly issues of documentation and style, the only more substantive bit is to ensure the id_order
of the weights we build is relatable to the DataArray
514d1cd
to
36edb9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple minor bits to add, only docs and tests and I think this is good to ship!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MgeeeeK this looks great and I think we are super close to merging. The only thing remaining is to test a couple more lines. I resolved all of @darribas comments that where addressed and looked great. There are a couple minor comments still standing that slipped through the radar and are still open (even if marked outdated). Once these are added I am happy to get this merged. Thank you so much for your hard work this and last year!
Fixed formating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've resolved a couple of the standing threads, they look good. I'm not sure test_da2WSP
is being fully tested. I can see rook
and queen
are now both tested, but it's always in the multi-core context. Is it a different bit of code that runs it on single core? If not, it's fine, but if it is, we should test that too.
No, multi-thread is extension of the base constructor but still I'll add another test comparing results of multi-threaded and single-threaded builder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this merged then! :)
This pull request adds a new optimized weight builder for the raster interface.
Main takeaway:
threading
backend.higher_order
neighbors, this is done using 2 ways:k=int
andinclude_nas=boolean
).k
is used for specifying the kth order andinclude_nas=True
is used for including higher-order neighbors even if lower-order neighbors are missing.higher_order
functionality is based on the suggestion provided by Martin in this issue libpysal/#issue313. This also adds diagonal elements that are first converted to zero and then these zero elements are removed in the last step. But this changes the sparsity of the matrix!.include_nas
isTrue
then the method simply uses modular arithmetic to add higher-order neighbors. (with one caveat explained earlier and in this thread libpysal/#328)Here is the plot showing difference between two approaches.