Repository navigation
Conversation
* re-apply CLIMADA-project#1350 vectorizations for Impact.impact_at_reg and points_to_raster * fix Impact.impact_at_reg row indexing when len(agg_regions) < n_exp (CLIMADA-project#1357)
napattan
requested review from
chahank,
emanuel-schmid and
peanutfun
as code owners
November 20, 2026 13:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this PR:
Impact.impact_at_regvianp.unique(..., return_inverse=True)+ CSR sparse indicator matrix multiplication, andclimada.util.coordinates.points_to_rasterapply_boxviashapely.box) following reverta7849c8, with performance characteristics unchanged from perf(engine,coordinates): vectorize Impact.impact_at_reg CSR reduction and points_to_raster boxes #1350.Impact.impact_at_regby flatteningagg_regionswithnp.asarray(agg_regions).ravel()and sizing the indicator matrix rows fromn_reg = agg_regions.size(shape=(self.imp_mat.shape[1], agg_reg_unique.size), with explicit guards for empty or over-lengthagg_regions) so callers passinglen(agg_regions) < self.imp_mat.shape[1](such asclimada.test.test_util_calibrate, whereexposure()has 3 points with 1 unassigned centroid andagg_regions=["a", "b"]has length 2) match the priornp.wherecolumn selection identically.TestImpactReg.test_agg_regions_lengthcovering shorter, 2D, over-length, and emptyagg_regions(verified locally withpytest climada/test/test_util_calibrate.py climada/engine/test/test_impact.py climada/util/test/test_coordinates.py), and move theCHANGELOG.mdentry to## Unreleased > ### Changed.This PR fixes #1357
PR Author Checklist
develop)PR Reviewer Checklist