Skip to content

Update test_base.py #1090

Update test_base.py

Update test_base.py #1090

GitHub Actions / Core / Unit Test Results (3.11) failed Dec 2, 2024 in 0s

1 fail, 710 pass in 10m 39s

711 tests  +701   710 ✅ +710   10m 39s ⏱️ + 10m 12s
  1 suites ±  0     0 💤 ±  0 
  1 files   ±  0     1 ❌ +  1 

Results for commit e8e3646. ± Comparison against earlier commit df3ec13.

Annotations

Check warning on line 0 in climada.entity.exposures.test.test_base.TestGeoDFFuncs

See this annotation in the file changed.

@github-actions github-actions / Core / Unit Test Results (3.11)

test_latlon_with_polygons (climada.entity.exposures.test.test_base.TestGeoDFFuncs) failed

tests_xml/tests.xml [took 0s]
Raw output
AssertionError: 'Can only calculate latitude from Points. GeoDataFrame contain[19 chars]ygon' != 'Can only calculate longitude from Points. GeoDataFrame contai[20 chars]ygon'
- Can only calculate latitude from Points. GeoDataFrame contains Polygon, MultiPolygon
?                     ^^
+ Can only calculate longitude from Points. GeoDataFrame contains Polygon, MultiPolygon
?                     ^^^
self = <climada.entity.exposures.test.test_base.TestGeoDFFuncs testMethod=test_latlon_with_polygons>

    def test_latlon_with_polygons(self):
        """Check for proper error message if the data frame contains non-Point shapes"""
        poly = Polygon(
            [(10.0, 0.0), (10.0, 1.0), (11.0, 1.0), (11.0, 0.0), (10.0, 0.0)]
        )
        point = Point((1, -1))
        multi = MultiPolygon(
            [
                (
                    ((0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)),
                    [((0.1, 1.1), (0.1, 1.2), (0.2, 1.2), (0.2, 1.1))],
                )
            ]
        )
        poly = Polygon()
        exp = Exposures(geometry=[poly, point, multi, poly])
        with self.assertRaises(ValueError) as valer:
            exp.latitude
        self.assertEqual(
            "Can only calculate latitude from Points. GeoDataFrame contains Polygon, MultiPolygon",
            str(valer.exception),
        )
        with self.assertRaises(ValueError) as valer:
            exp.longitude
>       self.assertEqual(
            "Can only calculate latitude from Points. GeoDataFrame contains Polygon, MultiPolygon",
            str(valer.exception),
        )
E       AssertionError: 'Can only calculate latitude from Points. GeoDataFrame contain[19 chars]ygon' != 'Can only calculate longitude from Points. GeoDataFrame contai[20 chars]ygon'
E       - Can only calculate latitude from Points. GeoDataFrame contains Polygon, MultiPolygon
E       ?                     ^^
E       + Can only calculate longitude from Points. GeoDataFrame contains Polygon, MultiPolygon
E       ?                     ^^^

climada/entity/exposures/test/test_base.py:679: AssertionError