pyproj4 / pyproj

Python interface to PROJ (cartographic projections and coordinate transformations library)
https://pyproj4.github.io/pyproj
MIT License
1.04k stars 210 forks source link

test failure in test_crs_cf.py #1387

Closed jdkloe closed 5 months ago

jdkloe commented 5 months ago

Problem description

pyproj v3.6.1 works and tests just fine on fedora 39 and 40. But when I try build build it for fedora 41 I get one failure during the test run.

=================================== FAILURES ===================================
__________________________ test_azimuthal_equidistant __________________________

    def test_azimuthal_equidistant():
        crs = CRS("ESRI:54032")
        expected_cf = {
            "semi_major_axis": 6378137.0,
            "semi_minor_axis": crs.ellipsoid.semi_minor_metre,
            "inverse_flattening": crs.ellipsoid.inverse_flattening,
            "reference_ellipsoid_name": "WGS 84",
            "longitude_of_prime_meridian": 0.0,
            "prime_meridian_name": "Greenwich",
            "geographic_crs_name": "WGS 84",
            "horizontal_datum_name": "World Geodetic System 1984",
            "projected_crs_name": "World_Azimuthal_Equidistant",
            "grid_mapping_name": "azimuthal_equidistant",
            "latitude_of_projection_origin": 0.0,
            "longitude_of_projection_origin": 0.0,
            "false_easting": 0.0,
            "false_northing": 0.0,
        }
        cf_dict = crs.to_cf()
        assert cf_dict.pop("crs_wkt").startswith("PROJCRS[")
>       assert cf_dict == expected_cf
E       AssertionError: assert {} == {'false_easti...distant', ...}
E         Right contains 14 more items:
E         {'false_easting': 0.0,
E          'false_northing': 0.0,
E          'geographic_crs_name': 'WGS 84',
E          'grid_mapping_name': 'azimuthal_equidistant',
E          'horizontal_datum_name': 'World Geodetic System 1984',
E          'inverse_flattening': 298.257223563,...
E         
E         ...Full output truncated (9 lines hidden), use '-vv' to show

test/crs/test_crs_cf.py:1206: AssertionError

Also if I replay this test on the python command prompt I see the problem:

>>> from pyproj import CRS
>>> crs = CRS("ESRI:54032")
>>> cf_dict = crs.to_cf()
>>> cf_dict.pop("crs_wkt").startswith("PROJCRS[")
True
>>> cf_dict
{}
>>> 

While according to the test definition there should be content in this cf_dict.

Looking at the code in _crs.pyx I see that the result from the to_cf() method depends on inspecting self.name. In my failing environment I see the following value:

>>> crs.name
'World_Azimuthal_Equidistant'

And this does not match with any of the if statements in the to_cf() method . I am not familiar enough with this code to understand why that is the case.

Expected Output

the test should pass

Environment Information

Fedora 41/rawhide mock test environment.

python3 -m pyproj -v

pyproj info: pyproj: 3.6.1 PROJ: 9.4.0 data dir: /usr/share/proj user_data_dir: /builddir/.local/share/proj PROJ DATA (recommended version): 1.17 PROJ Database: 1.3 EPSG Database: v11.004 [2024-02-24] ESRI Database: ArcGIS Pro 3.2 [2023-11-02] IGNF Database: 3.1.0 [2019-05-24]

System: python: 3.12.2 (main, Feb 21 2024, 00:00:00) [GCC 14.0.1 20240217 (Red Hat 14.0.1-0)] executable: /usr/bin/python3 machine: Linux-6.7.7-200.fc39.x86_64-x86_64-with-glibc2.39.9000

Python deps: certifi: 2023.5.7 Cython: 3.0.8 setuptools: 69.0.3 pip: None

Installation method

from source

jdkloe commented 5 months ago

Looking at the crs.to_json_dict() that is called in the top of the to_cf() method if I print it using

import json
print(json.dumps(crs.to_json_dict(), indent=4))

I see a small difference:

fedora 39 output:

    "conversion": {
        "name": "World_Azimuthal_Equidistant",
        "method": {
            "name": "Modified Azimuthal Equidistant",
            "id": {
                "authority": "EPSG",
                "code": 9832
            }
        },

fedora 39 output:

    "conversion": {
        "name": "World_Azimuthal_Equidistant",
        "method": {
            "name": "Azimuthal Equidistant",
            "id": {
                "authority": "EPSG",
                "code": 1125
            }
        },

but I don't know if this is related.

snowman2 commented 5 months ago

Duplicate of #1384