Commit 76bc86d
committed
Distinguish explicit gpu=True vs auto-detected in fallback warning
Two Copilot review notes on PR #1678:
1. The fallback warning at to_geotiff(..., gpu=True) dispatch hard-coded
"to_geotiff(gpu=True) fell back to CPU" even when GPU was reached
through the auto-detect branch (gpu is None and the data is CuPy).
That tells the caller their explicit flag was dropped when they
never set one, pointing them at the wrong knob. Capture
auto_detected_gpu = (gpu is None) before resolving use_gpu and pick
the wording in a single helper so the ImportError and
RuntimeError branches stay in lockstep.
2. The inline comment on the ImportError branch claimed
"cupy or nvCOMP not installed" but write_geotiff_gpu only raises
ImportError for missing cupy. nvCOMP unavailability is handled
inside _try_nvcomp_from_device_bufs (returns None, triggering CPU
compression internally), so it never reaches this except block.
Reworded the comment to match the actual code path.
Tests:
- Updated existing explicit-gpu assertions to pin the new template.
- Strengthened the auto-detect test with full text assertions.
- Added test_auto_detected_gpu_runtime_error_falls_back_with_warning
to confirm both branches use the same template under auto-detect.
- Added test_explicit_gpu_false_then_true_uses_explicit_template
to pin that template selection follows gpu is None, not use_gpu
(so gpu=True on numpy data still gets the explicit wording).
Narrowing logic and strict-mode (XRSPATIAL_GEOTIFF_STRICT) behaviour
are unchanged.1 parent 97666cc commit 76bc86d
2 files changed
Lines changed: 145 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
106 | 130 | | |
107 | 131 | | |
108 | 132 | | |
| |||
1132 | 1156 | | |
1133 | 1157 | | |
1134 | 1158 | | |
1135 | | - | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
1136 | 1164 | | |
1137 | 1165 | | |
1138 | 1166 | | |
| |||
1171 | 1199 | | |
1172 | 1200 | | |
1173 | 1201 | | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1178 | 1211 | | |
1179 | 1212 | | |
1180 | 1213 | | |
1181 | | - | |
1182 | | - | |
| 1214 | + | |
1183 | 1215 | | |
1184 | 1216 | | |
1185 | 1217 | | |
| |||
1201 | 1233 | | |
1202 | 1234 | | |
1203 | 1235 | | |
1204 | | - | |
1205 | | - | |
| 1236 | + | |
1206 | 1237 | | |
1207 | 1238 | | |
1208 | 1239 | | |
| |||
Lines changed: 105 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
144 | 148 | | |
145 | | - | |
| 149 | + | |
146 | 150 | | |
147 | 151 | | |
148 | 152 | | |
| |||
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
198 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
| |||
215 | 224 | | |
216 | 225 | | |
217 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
218 | 242 | | |
219 | 243 | | |
220 | 244 | | |
221 | 245 | | |
222 | 246 | | |
223 | 247 | | |
224 | 248 | | |
225 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
226 | 252 | | |
227 | 253 | | |
228 | 254 | | |
| |||
234 | 260 | | |
235 | 261 | | |
236 | 262 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 263 | + | |
247 | 264 | | |
248 | 265 | | |
249 | 266 | | |
| |||
257 | 274 | | |
258 | 275 | | |
259 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
0 commit comments