pytroll / pyresample

Geospatial image resampling in Python
http://pyresample.readthedocs.org
GNU Lesser General Public License v3.0
346 stars 94 forks source link

Fails to build with Shapely 2.0 #484

Closed sebastic closed 1 year ago

sebastic commented 1 year ago

The build fails due to test failures:

=================================== FAILURES ===================================
___________________ Test.test_area_def_geocentric_resolution ___________________

self = <pyresample.test.test_geometry.Test testMethod=test_area_def_geocentric_resolution>

    def test_area_def_geocentric_resolution(self):
        """Test the AreaDefinition.geocentric_resolution method."""
        from pyresample import get_area_def
        area_extent = (-5570248.477339745, -5561247.267842293, 5567248.074173927, 5570248.477339745)
        proj_dict = {'a': 6378169.0, 'b': 6356583.8, 'h': 35785831.0,
                     'lon_0': 0.0, 'proj': 'geos', 'units': 'm'}
        # metered projection
        area_def = get_area_def('orig', 'Test area', 'test',
                                proj_dict,
                                3712, 3712,
                                area_extent)
        geo_res = area_def.geocentric_resolution()
>       np.testing.assert_allclose(10646.562531, geo_res)
E       AssertionError: 
E       Not equal to tolerance rtol=1e-07, atol=0
E       
E       Mismatched elements: 1 / 1 (100%)
E       Max absolute difference: 0.09742581
E       Max relative difference: 9.15100108e-06
E        x: array(10646.562531)
E        y: array(10646.465105)

pyresample/test/test_geometry.py:1432: AssertionError

self = <pyresample.test.test_geometry.Test testMethod=test_cartopy_crs>

    def test_cartopy_crs(self):
        """Test conversion from area definition to cartopy crs."""
        europe = geometry.AreaDefinition(area_id='areaD',
                                         description='Europe (3km, HRV, VTC)',
                                         proj_id='areaD',
                                         projection={'a': '6378144.0',
                                                     'b': '6356759.0',
                                                     'lat_0': '50.00',
                                                     'lat_ts': '50.00',
                                                     'lon_0': '8.00',
                                                     'proj': 'stere'},
                                         width=800, height=800,
                                         area_extent=[-1370912.72,
                                                      -909968.64000000001,
                                                      1029087.28,
                                                      1490031.3600000001])
        seviri = geometry.AreaDefinition(area_id='seviri',
                                         description='SEVIRI HRIT like (flipped, south up)',
                                         proj_id='seviri',
                                         projection={'proj': 'geos',
                                                     'lon_0': 0.0,
                                                     'a': 6378169.00,
                                                     'b': 6356583.80,
                                                     'h': 35785831.00,
                                                     'units': 'm'},
                                         width=123, height=123,
                                         area_extent=[5500000, 5500000, -5500000, -5500000])

        for area_def in [europe, seviri]:
>           crs = area_def.to_cartopy_crs()

pyresample/test/test_geometry.py:120: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pyresample/geometry.py:1929: in to_cartopy_crs
    import cartopy.crs as ccrs
/usr/lib/python3/dist-packages/cartopy/__init__.py:107: in <module>
    import cartopy.crs  # noqa: E402  module-level imports
/usr/lib/python3/dist-packages/cartopy/crs.py:27: in <module>
    import cartopy.trace
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   ImportError: cannot import name lgeos

lib/cartopy/trace.pyx:56: ImportError

The latter is caused by Cartopy, see: https://github.com/SciTools/cartopy/issues/2076

djhoese commented 1 year ago

Could you provide more information about your environment? I have not tested against shapely 2.0, but the geocentric resolution test that is failing shouldn't be depending on shapely at all so I'm not sure why that test would have changed.

sebastic commented 1 year ago

Environment: Debian packages from unstable with python3-shapely (2.0~rc2-1~exp2) from experimental.

The test succeeds with python3-shapely (1.8.5-2) from Debian unstable.

sebastic commented 1 year ago

The build with shapely 1.8.5 was misleading, it used some older dependencies.

Changes between the last successful build and the failing one (both with Shapely 1.8.5):

Package Success Failure
glib2.0 2.74.1 2.74.2
proj 9.1.0 9.1.1
certifi 2022.6.15 2022.9.24
charset-normalizer 2.0.6 3.0.1
click 8.0.3 8.1.3
colorama 0.4.5 0.4.6
sphinx 4.5.0 5.3.0
xarray 2022.11.0 2022.12.0

test_area_def_geocentric_resolution also fails in a bookworm environment, which suggest that the recent update of proj to 9.1.1 caused the issue. Increasing the tolerance may suffice to resolve the issue.