Skip to content

Commit ea8e9b6

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/static-risk-traj
2 parents 152f594 + 99703d3 commit ea8e9b6

9 files changed

Lines changed: 28 additions & 33 deletions

File tree

climada/engine/unsequa/test/test_unsequa.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,18 @@
4141
from climada.entity import Exposures, ImpactFunc, ImpactFuncSet
4242
from climada.entity.entity_def import Entity
4343
from climada.hazard import Hazard
44-
from climada.util.api_client import Client
44+
from climada.test import get_test_file
4545
from climada.util.constants import (
4646
ENT_DEMO_FUTURE,
4747
ENT_DEMO_TODAY,
48-
EXP_DEMO_H5,
4948
HAZ_DEMO_H5,
5049
TEST_UNC_OUTPUT_COSTBEN,
5150
TEST_UNC_OUTPUT_IMPACT,
5251
)
5352

54-
test_unc_output_impact = Client().get_dataset_file(
55-
name=TEST_UNC_OUTPUT_IMPACT, status="test_dataset"
56-
)
57-
test_unc_output_costben = Client().get_dataset_file(
58-
name=TEST_UNC_OUTPUT_COSTBEN, status="test_dataset"
59-
)
53+
EXP_DEMO_H5 = get_test_file("exp_demo_today", file_format="hdf5")
54+
test_unc_output_impact = get_test_file(TEST_UNC_OUTPUT_IMPACT)
55+
test_unc_output_costben = get_test_file(TEST_UNC_OUTPUT_COSTBEN)
6056

6157

6258
def impf_dem(x_paa=1, x_mdd=1):
@@ -578,7 +574,7 @@ def test_calc_sensitivity_all_pass(self):
578574
"sensitivity_kwargs": {"S": 10, "seed": 12345},
579575
"test_param_name": ["x_exp", 0],
580576
"test_si_name": ["CV", 16],
581-
"test_si_value": [0.25000, 2],
577+
"test_si_value": [0.250000, 2],
582578
},
583579
"hdmr": {
584580
"sampling_method": "saltelli",
@@ -587,7 +583,7 @@ def test_calc_sensitivity_all_pass(self):
587583
"sensitivity_kwargs": {},
588584
"test_param_name": ["x_exp", 2],
589585
"test_si_name": ["Sa", 4],
590-
"test_si_value": [0.004658, 3],
586+
"test_si_value": [0.004649, 3],
591587
},
592588
"ff": {
593589
"sampling_method": "ff",
@@ -618,7 +614,7 @@ def test_calc_sensitivity_all_pass(self):
618614
},
619615
"test_param_name": ["x_exp", 0],
620616
"test_si_name": ["dgsm", 8],
621-
"test_si_value": [1.697516e-01, 9],
617+
"test_si_value": [0.1697516, 9],
622618
},
623619
"fast": {
624620
"sampling_method": "fast_sampler",
@@ -627,7 +623,7 @@ def test_calc_sensitivity_all_pass(self):
627623
"sensitivity_kwargs": {"M": 4, "seed": 12345},
628624
"test_param_name": ["x_exp", 0],
629625
"test_si_name": ["S1_conf", 8],
630-
"test_si_value": [0.671396, 1],
626+
"test_si_value": [0.671546, 1],
631627
},
632628
"rbd_fast": {
633629
"sampling_method": "saltelli",
@@ -636,7 +632,7 @@ def test_calc_sensitivity_all_pass(self):
636632
"sensitivity_kwargs": {"M": 4, "seed": 12345},
637633
"test_param_name": ["x_exp", 0],
638634
"test_si_name": ["S1_conf", 4],
639-
"test_si_value": [0.152609, 4],
635+
"test_si_value": [0.129919, 4],
640636
},
641637
"morris": {
642638
"sampling_method": "morris",
@@ -645,7 +641,7 @@ def test_calc_sensitivity_all_pass(self):
645641
"sensitivity_kwargs": {},
646642
"test_param_name": ["x_exp", 0],
647643
"test_si_name": ["mu", 1],
648-
"test_si_value": [5066460029.63911, 8],
644+
"test_si_value": [7935400297.813827, 8],
649645
},
650646
}
651647

@@ -700,7 +696,7 @@ def test_sensitivity_method(
700696
haz_unc,
701697
sensitivity_method,
702698
method_params,
703-
places=2 if sensitivity_method == "rbd_fast" else 5,
699+
places=5,
704700
)
705701

706702

climada/entity/exposures/test/test_base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,6 @@ def test_handling_unit_conflicts_pass(self):
440440
self.assertEqual(exp_df.value_unit, "XSD")
441441
with self.assertRaises(ValueError) as cm:
442442
exp_df = Exposures(df, meta={"value_unit": "XSD"}, value_unit="PAK")
443-
with self.assertRaises(ValueError) as cm:
444-
exp_df = Exposures(df, meta={"value_unit": "PAK"}, value_unit="XSD")
445-
with self.assertRaises(ValueError) as cm:
446-
exp_df = Exposures(df, meta={"value_unit": "PAK"}, value_unit="PAK")
447443

448444
def test_io_hdf5_pass(self):
449445
"""write and read hdf5"""

climada/entity/measures/test/test_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@
3636
from climada.entity.measures.measure_set import MeasureSet
3737
from climada.hazard.base import Hazard
3838
from climada.test import get_test_file
39-
from climada.util.constants import EXP_DEMO_H5, HAZ_DEMO_H5
39+
from climada.util.constants import HAZ_DEMO_H5
4040

4141
DATA_DIR = CONFIG.measures.test_data.dir()
4242

43+
EXP_DEMO_H5 = get_test_file("exp_demo_today", file_format="hdf5")
44+
4345
HAZ_TEST_TC: Path = get_test_file("test_tc_florida", file_format="hdf5")
4446
"""
4547
Hazard test file from Data API: Hurricanes from 1851 to 2011 over Florida with 100 centroids.

climada/hazard/tc_tracks_synth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ def _apply_decay_coeffs(track, v_rel, p_rel, land_geom, s_rel):
10491049
# if there is no further landfall, correct until the end of
10501050
# the track
10511051
end_cor = track["time"].size
1052-
rndn = 0.1 * float(np.abs(np.random.normal(size=1) * 5) + 6)
1052+
rndn = 0.1 * float(np.abs(np.random.default_rng().normal() * 5) + 6)
10531053
r_diff = (
10541054
track["central_pressure"][land_sea].values
10551055
- track["central_pressure"][land_sea - 1].values

climada/test/test_api_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ def test_get_exposures(self):
177177
"fin_mode": "pop",
178178
"exponents": "(0,1)",
179179
},
180-
version="v1",
180+
version="v3",
181181
dump_dir=DATA_DIR,
182182
)
183183
self.assertEqual(len(exposures.gdf), 5782)
184184
self.assertEqual(np.unique(exposures.region_id), 40)
185185
self.assertEqual(
186186
exposures.description,
187-
"LitPop Exposure for ['AUT'] at 150 as, year: 2018, financial mode: pop, exp: [0, 1], admin1_calc: False",
187+
"LitPop Exposure for ['AUT'] at 150 as, year: 2018, financial mode: pop, exp: (0, 1), admin1_calc: False",
188188
)
189189

190190
def test_get_exposures_fails(self):
@@ -264,12 +264,12 @@ def test_get_hazard_fails(self):
264264

265265
def test_get_litpop(self):
266266
client = Client()
267-
litpop = client.get_litpop(country="LUX", version="v1", dump_dir=DATA_DIR)
267+
litpop = client.get_litpop(country="LUX", version="v3", dump_dir=DATA_DIR)
268268
self.assertEqual(len(litpop.gdf), 188)
269269
self.assertEqual(np.unique(litpop.region_id), 442)
270270
self.assertEqual(
271271
litpop.description,
272-
"LitPop Exposure for ['LUX'] at 150 as, year: 2018, financial mode: pc, exp: [1, 1], admin1_calc: False",
272+
"LitPop Exposure for ['LUX'] at 150 as, year: 2018, financial mode: pc, exp: (1, 1), admin1_calc: False",
273273
)
274274

275275
def test_get_litpop_fail(self):

climada/test/test_engine.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434
from climada.entity import Exposures, ImpactFunc, ImpactFuncSet
3535
from climada.entity.entity_def import Entity
3636
from climada.hazard import Hazard
37+
from climada.test import get_test_file
3738
from climada.util.constants import (
3839
ENT_DEMO_FUTURE,
3940
ENT_DEMO_TODAY,
40-
EXP_DEMO_H5,
4141
HAZ_DEMO_H5,
4242
)
4343

4444
DATA_DIR = CONFIG.engine.test_data.dir()
45+
EXP_DEMO_H5 = get_test_file("exp_demo_today", file_format="hdf5")
4546
EMDAT_TEST_CSV = DATA_DIR.joinpath("emdat_testdata_BGD_USA_1970-2017.csv")
4647

4748

climada/util/hdf5_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_string(array):
8989
-------
9090
string
9191
"""
92-
return "".join(chr(int(c)) for c in array)
92+
return "".join(chr(c.item()) for c in array)
9393

9494

9595
def get_str_from_ref(file_name, var):

doc/user-guide/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ User guide
33
====================
44

55
This user guide contains all the detailed tutorials about the different parts of CLIMADA.
6-
If you are a new user, we advise you to have a look at the `10 minutes CLIMADA <0_10min_climada>`_
7-
which introduces the basics briefly, or the full `Overview <1_main_climada>`_ which goes more in depth.
6+
If you are a new user, we advise you to have a look at the `10 minutes CLIMADA <0_10min_climada.html>`_
7+
which introduces the basics briefly, or the full `Overview <1_main_climada.html>`_ which goes more in depth.
88

9-
You can then go on to more specific tutorial about `Hazard <hazard>`_,
10-
`Exposures <exposures>`_ or `Impact <impact>`_ or advanced usage such as
11-
`Uncertainty Quantification <unsequa>`_
9+
You can then go on to more specific tutorial about `Hazard <hazard.html>`_,
10+
`Exposures <exposures.html>`_ or `Impact <impact.html>`_ or advanced usage such as
11+
`Uncertainty Quantification <unsequa.html>`_
1212

1313
.. toctree::
1414
:maxdepth: 2

requirements/env_climada.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
- rasterio>=1.4
3636
- requests>=2.32
3737
- rtree>=1.4
38-
- salib>=1.5,<1.5.2 # see https://github.com/CLIMADA-project/climada_python/issues/1081
38+
- salib>=1.5.2 # see https://github.com/CLIMADA-project/climada_python/issues/1081
3939
- scikit-learn>=1.7
4040
- scipy>=1.15
4141
- seaborn>=0.13

0 commit comments

Comments
 (0)