Repository navigation
Conversation
napattan
requested review from
chahank,
emanuel-schmid and
peanutfun
as code owners
November 20, 2026 13:27
* re-apply CLIMADA-project#1350 vectorizations for Impact.impact_at_reg and points_to_raster * enforce strict 1D exact-length agg_regions check matching docstring (CLIMADA-project#1357) * update climada/test/test_util_calibrate.py for 3-point exposure fixture
napattan
force-pushed
the
fix/vectorize-impact-at-reg-points-to-raster-1357
branch
from
November 23, 2026 16:14
ee5eb87 to
2179733
Compare
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_reg(climada/engine/impact.py) with a single sparse indicator matrix multiplication (self.imp_mat @ reg_ind), preservingimp_mat.dtypeand theagg_regions=Noneadmin-0 country fallback.Point(...).buffer(res / 2).envelopecall inclimada.util.coordinates.points_to_rasterwith vectorizedshapely.box(and drop the unusedPointimport).agg_regionsinImpact.impact_at_reg(agg_regions.ndim == 1andlen(agg_regions) == imp_mat.shape[1], raisingValueErrorotherwise) to match the existing docstring contract, and document theRaisessection.climada/test/test_util_calibrate.py(TestScipyMinimizeOptimizer.setUpandTestBayesianOptimizer.setUp) fromimpact.impact_at_reg(["a", "b"])toimpact.impact_at_reg(["a", "b", "c"])[["a", "b"]]to match the 3-pointexposure()fixture (whose 3rd point is unassigned) without alteringInput.impact_to_aligned_dfalignment, MSE scaling, orOutputEvaluatorplots. Audited all otherimpact_at_regcall sites inclimada/anddoc/and confirmed none rely on mismatched lengths.climada/engine/test/test_impact.pycovering unsorted duplicate region labels,float32dtype preservation, andValueErrorvalidation for empty, shorter, longer, scalar, and 2Dagg_regions.CHANGELOG.mdandAUTHORS.md.Verification
MPLBACKEND=Agg,CI=true):pytest climada/test/test_util_calibrate.py climada/engine/test/test_impact.py climada/util/test/test_coordinates.py climada/util/calibrate/test/ climada/entity/exposures/test/test_base.py-> 214 passed, 1 skipped (pre-existing
test_cycling_csv), 15 subtests passed, 0 failed (including 6/6 inclimada/test/test_util_calibrate.py).pylint --rcfile=.pylintrc climada/engine/impact.py climada/util/coordinates.py: 9.34/10 (0 warnings on modified lines).black --check(24.4.2) andisort --profile black --check-only(5.13.2): passed.a7849c8fbaseline):Impact.impact_at_regmax_diff = 1.42e-14points_to_rasterboxTrue)This PR fixes #1357
PR Author Checklist
develop)PR Reviewer Checklist