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_geod_inverse_transform fails on 64bit PowerPC architectures #849

Closed
sebastic opened this issue May 19, 2021 · 2 comments · Fixed by #852
Closed

test_geod_inverse_transform fails on 64bit PowerPC architectures #849

sebastic opened this issue May 19, 2021 · 2 comments · Fixed by #852
Labels

Comments

@sebastic
Copy link
Contributor

The Debian package build for 3.1rc0 failed on 64bit PowerPC architectures:

https://buildd.debian.org/status/package.php?p=python-pyproj&suite=experimental

From the ppc64el buildlog:

=================================== FAILURES ===================================
_________________________ test_geod_inverse_transform __________________________

    def test_geod_inverse_transform():
        gg = Geod(ellps="clrk66")
        lat1pt = 42.0 + (15.0 / 60.0)
        lon1pt = -71.0 - (7.0 / 60.0)
        lat2pt = 45.0 + (31.0 / 60.0)
        lon2pt = -123.0 - (41.0 / 60.0)
        """
        distance between boston and portland, clrk66:
        -66.531 75.654  4164192.708
        distance between boston and portland, WGS84:
        -66.530 75.654  4164074.239
        testing pickling of Geod instance
        distance between boston and portland, clrk66 (from pickle):
        -66.531 75.654  4164192.708
        distance between boston and portland, WGS84 (from pickle):
        -66.530 75.654  4164074.239
        inverse transform
        from proj.4 invgeod:
        b'-66.531\t75.654\t4164192.708\n'
    
        """
        true_az12 = -66.5305947876623
        true_az21 = 75.65363415556968
        print("from pyproj.Geod.inv:")
        az12, az21, dist = gg.inv(lon1pt, lat1pt, lon2pt, lat2pt)
        assert_almost_equal(
            (az12, az21, dist), (true_az12, true_az21, 4164192.708), decimal=3
        )
    
        print("forward transform")
        print("from proj.4 geod:")
        endlon, endlat, backaz = gg.fwd(lon1pt, lat1pt, az12, dist)
        assert_almost_equal(
            (endlon, endlat, backaz), (lon2pt, lat2pt, true_az21), decimal=3
        )
    
        inc_exc = ["excluding", "including"]
        res_az12_az21_dists_all = [
            (180.0, 0.0, 0.0),
            (-66.53059478766238, 106.79071710136431, 832838.5416198927),
            (-73.20928289863558, 99.32289055927389, 832838.5416198935),
            (-80.67710944072617, 91.36325611787134, 832838.5416198947),
            (-88.63674388212858, 83.32809401477382, 832838.5416198922),
            (-96.67190598522616, 75.65363415556973, 832838.5416198926),
        ]
        point_count = len(res_az12_az21_dists_all)
        for include_initial, include_terminus in itertools.product(
            (False, True), (False, True)
        ):
            initial_idx = int(not include_initial)
            terminus_idx = int(not include_terminus)
    
            npts = point_count - initial_idx - terminus_idx
            print("intermediate points:")
            print("from geod with +lat_1,+lon_1,+lat_2,+lon_2,+n_S:")
            print(f"{lat1pt:6.3f} {lon1pt:7.3f} {lat2pt:6.3f} {lon2pt:7.3f} {npts}")
    
            lonlats = gg.npts(
                lon1pt,
                lat1pt,
                lon2pt,
                lat2pt,
                npts,
                initial_idx=initial_idx,
                terminus_idx=terminus_idx,
            )
            assert len(lonlats) == npts
    
            npts1 = npts + initial_idx + terminus_idx - 1
            del_s = dist / npts1
            print(
                f"Total distnace is {dist}, "
                f"Points count: {npts}, "
                f"{inc_exc[include_initial]} initial point, "
                f"{inc_exc[include_terminus]} terminus point. "
                f"The distance between successive points is {dist}/{npts1} = {del_s}"
            )
    
            from_idx = initial_idx
            to_idx = point_count - terminus_idx
            res_az12_az21_dists = res_az12_az21_dists_all[from_idx:to_idx]
    
            lonprev = lon1pt
            latprev = lat1pt
            for (lon, lat), (res12, res21, resdist) in zip(lonlats, res_az12_az21_dists):
                o_az12, o_az21, o_dist = gg.inv(lonprev, latprev, lon, lat)
>               assert_almost_equal((o_az12, o_az21, o_dist), (res12, res21, resdist))
E               AssertionError: 
E               Arrays are not almost equal to 7 decimals
E               
E               Mismatched elements: 2 / 3 (66.7%)
E               Max absolute difference: 180.
E               Max relative difference: 1.
E                x: array([0.0000000e+00, 1.8000000e+02, 9.0976802e-10])
E                y: array([180.,   0.,   0.])

test/test_geod.py:135: AssertionError
----------------------------- Captured stdout call -----------------------------
from pyproj.Geod.inv:
forward transform
from proj.4 geod:
intermediate points:
from geod with +lat_1,+lon_1,+lat_2,+lon_2,+n_S:
42.250 -71.117 45.517 -123.683 4
Total distnace is 4164192.7080994667, Points count: 4, excluding initial point, excluding terminus point. The distance between successive points is 4164192.7080994667/5 = 832838.5416198934
intermediate points:
from geod with +lat_1,+lon_1,+lat_2,+lon_2,+n_S:
42.250 -71.117 45.517 -123.683 5
Total distnace is 4164192.7080994667, Points count: 5, excluding initial point, including terminus point. The distance between successive points is 4164192.7080994667/5 = 832838.5416198934
intermediate points:
from geod with +lat_1,+lon_1,+lat_2,+lon_2,+n_S:
42.250 -71.117 45.517 -123.683 5
Total distnace is 4164192.7080994667, Points count: 5, including initial point, excluding terminus point. The distance between successive points is 4164192.7080994667/5 = 832838.5416198934
=============================== warnings summary ===============================
.pybuild/cpython3_3.9_pyproj/build/test/test_datadir.py::test_get_data_dir__from_user[str]
.pybuild/cpython3_3.9_pyproj/build/test/test_datadir.py::test_get_data_dir__from_user[Path]
.pybuild/cpython3_3.9_pyproj/build/test/test_datadir.py::test_append_data_dir__internal[str]
.pybuild/cpython3_3.9_pyproj/build/test/test_datadir.py::test_append_data_dir__internal[Path]
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.9_pyproj/build/pyproj/datadir.py:37: UserWarning: pyproj unable to set database path.
    _global_context_set_data_dir()

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED test/test_geod.py::test_geod_inverse_transform - AssertionError: 
= 1 failed, 719 passed, 3 skipped, 59 deselected, 4 warnings in 162.11s (0:02:42) =
@sebastic sebastic added the bug label May 19, 2021
@snowman2
Copy link
Member

Thanks for the report @sebastic 👍

Likely related to #841

ping @idanmiara in case you have any ideas.

@idanmiara
Copy link
Contributor

Thanks for the report @sebastic 👍

Likely related to #841

ping @idanmiara in case you have any ideas.

I think it fails when comparing the az from the initial point to the first point in the result array, which is also the initial point. So it could be 0 or 180 or any other number.
I'll modify that test to fix it.

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

Successfully merging a pull request may close this issue.

3 participants