Skip to content

Commit ee119f1

Browse files
download exp_demo_h5 from api
1 parent 049c442 commit ee119f1

4 files changed

Lines changed: 13 additions & 14 deletions

File tree

climada/engine/unsequa/test/test_unsequa.py

Lines changed: 4 additions & 8 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):

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/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

0 commit comments

Comments
 (0)