-
Notifications
You must be signed in to change notification settings - Fork 215
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
numpy 1.25 warning on 1-element array input #1307
Comments
Thinking more about the extra |
I agree that no code change and recommend users apply a warning filter sounds like the best course of action. Side note: Mind making an issue to remove the hacks we put in place due to the current numpy conversion to double in a future version of pyproj? |
Opened the new issue. Lets close this issue then and move the conversation back to Cartopy @neutrinoceros. Sorry for pointing you all over the place here! |
no worries ! I understand this issue is more subtle than most :-) |
For others: The new issue is #1309 |
Quick question just to be absolutely sure how to deal with this warning since I'm still a bit confused... Am I right that the recommendation here is to simply ignore this warning since upcoming releases of ...Or in other words: |
python -m pip install numpy --index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --pre
python -m pip install pyproj >>> import numpy
>>> import pyproj
>>> numpy.__version__
'2.0.0.dev0+git20240203.5c34c87'
>>> pyproj.__version__
'3.6.1'
>>> transformer = pyproj.Transformer.from_crs(4326, 3857, always_xy=True)
>>> transformer.transform(numpy.array([0]), numpy.array([0]))
(array([0.]), array([0.])) |
Code Sample, a copy-pastable example if possible
Problem description
Numpy 1.25 is now issuing a warning on auto-conversion of 1-element arrays to double. We have recently added a try-except for a fast-path on the transformer that tries the conversion and then catches the exception. However, this now also throws a warning, which we actually don't care about, but if running with
python -Werror script.py
it will raise.We can add the following filter to ignore these warnings within that block, but this adds a significant slowdown of ~5x for the single-point case.
single-point: ~10s
Another option is to catch all exceptions and then do the comparison test and re-raise within the exception block.
single-point: ~2s
I'm raising this issue to get thoughts and ideas on what would be the best way to handle this (maybe something other than those two ideas above). The patch should go in
geod
andtransformer
, I haven't looked in detail at other locations. This was originally raised over in Cartopy: SciTools/cartopy#2194 but seems like it should probably be addressed in Pyprojcc @neutrinoceros
Expected Output
No warnings using Numpy 1.25
Installation method
pip install -e .
The text was updated successfully, but these errors were encountered: