Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with PROJ 9.2 #2193

Closed
sebastic opened this issue Jun 13, 2023 · 4 comments · Fixed by #2209
Closed

Test failures with PROJ 9.2 #2193

sebastic opened this issue Jun 13, 2023 · 4 comments · Fixed by #2209
Milestone

Comments

@sebastic
Copy link

Description

The Debian package fails with to build with PROJ 9.2.1 due to test failures:

=================================== FAILURES ===================================
______________________________ TestCRS.test_epsg _______________________________

self = <cartopy.tests.test_crs.TestCRS object at 0x7f23457c28d0>

    def test_epsg(self):
        uk = ccrs.epsg(27700)
        assert uk.epsg_code == 27700
>       assert_almost_equal(uk.x_limits, (-104009.357, 688806.007), decimal=3)

cartopy/tests/test_crs.py:92: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233e4c0f40>, (-104728.76470291585, 688806.0073395604), (-104009.357, 688806.007))
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: 1 / 2 (50%)
E           Max absolute difference: 719.40770292
E           Max relative difference: 0.00691676
E            x: array([-104728.765,  688806.007])
E            y: array([-104009.357,  688806.007])

/usr/lib/python3.11/contextlib.py:81: AssertionError
______________________ TestEquidistantConic.test_default _______________________

self = <cartopy.tests.crs.test_equidistant_conic.TestEquidistantConic object at 0x7f233f8a4750>

    def test_default(self):
        eqdc = ccrs.EquidistantConic()
        other_args = {'ellps=WGS84', 'lon_0=0.0', 'lat_0=0.0', 'x_0=0.0',
                      'y_0=0.0', 'lat_1=20.0', 'lat_2=50.0'}
        check_proj_params('eqdc', eqdc, other_args)
    
>       assert_almost_equal(np.array(eqdc.x_limits),
                            (-22784919.35600352, 22784919.35600352),
                            decimal=7)

cartopy/tests/crs/test_equidistant_conic.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233e386160>, array([-22784919.35599817,  22784919.35599817]), (-22784919.35600352, 22784919.35600352))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 7 decimals', 'precision': 7, '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 7 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 5.34579158e-06
E           Max relative difference: 2.34619728e-13
E            x: array([-22784919.3559982,  22784919.3559982])
E            y: array([-22784919.3560035,  22784919.3560035])

/usr/lib/python3.11/contextlib.py:81: AssertionError
__________________ TestEquidistantConic.test_eccentric_globe ___________________

self = <cartopy.tests.crs.test_equidistant_conic.TestEquidistantConic object at 0x7f233f8a7b10>

    def test_eccentric_globe(self):
        globe = ccrs.Globe(semimajor_axis=1000, semiminor_axis=500,
                           ellipse=None)
        eqdc = ccrs.EquidistantConic(globe=globe)
        other_args = {'a=1000', 'b=500', 'lon_0=0.0', 'lat_0=0.0', 'x_0=0.0',
                      'y_0=0.0', 'lat_1=20.0', 'lat_2=50.0'}
        check_proj_params('eqdc', eqdc, other_args)
    
>       assert_almost_equal(np.array(eqdc.x_limits),
                            (-3016.869847713461, 3016.869847713461),
                            decimal=7)

cartopy/tests/crs/test_equidistant_conic.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233e3867a0>, array([-2960.1009481,  2960.1009481]), (-3016.869847713461, 3016.869847713461))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 7 decimals', 'precision': 7, '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 7 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 56.76889961
E           Max relative difference: 0.01881715
E            x: array([-2960.1009481,  2960.1009481])
E            y: array([-3016.8698477,  3016.8698477])

/usr/lib/python3.11/contextlib.py:81: AssertionError
________________ TestEquidistantConic.test_ellipsoid_transform _________________

self = <cartopy.tests.crs.test_equidistant_conic.TestEquidistantConic object at 0x7f233f8a5b90>

    def test_ellipsoid_transform(self):
        # USGS Professional Paper 1395, pp 299--300
        globe = ccrs.Globe(semimajor_axis=6378206.4,
                           flattening=1 - np.sqrt(1 - 0.00676866),
                           ellipse=None)
        lat_1 = 29.5
        lat_2 = 45.5
        eqdc = ccrs.EquidistantConic(central_latitude=23.0,
                                     central_longitude=-96.0,
                                     standard_parallels=(lat_1, lat_2),
                                     globe=globe)
        geodetic = eqdc.as_geodetic()
    
        other_args = {'a=6378206.4', 'f=0.003390076308689371', 'lon_0=-96.0',
                      'lat_0=23.0', 'x_0=0.0', 'y_0=0.0', 'lat_1=29.5',
                      'lat_2=45.5'}
        check_proj_params('eqdc', eqdc, other_args)
    
>       assert_almost_equal(np.array(eqdc.x_limits),
                            (-22421870.719894886, 22421870.719894886),
                            decimal=7)

cartopy/tests/crs/test_equidistant_conic.py:131: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233d144cc0>, array([-22421870.71988974,  22421870.71988976]), (-22421870.719894886, 22421870.719894886))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 7 decimals', 'precision': 7, '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 7 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 5.14835119e-06
E           Max relative difference: 2.29612919e-13
E            x: array([-22421870.7198897,  22421870.7198898])
E            y: array([-22421870.7198949,  22421870.7198949])

/usr/lib/python3.11/contextlib.py:81: AssertionError
__________ Test_LambertConformal_standard_parallels.test_single_spole __________

self = <cartopy.tests.crs.test_lambert_conformal.Test_LambertConformal_standard_parallels object at 0x7f233f679210>

    def test_single_spole(self):
        s_pole_crs = ccrs.LambertConformal(standard_parallels=[-1.])
>       assert_array_almost_equal(s_pole_crs.x_limits,
                                  (-19939660, 19939660),
                                  decimal=0)

cartopy/tests/crs/test_lambert_conformal.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233e4c0e00>, (-19840440.929965686, 19840440.92996561), (-19939660, 19939660))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 0 decimals', 'precision': 0, '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 0 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 99219.07003439
E           Max relative difference: 0.00497597
E            x: array([-19840441.,  19840441.])
E            y: array([-19939660,  19939660])

/usr/lib/python3.11/contextlib.py:81: AssertionError
__________ Test_LambertConformal_standard_parallels.test_single_npole __________

self = <cartopy.tests.crs.test_lambert_conformal.Test_LambertConformal_standard_parallels object at 0x7f233f67b610>

    def test_single_npole(self):
        n_pole_crs = ccrs.LambertConformal(standard_parallels=[1.])
>       assert_array_almost_equal(n_pole_crs.x_limits,
                                  (-20130569, 20130569),
                                  decimal=0)

cartopy/tests/crs/test_lambert_conformal.py:80: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233d1ae020>, (-20222156.420383506, 20222156.420383424), (-20130569, 20130569))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 0 decimals', 'precision': 0, '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 0 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 91587.42038351
E           Max relative difference: 0.00454967
E            x: array([-20222156.,  20222156.])
E            y: array([-20130569,  20130569])

/usr/lib/python3.11/contextlib.py:81: AssertionError
_____________________ TestSinusoidal.test_eccentric_globe ______________________

self = <cartopy.tests.crs.test_sinusoidal.TestSinusoidal object at 0x7f233f6695d0>

    def test_eccentric_globe(self):
        globe = ccrs.Globe(semimajor_axis=1000, semiminor_axis=500,
                           ellipse=None)
        crs = ccrs.Sinusoidal(globe=globe)
        other_args = {'a=1000', 'b=500', 'lon_0=0.0', 'x_0=0.0', 'y_0=0.0'}
        check_proj_params('sinu', crs, other_args)
    
        assert_almost_equal(np.array(crs.x_limits),
                            [-3141.59, 3141.59], decimal=2)
>       assert_almost_equal(np.array(crs.y_limits),
                            [-1216.60, 1216.60], decimal=2)

cartopy/tests/crs/test_sinusoidal.py:37: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7f233e3d1580>, array([-1211.05573766,  1211.05573766]), [-1216.6, 1216.6])
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 2 decimals', 'precision': 2, '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 2 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 5.54426234
E           Max relative difference: 0.00455718
E            x: array([-1211.06,  1211.06])
E            y: array([-1216.6,  1216.6])

/usr/lib/python3.11/contextlib.py:81: AssertionError
=============================== warnings summary ===============================
.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py::TestCRS::test_osgb[True]
.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py::TestCRS::test_osgb[False]
  /build/python-cartopy-0.21.1+dfsg/.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py:61: UserWarning: uk_os_OSTN15_NTv2_OSGBtoETRS.tif is unavailable; testing OSGB at reduced precision
    warnings.warn(f'{grid_name} is unavailable; '

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED cartopy/tests/test_crs.py::TestCRS::test_epsg - AssertionError: 
FAILED cartopy/tests/crs/test_equidistant_conic.py::TestEquidistantConic::test_default
FAILED cartopy/tests/crs/test_equidistant_conic.py::TestEquidistantConic::test_eccentric_globe
FAILED cartopy/tests/crs/test_equidistant_conic.py::TestEquidistantConic::test_ellipsoid_transform
FAILED cartopy/tests/crs/test_lambert_conformal.py::Test_LambertConformal_standard_parallels::test_single_spole
FAILED cartopy/tests/crs/test_lambert_conformal.py::Test_LambertConformal_standard_parallels::test_single_npole
FAILED cartopy/tests/crs/test_sinusoidal.py::TestSinusoidal::test_eccentric_globe
= 7 failed, 577 passed, 3 skipped, 186 deselected, 2 xfailed, 2 xpassed, 2 warnings in 26.27s =

Operating system

Debian unstable

Cartopy version

0.21.1

@QuLogic
Copy link
Member

QuLogic commented Jun 13, 2023

Duplicate of #2145? You can backport #2163 to fix it.

@sebastic
Copy link
Author

When I apply the changes from #2163 there two different test failures with PROJ 9.2.1:

=================================== FAILURES ===================================
__________ Test_LambertConformal_standard_parallels.test_single_spole __________

self = <cartopy.tests.crs.test_lambert_conformal.Test_LambertConformal_standard_parallels object at 0x7fe5c8a21890>

    def test_single_spole(self):
        s_pole_crs = ccrs.LambertConformal(standard_parallels=[-1.])
>       assert_array_almost_equal(s_pole_crs.x_limits,
                                  (-19939660, 19939660),
                                  decimal=0)

cartopy/tests/crs/test_lambert_conformal.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7fe5c37e44a0>, (-19840440.929965686, 19840440.92996561), (-19939660, 19939660))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 0 decimals', 'precision': 0, '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 0 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 99219.07003439
E           Max relative difference: 0.00497597
E            x: array([-19840441.,  19840441.])
E            y: array([-19939660,  19939660])

/usr/lib/python3.11/contextlib.py:81: AssertionError
__________ Test_LambertConformal_standard_parallels.test_single_npole __________

self = <cartopy.tests.crs.test_lambert_conformal.Test_LambertConformal_standard_parallels object at 0x7fe5c8a22590>

    def test_single_npole(self):
        n_pole_crs = ccrs.LambertConformal(standard_parallels=[1.])
>       assert_array_almost_equal(n_pole_crs.x_limits,
                                  (-20130569, 20130569),
                                  decimal=0)

cartopy/tests/crs/test_lambert_conformal.py:80: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3.11/contextlib.py:81: in inner
    return func(*args, **kwds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<function assert_array_almost_equal.<locals>.compare at 0x7fe5c24c4720>, (-20222156.420383506, 20222156.420383424), (-20130569, 20130569))
kwds = {'err_msg': '', 'header': 'Arrays are not almost equal to 0 decimals', 'precision': 0, '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 0 decimals
E           
E           Mismatched elements: 2 / 2 (100%)
E           Max absolute difference: 91587.42038351
E           Max relative difference: 0.00454967
E            x: array([-20222156.,  20222156.])
E            y: array([-20130569,  20130569])

/usr/lib/python3.11/contextlib.py:81: AssertionError
=============================== warnings summary ===============================
.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py::TestCRS::test_osgb[True]
.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py::TestCRS::test_osgb[False]
.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py::TestCRS::test_epsg
  /build/python-cartopy-0.21.1+dfsg/.pybuild/cpython3_3.11_cartopy/build/cartopy/tests/test_crs.py:61: UserWarning: uk_os_OSTN15_NTv2_OSGBtoETRS.tif is unavailable; testing OSGB at reduced precision
    warnings.warn(f'{grid_name} is unavailable; '

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED cartopy/tests/crs/test_lambert_conformal.py::Test_LambertConformal_standard_parallels::test_single_spole
FAILED cartopy/tests/crs/test_lambert_conformal.py::Test_LambertConformal_standard_parallels::test_single_npole
= 2 failed, 582 passed, 3 skipped, 186 deselected, 2 xfailed, 2 xpassed, 3 warnings in 40.80s =

@sebastic sebastic reopened this Jun 14, 2023
@greglucas
Copy link
Contributor

@kirillrdy it looks like there might be a few more tests to update in addition to your previous PROJ 9.2 test changes if you're interested in opening another PR for those ones too.

@kirillrdy
Copy link
Contributor

@greglucas I'll have a look, I wonder why CI on our side didn't pick it up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants