Skip to content

Commit 72ab4f6

Browse files
committed
More strictly define data types
1 parent bc3a0c9 commit 72ab4f6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/dscim/preprocessing/input_damages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ def prep_mortality_damages(
715715

716716
# longest-string gcm has to be processed first so the coordinate is the right str length
717717
gcms = sorted(gcms, key=len, reverse=True)
718+
max_gcm_len = len(gcms[0])
718719

719720
if mortality_version == 0:
720721
scaling_deaths = "epa_scaled"
@@ -808,6 +809,8 @@ def prep(
808809
if damages[v].dtype == object:
809810
damages[v] = damages[v].astype("unicode")
810811

812+
damages['gcm'] = damages['gcm'].astype("U" + str(max_gcm_len))
813+
811814
if i == 0:
812815
damages.to_zarr(
813816
f"{outpath}/impacts-darwin-montecarlo-damages-v{mortality_version}.zarr",

tests/test_main_recipe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ def test_weitzman_min(menu_instance):
258258
diff = censored_values_slower[0:index] - censored_values[0:index]
259259
assert all(x > 0 for x in diff)
260260
as_share = menu_instance.weitzman_min(
261-
[20, 50, 100], [5, 30, 60], as_share
261+
np.array([20, 50, 100]), np.array([5, 30, 60]), as_share
262262
) # the first value only should be censored
263263
assert as_share[0] != 5 and [as_share[1], as_share[2]] == [30, 60]
264264
all_cons = menu_instance.weitzman_min(
265-
[20, 50, 100], [5, 30, 60], all_cons
265+
np.array([20, 50, 100]), np.array([5, 30, 60]), all_cons
266266
) # all values should be changed
267267
assert all([x != 0 for x in all_cons - [5, 30, 60]])
268268

0 commit comments

Comments
 (0)