Closed gillins closed 7 months ago
Oh, and P.S. Last night I did do a wander through GDAL's code, and it looks like these functions go way back. I didn't find the original commit, but certainly into gdal 2.x somewhere, so I think that is good enough.
Do you have the PYTHONWARNINGS
env var set? I can't seem to trigger the warning unless this is set (or -W
). Thanks for the stacklevel=2 though - very useful.
Interesting that we missed this being in GDAL the whole time.
That's weird about the warnings. No, I don't think I have that set, or anything similar. I have pasted in the test script, and the output, below.
#!/usr/bin/env python
import warnings
import numpy
from rios import imageio
def main():
f()
def f():
print(imageio.GDALTypeToNumpyType(1))
print()
print(imageio.NumpyTypeToGDALType(numpy.uint8))
if __name__ == "__main__":
main()
Output is
$ ./testwarn.py
/home/neil/tmp/./testwarn.py:11: DeprecationWarning: Future versions of RIOS may remove this function. Use gdal_array.GDALTypeCodeToNumericTypeCode instead
print(imageio.GDALTypeToNumpyType(1))
<class 'numpy.uint8'>
/home/neil/tmp/./testwarn.py:13: DeprecationWarning: Future versions of RIOS may remove this function. Use gdal_array.NumericTypeCodeToGDALTypeCode instead
print(imageio.NumpyTypeToGDALType(numpy.uint8))
1
I just ran that - no warnings for me (without PYTHONWARNINGS). What version of Python are you using? I'm on 3.11. Doesn't really matter I guess - I don't think there is another mechanism.
How very odd.
$ python -V
Python 3.12.1
And my environment is clean of any variable like that
$ env | grep PYTHON
CONDA_PYTHON_EXE=/home/neil/miniconda3/bin/python
I don't know what is going on.
Yes, doesn't matter too much, I guess. I doubt there are many people who actually used our version of such a function.
of our own versions. Issue a
DeprecationWarning
if anyone tries to use these functions. You have to invoke Python with-W error
to get these warnings of course, which is annoying.Hasn't been heavily tested, but can you see any problems @neilflood ?