File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1919"""
2020
2121import logging
22+ import numbers
2223from pathlib import Path
2324
2425import geopandas
@@ -820,12 +821,12 @@ def _from_country(
820821 total_value = _get_total_value_per_country (iso3a , fin_mode , reference_year )
821822
822823 # disaggregate total value proportional to LitPop values:
823- if isinstance (total_value , ( float , int ) ):
824+ if isinstance (total_value , numbers . Number ):
824825 litpop_gdf ["value" ] = (
825826 np .divide (litpop_gdf ["value" ], litpop_gdf ["value" ].sum ()) * total_value
826827 )
827828 elif total_value is not None :
828- raise TypeError ("total_value must be int or float ." )
829+ raise TypeError (f "total_value ( { total_value } ) must be a number ." )
829830
830831 exp = LitPop ()
831832 exp .set_gdf (litpop_gdf )
Original file line number Diff line number Diff line change 2222import unittest
2323from pathlib import Path
2424
25- from climada .util .constants import DEMO_DIR , ENT_TEMPLATE_XLS , GLB_CENTROIDS_MAT
25+ from climada .util .constants import (
26+ DEMO_DIR ,
27+ ENT_TEMPLATE_XLS ,
28+ GLB_CENTROIDS_MAT ,
29+ SYSTEM_DIR ,
30+ )
2631from climada .util .files_handler import (
2732 download_file ,
2833 get_extension ,
@@ -107,7 +112,8 @@ def test_folder_contents(self):
107112 def test_wrong_argument (self ):
108113 """If the input contains a non-existing file, an empyt directory or a pattern that is not
109114 matched, the method should raise a ValueError."""
110- empty_dir = DEMO_DIR .parent
115+ empty_dir = SYSTEM_DIR / "exposures"
116+ self .assertTrue (empty_dir .is_dir )
111117 with self .assertRaises (ValueError ) as ve :
112118 get_file_names (str (empty_dir ))
113119 self .assertIn ("no files" , str (ve .exception ))
You can’t perform that action at this time.
0 commit comments