Skip to content

Commit

Permalink
Avoid redundant calls to np.unique in Impact.impact_at_reg (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
peanutfun authored Feb 5, 2024
1 parent 7979fef commit 78efc1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Removed:
- In the TropCyclone class in the Holland model 2008 and 2010 implementation, a doublecounting of translational velocity is removed [#833](https://github.com/CLIMADA-project/climada_python/pull/833)
- `climada.util.test.test_finance` and `climada.test.test_engine` updated to recent input data from worldbank [#841](https://github.com/CLIMADA-project/climada_python/pull/841)
- Set `nodefaults` in Conda environment specs because `defaults` are not compatible with conda-forge [#845](https://github.com/CLIMADA-project/climada_python/pull/845)
- Avoid redundant calls to `np.unique` in `Impact.impact_at_reg` [#848](https://github.com/CLIMADA-project/climada_python/pull/848)

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions climada/engine/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ def impact_at_reg(self, agg_regions=None):
at_reg_event = np.hstack(
[
self.imp_mat[:, np.where(agg_regions == reg)[0]].sum(1)
for reg in np.unique(agg_reg_unique)
for reg in agg_reg_unique
]
)

at_reg_event = pd.DataFrame(
at_reg_event, columns=np.unique(agg_reg_unique), index=self.event_id
at_reg_event, columns=agg_reg_unique, index=self.event_id
)

return at_reg_event
Expand Down

0 comments on commit 78efc1e

Please sign in to comment.