Skip to content

Update tests in test_vec_ras #197

Update tests in test_vec_ras

Update tests in test_vec_ras #197

This check has been archived and is scheduled for deletion. Learn more about checks retention
GitHub Actions / Unit Test Results Python 3.9 failed Dec 5, 2023 in 0s

25 fail, 610 pass in 6m 30s

635 tests  ±0   610 ✔️ +7   6m 30s ⏱️ -16s
    1 suites ±0       0 💤 ±0 
    1 files   ±0     25  - 7 

Results for commit ae6a0cc. ± Comparison against earlier commit a426247.

Annotations

Check warning on line 0 in climada.hazard.centroids.test.test_centr.TestCentroidsReader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_centroid_pass (climada.hazard.centroids.test.test_centr.TestCentroidsReader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.centroids.test.test_centr.TestCentroidsReader testMethod=test_centroid_pass>

    def test_centroid_pass(self):
        """Read a centroid excel file correctly."""
>       centroids = Centroids.from_excel(HAZ_TEMPLATE_XLS)

climada/hazard/centroids/test/test_centr.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = None

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_append_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_append_pass>

    def test_append_pass(self):
        """Append points"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:192: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_area_approx (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_area_approx>

    def test_area_approx(self):
        """Test set_area_approx"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:184: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_area_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
AttributeError: can't set attribute
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'})
    
        centr = Centroids(latitude=vec_data.lat.values, longitude=vec_data.lon.values)
>       centr.geometry = vec_data.geometry
E       AttributeError: can't set attribute

climada/hazard/centroids/test/test_vec_ras.py:132: AttributeError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_dist_coast_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 2s]
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.9/lib/python3.9/contextlib.py:79: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7fe533077820>, 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.9/lib/python3.9/contextlib.py:79: AssertionError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_equal_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_equal_pass>

    def test_equal_pass(self):
        """Test equal"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:210: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_get_closest_point (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_get_closest_point>

    def test_get_closest_point(self):
        """Test get_closest_point"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:145: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_get_pixel_polygons_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_get_pixel_polygons_pass>

    def test_get_pixel_polygons_pass(self):
        """Test calc_pixels_polygons"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:174: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

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.9/lib/python3.9/contextlib.py:79: AssertionError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

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: 4 / 6 (66.7%)
Max absolute difference: 776
Max relative difference: 1.
 x: array([ 0,  0,  0,  0, 10,  0])
 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     0
1     0
2     0
3     0
4    10
5     0
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: 4 / 6 (66.7%)
E           Max absolute difference: 776
E           Max relative difference: 1.
E            x: array([ 0,  0,  0,  0, 10,  0])
E            y: array([776, 242, 578,   0,  10, 218])

../../../micromamba/envs/climada_env_3.9/lib/python3.9/contextlib.py:79: AssertionError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_set_lat_lon_to_meta_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_set_lat_lon_to_meta_pass>

    def test_set_lat_lon_to_meta_pass(self):
        """Test set_lat_lon_to_meta"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:157: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestVector

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_size_pass (climada.hazard.centroids.test.test_vec_ras.TestVector) failed

tests_xml/tests.xml [took 0s]
Raw output
NameError: name 'data_vector' is not defined
self = <climada.hazard.centroids.test.test_vec_ras.TestVector testMethod=test_size_pass>

    def test_size_pass(self):
        """Test size property"""
>       lat, lon, geometry = data_vector()
E       NameError: name 'data_vector' is not defined

climada/hazard/centroids/test/test_vec_ras.py:138: NameError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestRaster

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

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:278: AssertionError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestRaster

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

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:239: AssertionError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestReader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_from_raster_file_wrong_fail (climada.hazard.centroids.test.test_vec_ras.TestReader) failed

tests_xml/tests.xml [took 0s]
Raw output
AttributeError: 'Centroids' object has no attribute 'meta'
self = <climada.hazard.centroids.test.test_vec_ras.TestReader testMethod=test_from_raster_file_wrong_fail>

    def test_from_raster_file_wrong_fail(self):
        """Test from_raster_file with wrong centroids"""
        centr = Centroids.from_raster_file(HAZ_DEMO_FL, window=Window(10, 20, 50, 60))
>       self.assertAlmostEqual(centr.meta['crs'], DEF_CRS)
E       AttributeError: 'Centroids' object has no attribute 'meta'

climada/hazard/centroids/test/test_vec_ras.py:390: AttributeError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestReader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_from_vector_file (climada.hazard.centroids.test.test_vec_ras.TestReader) failed

tests_xml/tests.xml [took 0s]
Raw output
TypeError: climada.hazard.centroids.centr.Centroids() got multiple values for keyword argument 'latitude'
self = <climada.hazard.centroids.test.test_vec_ras.TestReader testMethod=test_from_vector_file>

    def test_from_vector_file(self):
        """Test from_vector_file and values_from_vector_files"""
        shp_file = shapereader.natural_earth(resolution='110m', category='cultural',
                                             name='populated_places_simple')
>       centr = Centroids.from_vector_file(shp_file)

climada/hazard/centroids/test/test_vec_ras.py:359: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/centroids/centr.py:649: in from_vector_file
    centroids = cls.from_geodataframe(gpd.read_file(file_name))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
gdf =      scalerank  natscale  ...       ne_id                     geometry
0            8        10  ...  1159127243    PO...INT (103.85387 1.29498)
242          0       600  ...  1159151629   POINT (114.18306 22.30693)

[243 rows x 32 columns]

    @classmethod
    def from_geodataframe(cls, gdf):
        """Initialize centroids from a geodataframe
    
        Parameters
        ----------
        gdf : GeoDataFrame
            Input geodataframe with centroids as points
            in the geometry column. All other columns are
            attached to the centroids geodataframe.
    
        Returns
        -------
        Centroids
            Centroids built from the geodataframe.
        """
>       return cls(
            longitude=gdf.geometry.x.values,
            latitude=gdf.geometry.y.values,
            crs=gdf.crs,
            **gdf.drop(columns=['geometry']).to_dict(orient='list')
            )
E       TypeError: climada.hazard.centroids.centr.Centroids() got multiple values for keyword argument 'latitude'

climada/hazard/centroids/centr.py:235: TypeError

Check warning on line 0 in climada.hazard.centroids.test.test_vec_ras.TestReader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_write_read_raster_h5 (climada.hazard.centroids.test.test_vec_ras.TestReader) failed

tests_xml/tests.xml [took 0s]
Raw output
AttributeError: type object 'Centroids' has no attribute 'from_pix_bounds'
self = <climada.hazard.centroids.test.test_vec_ras.TestReader testMethod=test_write_read_raster_h5>

    def test_write_read_raster_h5(self):
        """Write and read hdf5 format"""
        file_name = str(DATA_DIR.joinpath('test_centr.h5'))
    
        xf_lat, xo_lon, d_lat, d_lon, n_lat, n_lon = 10, 5, -0.5, 0.2, 20, 25
>       centr = Centroids.from_pix_bounds(xf_lat, xo_lon, d_lat, d_lon, n_lat, n_lon)
E       AttributeError: type object 'Centroids' has no attribute 'from_pix_bounds'

climada/hazard/centroids/test/test_vec_ras.py:412: AttributeError

Check warning on line 0 in climada.hazard.test.test_base.TestLoader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_event_id_to_name_fail (climada.hazard.test.test_base.TestLoader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestLoader testMethod=test_event_id_to_name_fail>

    def test_event_id_to_name_fail(self):
        """Test event_id_to_name function."""
>       haz = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:193: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestLoader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_event_id_to_name_pass (climada.hazard.test.test_base.TestLoader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestLoader testMethod=test_event_id_to_name_pass>

    def test_event_id_to_name_pass(self):
        """Test event_id_to_name function."""
>       haz = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:187: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestLoader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_event_name_to_id_fail (climada.hazard.test.test_base.TestLoader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestLoader testMethod=test_event_name_to_id_fail>

    def test_event_name_to_id_fail(self):
        """Test event_name_to_id function."""
>       haz = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:180: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestLoader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_event_name_to_id_pass (climada.hazard.test.test_base.TestLoader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestLoader testMethod=test_event_name_to_id_pass>

    def test_event_name_to_id_pass(self):
        """Test event_name_to_id function."""
>       haz = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestRemoveDupl

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_equal_same (climada.hazard.test.test_base.TestRemoveDupl) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestRemoveDupl testMethod=test_equal_same>

    def test_equal_same(self):
        """Append the same hazard and remove duplicates, obtain initial hazard."""
>       haz1 = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:220: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestAppend

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_append_empty_fill (climada.hazard.test.test_base.TestAppend) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestAppend testMethod=test_append_empty_fill>

    def test_append_empty_fill(self):
        """Append an empty. Obtain initial hazard."""
        def _check_hazard(hazard):
            # expected values
            haz1_orig = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')
            self.assertEqual(hazard.event_name, haz1_orig.event_name)
            self.assertTrue(np.array_equal(hazard.event_id, haz1_orig.event_id))
            self.assertTrue(np.array_equal(hazard.date, haz1_orig.date))
            self.assertTrue(np.array_equal(hazard.orig, haz1_orig.orig))
            self.assertTrue(np.array_equal(hazard.frequency, haz1_orig.frequency))
            self.assertEqual(hazard.frequency_unit, haz1_orig.frequency_unit)
            self.assertTrue((hazard.intensity != haz1_orig.intensity).nnz == 0)
            self.assertTrue((hazard.fraction != haz1_orig.fraction).nnz == 0)
            self.assertEqual(hazard.units, haz1_orig.units)
            self.assertEqual(hazard.haz_type, haz1_orig.haz_type)
    
>       haz1 = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:617: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_base.TestReaderExcel

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_hazard_pass (climada.hazard.test.test_base.TestReaderExcel) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
self = <climada.hazard.test.test_base.TestReaderExcel testMethod=test_hazard_pass>

    def test_hazard_pass(self):
        """Read an hazard excel file correctly."""
    
        # Read demo excel file
        description = 'One single file.'
>       hazard = Hazard.from_excel(HAZ_TEMPLATE_XLS, haz_type='TC')

climada/hazard/test/test_base.py:1031: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/hazard/base.py:1182: in from_excel
    centroids = Centroids.from_excel(file_name, var_names=var_names['col_centroids'])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/climada/data/hazard_template.xlsx')
var_names = {'col_name': {'cen_id': 'centroid_id', 'lat': 'latitude', 'lon': 'longitude'}, 'sheet_name': 'centroids'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError

Check warning on line 0 in climada.hazard.test.test_storm_europe.TestReader

See this annotation in the file changed.

@github-actions github-actions / Unit Test Results Python 3.9

test_read_with_cent (climada.hazard.test.test_storm_europe.TestReader) failed

tests_xml/tests.xml [took 0s]
Raw output
UnboundLocalError: local variable 'crs' referenced before assignment
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
            )

climada/hazard/test/test_storm_europe.py:70: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'climada.hazard.centroids.centr.Centroids'>
file_name = PosixPath('/home/runner/work/climada_python/climada_python/climada/hazard/test/data/fp_centroids-test.xls')
var_names = {'col_name': {' area_pixel': 'area_pixel', 'dist_coast': 'dist_coast', 'elevation': 'elevation', 'lat': 'latitude', ...}, 'sheet_name': 'fp_centroids-test'}

    @classmethod
    def from_excel(cls, file_name, var_names=None):
        """Generate a new centroids object from an excel file with column names in var_names.
    
        Parameters
        ----------
        file_name : str
            absolute or relative file name
        crs : dict() or rasterio.crs.CRS, optional
            CRS. Default: DEF_CRS
        var_names : dict, default
            name of the variables
    
        Raises
        ------
        KeyError
    
        Returns
        -------
        centr : Centroids
            Centroids with data from the given excel file
        """
>       if crs is None:
E       UnboundLocalError: local variable 'crs' referenced before assignment

climada/hazard/centroids/centr.py:708: UnboundLocalError