gencenctroids.centr: change crs of the geodataframe instead of the ge… #207
8 fail, 623 pass in 6m 47s
Annotations
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector
github-actions / Unit Test Results Python 3.10
test_area_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed
tests_xml/tests.xml [took 0s]
Raw output
AssertionError: False is not true
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_area_pass>
def test_area_pass(self):
"""Test set_area"""
ulx, xres, lrx = 60, 1, 90
uly, yres, lry = 0, 1, 20
xx, yy = np.meshgrid(np.arange(ulx + xres / 2, lrx, xres),
np.arange(uly + yres / 2, lry, yres))
vec_data = gpd.GeoDataFrame({
'geometry': [Point(xflat, yflat) for xflat, yflat in zip(xx.flatten(), yy.flatten())],
'lon': xx.flatten(),
'lat': yy.flatten(),
}, crs={'proj': 'cea'})
area_pixel = self.centr.get_area_pixel()
> self.assertTrue(np.allclose(area_pixel, np.ones(self.centr.size)))
E AssertionError: False is not true
climada/hazard/centroids/test/test_vec_ras.py:132: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector
github-actions / Unit Test Results Python 3.10
test_dist_coast_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed
tests_xml/tests.xml [took 1s]
Raw output
AssertionError:
Arrays are not almost equal to 3 decimals
Mismatched elements: 5 / 6 (83.3%)
Max absolute difference: 553972.84998257
Max relative difference: 0.99711068
x: array([ 1605.243, 603.261, 2228.629, 482.265, 661.114,
158184.4 ])
y: array([5.556e+05, 1.641e+03, 2.007e+03, 4.823e+02, 4.500e+03, 1.086e+05])
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_dist_coast_pass>
def test_dist_coast_pass(self):
"""Test set_dist_coast"""
dist_coast = self.centr.get_dist_coast()\
# Just checking that the output doesnt change over time.
REF_VALUES = np.array([
5.55578093e+05, 1.64066475e+03, 2.00703835e+03,
4.82264614e+02, 4.50037266e+03, 1.08610274e+05
])
> np.testing.assert_array_almost_equal(dist_coast, REF_VALUES, decimal=3)
climada/hazard/centroids/test/test_vec_ras.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../micromamba/envs/climada_env_3.10/lib/python3.10/contextlib.py:79: in inner
return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<function assert_array_almost_equal.<locals>.compare at 0x7fc6b09a8820>, array([ 1605.24301743, 603.26125189, 2...6267]), array([5.55578093e+05, 1.64066475e+03, 2.00703835e+03, 4.82264614e+02,
4.50037266e+03, 1.08610274e+05]))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 3 decimals', 'precision': 3, 'verbose': True}
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
> return func(*args, **kwds)
E AssertionError:
E Arrays are not almost equal to 3 decimals
E
E Mismatched elements: 5 / 6 (83.3%)
E Max absolute difference: 553972.84998257
E Max relative difference: 0.99711068
E x: array([ 1605.243, 603.261, 2228.629, 482.265, 661.114,
E 158184.4 ])
E y: array([5.556e+05, 1.641e+03, 2.007e+03, 4.823e+02, 4.500e+03, 1.086e+05])
../../../micromamba/envs/climada_env_3.10/lib/python3.10/contextlib.py:79: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector
github-actions / Unit Test Results Python 3.10
test_get_closest_point (climada.hazard.centroids.test.test_vec_ras.TestVector) failed
tests_xml/tests.xml [took 0s]
Raw output
AssertionError: -78.5833 != -58.125 within 7 places (20.458299999999994 difference)
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_get_closest_point>
def test_get_closest_point(self):
"""Test get_closest_point"""
x, y, idx = self.centr.get_closest_point(-58.13, 14.38)
> self.assertAlmostEqual(x, -58.125)
E AssertionError: -78.5833 != -58.125 within 7 places (20.458299999999994 difference)
climada/hazard/centroids/test/test_vec_ras.py:142: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector
github-actions / Unit Test Results Python 3.10
test_on_land (climada.hazard.centroids.test.test_vec_ras.TestVector) failed
tests_xml/tests.xml [took 4s]
Raw output
AssertionError:
Arrays are not equal
Mismatched elements: 2 / 6 (33.3%)
x: array([ True, False, False, False, True, True])
y: array([ True, True, True, False, True, True])
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_on_land>
def test_on_land(self):
"""Test set_on_land"""
self.centr.set_on_land()
> np.testing.assert_array_equal(
self.centr.on_land,
ON_LAND
)
climada/hazard/centroids/test/test_vec_ras.py:105:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<built-in function eq>, 0 True
1 False
2 False
3 False
4 True
5 True
Name: on_land, dtype: bool, array([ True, True, True, False, True, True]))
kwds = {'err_msg': '', 'header': 'Arrays are not equal', 'strict': False, 'verbose': True}
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
> return func(*args, **kwds)
E AssertionError:
E Arrays are not equal
E
E Mismatched elements: 2 / 6 (33.3%)
E x: array([ True, False, False, False, True, True])
E y: array([ True, True, True, False, True, True])
../../../micromamba/envs/climada_env_3.10/lib/python3.10/contextlib.py:79: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector
github-actions / Unit Test Results Python 3.10
test_region_id_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed
tests_xml/tests.xml [took 4s]
Raw output
AssertionError:
Arrays are not equal
Mismatched elements: 2 / 6 (33.3%)
Max absolute difference: 578
Max relative difference: 1.
x: array([776, 0, 0, 0, 10, 218])
y: array([776, 242, 578, 0, 10, 218])
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_region_id_pass>
def test_region_id_pass(self):
"""Test set_region_id"""
self.centr.set_region_id()
> np.testing.assert_array_equal(
self.centr.region_id,
REGION_ID
)
climada/hazard/centroids/test/test_vec_ras.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<built-in function eq>, 0 776
1 0
2 0
3 0
4 10
5 218
Name: region_id, dtype: int64, array([776, 242, 578, 0, 10, 218]))
kwds = {'err_msg': '', 'header': 'Arrays are not equal', 'strict': False, 'verbose': True}
@wraps(func)
def inner(*args, **kwds):
with self._recreate_cm():
> return func(*args, **kwds)
E AssertionError:
E Arrays are not equal
E
E Mismatched elements: 2 / 6 (33.3%)
E Max absolute difference: 578
E Max relative difference: 1.
E x: array([776, 0, 0, 0, 10, 218])
E y: array([776, 242, 578, 0, 10, 218])
../../../micromamba/envs/climada_env_3.10/lib/python3.10/contextlib.py:79: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestRaster
github-actions / Unit Test Results Python 3.10
test_area_pass (climada.hazard.centroids.test.test_vec_ras.TestRaster) failed
tests_xml/tests.xml [took 0s]
Raw output
AssertionError: False is not true
self = <climada.hazard.centroids.test.test_vec_ras.TestRaster testMethod=test_area_pass>
def test_area_pass(self):
"""Test set_area"""
centr_ras = Centroids.from_raster_file(HAZ_DEMO_FL, window=Window(0, 0, 50, 60))
#centr_ras.meta['crs'] = {'proj': 'cea'}
area_pixel = centr_ras.get_area_pixel()
> self.assertTrue(
np.allclose(area_pixel,
np.ones(60 * 50) * 0.009000000000000341 * 0.009000000000000341))
E AssertionError: False is not true
climada/hazard/centroids/test/test_vec_ras.py:238: AssertionError
Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestRaster
github-actions / Unit Test Results Python 3.10
test_ne_crs_geom_pass (climada.hazard.centroids.test.test_vec_ras.TestRaster) failed
tests_xml/tests.xml [took 0s]
Raw output
AssertionError: 4.51063496489 != -69.3326495969998 within 7 places (73.8432845618898 difference)
self = <climada.hazard.centroids.test.test_vec_ras.TestRaster testMethod=test_ne_crs_geom_pass>
def test_ne_crs_geom_pass(self):
"""Test _ne_crs_geom"""
centr_ras = Centroids.from_raster_file(HAZ_DEMO_FL, window=Window(0, 0, 50, 60))
xy_vec = centr_ras._ne_crs_geom()
x_vec, y_vec = xy_vec.geometry[:].x.values, xy_vec.geometry[:].y.values
> self.assertAlmostEqual(4.51063496489, x_vec[0])
E AssertionError: 4.51063496489 != -69.3326495969998 within 7 places (73.8432845618898 difference)
climada/hazard/centroids/test/test_vec_ras.py:199: AssertionError
Check warning on line 0 in climada.hazard.test.test_storm_europe.TestReader
github-actions / Unit Test Results Python 3.10
test_read_with_cent (climada.hazard.test.test_storm_europe.TestReader) failed
tests_xml/tests.xml [took 0s]
Raw output
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
self = <climada.hazard.test.test_storm_europe.TestReader testMethod=test_read_with_cent>
def test_read_with_cent(self):
"""Test from_footprints while passing in a Centroids object"""
var_names = copy.deepcopy(DEF_VAR_EXCEL)
var_names['sheet_name'] = 'fp_centroids-test'
var_names['col_name']['region_id'] = 'iso_n3'
test_centroids = Centroids.from_excel(
DATA_DIR.joinpath('fp_centroids-test.xls'),
var_names=var_names
)
storms = StormEurope.from_footprints(WS_DEMO_NC, centroids=test_centroids)
self.assertEqual(storms.intensity.shape, (2, 9944))
self.assertEqual(
np.count_nonzero(
> ~np.isnan(storms.centroids.region_id)
),
6401
)
E TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
climada/hazard/test/test_storm_europe.py:79: TypeError