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

Conversion of array to scalar when transforming 1 element arrays leads to DeprecationWarning #1415

Closed
fmaussion opened this issue Jul 9, 2024 · 3 comments

Comments

@fmaussion
Copy link

Code Sample, a copy-pastable example if possible

import pyproj
trf = pyproj.Transformer.from_proj('EPSG:4326', 'EPSG:4326')
trf.transform(np.array([[1]]), np.array([[1]]))

Problem description

This code returns the correct output (arrays of dims [[]]) but throws a deprecation warning:

    trf.transform(np.array([[1]]), np.array([[1]]))
  File "/Users/uu23343/.mambaforge/envs/salem_env_202407/lib/python3.12/site-packages/pyproj/transformer.py", line 820, in transform
    return self._transformer._transform_point(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pyproj/_transformer.pyx", line 762, in pyproj._transformer._Transformer._transform_point
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

Expected Output

This should not send a deprecation I think? I don't want to turn this array into a scalar (and I'm not sure why pyproj does - perhaps for optimization?)

Environment Information

pyproj info:
    pyproj: 3.6.1
      PROJ: 9.4.0
  data dir: /Users/uu23343/.mambaforge/envs/salem_env_202407/share/proj
user_data_dir: /Users/uu23343/Library/Application Support/proj
PROJ DATA (recommended version): 1.18
PROJ Database: 1.3
EPSG Database: v11.006 [2024-03-13]
ESRI Database: ArcGIS Pro 3.3 [2024-05-07]
IGNF Database: 3.1.0 [2019-05-24]

System:
    python: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:11:10) [Clang 16.0.6 ]
executable: /Users/uu23343/.mambaforge/envs/salem_env_202407/bin/python
   machine: macOS-14.5-x86_64-i386-64bit

Python deps:
   certifi: 2024.7.4
    Cython: None
setuptools: 70.1.1
       pip: 24.0
@snowman2
Copy link
Member

snowman2 commented Jul 9, 2024

See #1307

@fmaussion
Copy link
Author

OK sorry I missed this. #1307 gives no context as to why numpy is raising this warning just for one version, but I did add a deprecation warning in our test suite for now...

@snowman2
Copy link
Member

snowman2 commented Jul 9, 2024

See #1309

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

No branches or pull requests

2 participants