Commit 672ebfc
authored
* Rename read_geotiff_gpu gpu kwarg to on_gpu_failure (#1560)
The kwarg shared a name with the boolean gpu= on open_geotiff /
to_geotiff / read_vrt but carried a different value space ('auto' or
'strict'). Calling read_geotiff_gpu(path, gpu=True) -- the natural
mental model after using open_geotiff(path, gpu=True) -- raised
"gpu must be 'auto' or 'strict', got True", obscuring the rename and
forcing readers to dig through the source to learn the correct values.
Rename to on_gpu_failure and keep gpu= as a deprecation shim:
- on_gpu_failure: canonical name, same {'auto', 'strict'} value space.
- gpu: still accepted; emits DeprecationWarning that points to the new
name and explains why the rename happened.
- Passing both raises TypeError to avoid silently picking one.
- Validation error message names on_gpu_failure so the rename is
discoverable from the traceback.
Existing test_gpu_strict_fallback_1516.py keeps using gpu='strict' via
the shim (with DeprecationWarning, as expected). One assertion that
hardcoded the old error string is updated to the new wording.
Module docstring updated to reference on_gpu_failure='strict' as the
example.
* Detect both-kwargs via sentinel in read_geotiff_gpu
Copilot caught a hole in the both-supplied check: the old guard
``if on_gpu_failure != 'auto'`` only fired when the new kwarg was
non-default, so calls like ``on_gpu_failure='auto', gpu='strict'`` (or
``on_gpu_failure='auto', gpu='auto'``) silently accepted the deprecated
value, contradicting the documented contract.
Use a sentinel for both kwargs so the both-supplied case is rejected
regardless of values. Add parametrized regression tests for the three
previously-silent value combinations.
Also widen the accepted-exceptions tuple in
test_gpu_alias_accepts_old_values_without_validation_error to include
ImportError, so it stays meaningful in CPU-only CI (where ``import
cupy`` raises after validation passes).
1 parent afb2e24 commit 672ebfc
3 files changed
Lines changed: 176 additions & 9 deletions
File tree
- xrspatial/geotiff
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
663 | 673 | | |
664 | 674 | | |
665 | 675 | | |
| |||
1813 | 1823 | | |
1814 | 1824 | | |
1815 | 1825 | | |
1816 | | - | |
| 1826 | + | |
| 1827 | + | |
1817 | 1828 | | |
1818 | 1829 | | |
1819 | 1830 | | |
| |||
1839 | 1850 | | |
1840 | 1851 | | |
1841 | 1852 | | |
1842 | | - | |
| 1853 | + | |
1843 | 1854 | | |
1844 | 1855 | | |
1845 | 1856 | | |
| |||
1859 | 1870 | | |
1860 | 1871 | | |
1861 | 1872 | | |
1862 | | - | |
1863 | | - | |
| 1873 | + | |
| 1874 | + | |
1864 | 1875 | | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
1865 | 1882 | | |
1866 | 1883 | | |
1867 | 1884 | | |
1868 | 1885 | | |
1869 | 1886 | | |
1870 | 1887 | | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
1871 | 1911 | | |
1872 | 1912 | | |
1873 | | - | |
| 1913 | + | |
1874 | 1914 | | |
1875 | 1915 | | |
1876 | 1916 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
263 | | - | |
264 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
265 | 272 | | |
266 | 273 | | |
267 | 274 | | |
0 commit comments