Conversation
* Assume data from LitPop is gridded when determining region IDs. * Add option to pass 'region_id' parameter to LitPop.from_shape.
* Avoid copying data by using np.asarray. * Streamline computations by relying on numpy broadcasting.
|
Looks all very reasonable! Any estimates of the gained computation time? Also, changelog needs to be updated. Maybe also the documentation to point people towards how to use custom shapes correctly. |
I was afraid you would ask that 😬 I can come up with some benchmarks tomorrow. The most important improvement is from using So, tldr: |
Not sure what you mean by that. How are people using it "incorrectly" in your perspective? |
Sorry for being unclear. I was referring to the original issue which was about how to use arbitrary shapes with LitPop. This functionality was clearly not obvious, so a documentation entry could help. |
|
Ah, sorry, you were referring to #715. I'll see what I can do. |
* Rename return value in local function. * Remove named argument call in `LitPop.from_shape`. * Improve `region_id` parameter documentation.
I moved the Issue to Discussions/Q&A and marked my workaround as answer, see #723 |
Small improvements, but certainly useful! In particular since |
| Returns | ||
| ------- | ||
| result_array : np.array of same shape as arrays in data_arrays | ||
| result : np.array of same shape as arrays in data_arrays |
There was a problem hiding this comment.
This is really nitpicking, but result is a terrible variable name ^^.
There was a problem hiding this comment.
True, but result_array was even worse. Do you have something better? The name can also be omitted here:
| result : np.array of same shape as arrays in data_arrays | |
| np.array of same shape as arrays in data_arrays |
There was a problem hiding this comment.
Well, the variable name still would be there. Maybe convoluted_array since this is essentially doing a convolution? Or rescaled_product ?
There was a problem hiding this comment.
How about leaving out the result variable and storing everything in the data variable? I think that the new variable definition actually is not needed.
There was a problem hiding this comment.
Also fine. Although data is not a better name than result.
There was a problem hiding this comment.
Then I'll do that. My goal is not to refactor this function 😅
Yes, I think I mixed something up. The major improvement was upgrading to shapely v2.0 on my side. |
|
@chahank Ready to merge from my side! |




Changes proposed in this PR:
LitPopby assuming the data is gridded (it is)gridpoints_core_calcto use numpy array tools and broadcasting, and avoid copying arraysLitPop.from_shape. This avoids country-code detection.PR Author Checklist
develop)PR Reviewer Checklist