diff --git a/requirements.txt b/requirements.txt index fbdd29cd..3aa4fe82 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # This is used to build the CI test environment and so Github can track dependencies. -xarray==2024.3.0 +xarray==2025.1.2 pandas==2.2.3 numpy==1.26.4 matplotlib==3.10.1 @@ -15,3 +15,4 @@ h5netcdf==1.6.1 impactlab-tools==0.6.0 p_tqdm==1.4.2 pyarrow==19.0.1 +numcodecs==0.15.1 diff --git a/src/dscim/preprocessing/input_damages.py b/src/dscim/preprocessing/input_damages.py index e55f6bb0..a5d71a35 100644 --- a/src/dscim/preprocessing/input_damages.py +++ b/src/dscim/preprocessing/input_damages.py @@ -715,6 +715,7 @@ def prep_mortality_damages( # longest-string gcm has to be processed first so the coordinate is the right str length gcms = sorted(gcms, key=len, reverse=True) + max_gcm_len = len(gcms[0]) if mortality_version == 0: scaling_deaths = "epa_scaled" @@ -808,6 +809,8 @@ def prep( if damages[v].dtype == object: damages[v] = damages[v].astype("unicode") + damages["gcm"] = damages["gcm"].astype("U" + str(max_gcm_len)) + if i == 0: damages.to_zarr( f"{outpath}/impacts-darwin-montecarlo-damages-v{mortality_version}.zarr", diff --git a/tests/test_main_recipe.py b/tests/test_main_recipe.py index e69c3958..28b0b3e2 100644 --- a/tests/test_main_recipe.py +++ b/tests/test_main_recipe.py @@ -258,11 +258,11 @@ def test_weitzman_min(menu_instance): diff = censored_values_slower[0:index] - censored_values[0:index] assert all(x > 0 for x in diff) as_share = menu_instance.weitzman_min( - [20, 50, 100], [5, 30, 60], as_share + np.array([20, 50, 100]), np.array([5, 30, 60]), as_share ) # the first value only should be censored assert as_share[0] != 5 and [as_share[1], as_share[2]] == [30, 60] all_cons = menu_instance.weitzman_min( - [20, 50, 100], [5, 30, 60], all_cons + np.array([20, 50, 100]), np.array([5, 30, 60]), all_cons ) # all values should be changed assert all([x != 0 for x in all_cons - [5, 30, 60]])