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

Incorrect behavior of geod.npts #1282

Closed
FactorizeD opened this issue May 4, 2023 · 6 comments · Fixed by #1288
Closed

Incorrect behavior of geod.npts #1282

FactorizeD opened this issue May 4, 2023 · 6 comments · Fixed by #1288
Labels
Milestone

Comments

@FactorizeD
Copy link

Hello,

This is my first post here, first and foremost I would like to thank you all for doing a fantastic work with this package:)

I am working on a project where pyproj is used and came across a strange behavior. I haven't checked every version to check where exactly did the issue start happening but it seems to be happening for the newest 3.5.0.

Consider the following:

import Geod

geod = Geod(ellps="WGS84")
geod.npts(np.nan, 1.0, 2.0, np.nan, npts=1)  # returns [(np.nan, 2.0)] ?!
geod.npts(1.0, 2.0, 3.0, np.nan, npts=1)  # returns [(1.0, 2.0)] ?!

Problem description

I would expect .npts to always return a tuple of nans when called on input containing nans. This however doesn't seem to be the case. I checked other possibilities with 2x np.nan or 1x np.nan in the input but only these two seem to be problematic.

Expected Output

[(np.nan, np.nan)] for both

Environment Information

pyproj info:
pyproj: 3.5.0
PROJ: 9.2.0
data dir: /usr/local/lib/python3.8/dist-packages/pyproj/proj_dir/share/proj
user_data_dir: /home/developer/.local/share/proj
PROJ DATA (recommended version): 1.13
PROJ Database: 1.2
EPSG Database: v10.082 [2023-02-06]
ESRI Database: ArcGIS Pro 3.1 [2023-19-01]
IGNF Database: 3.1.0 [2019-05-24]

System:
python: 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0]
executable: /usr/bin/python3
machine: Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.29

Python deps:
certifi: 2022.6.15
Cython: 0.29.14
setuptools: 58.4.0
pip: 23.1

Installation method

poetry inside docker

What do you think?

@FactorizeD FactorizeD added the bug label May 4, 2023
@snowman2
Copy link
Member

This change appears to be connected to #841.

With pyproj 3.0.1:

>>> import math
>>> from pyproj import Geod
>>> geod = Geod(ellps="WGS84")
>>> geod.npts(math.nan, 1.0, 2.0, math.nan, npts=1)
[(nan, nan)]

With pyproj 3.1.0:

>>> import math
>>> from pyproj import Geod
>>> geod = Geod(ellps="WGS84")
>>> geod.npts(math.nan, 1.0, 2.0, math.nan, npts=1)
[(nan, 0.9999999999999998)]

cc: @idanmiara

@snowman2
Copy link
Member

Possibly connected to this change as well: #825

@snowman2
Copy link
Member

e0b9453d29e7c9475467268d6838dac8503ab145 is the first bad commit
commit e0b9453d29e7c9475467268d6838dac8503ab145
Author: Idan Miara <idan@miara.com>
Date:   Mon May 10 13:45:25 2021 +0300

    pyproj/[geod.py, _geod.pyi, _geod.pyx] - add `fwd_intermediate`, `inv_intermediate` (improved version of `npts()`) functions; add `out_lons`, `out_lats` params to `npts()`; add examples and some more docs
    pyproj/enums.py, docs/api/enums.rst - add `GeodIntermediateFlag` flag
    test/test_geod.py - add tests for new functions

@snowman2
Copy link
Member

Seems the change started in #841

@snowman2
Copy link
Member

It seems the issue has to do with is_fwd being defined on whether the input is NaN:

bint is_fwd = isnan(lat2_or_nan)

@snowman2
Copy link
Member

Fix in #1288

@snowman2 snowman2 added this to the 3.6.0 milestone May 19, 2023
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.

2 participants