Commit 641d74a
authored
QA/QC: align sieve with GDAL and add parity tests (#1169)
* Fix OOM in visibility module for dask-backed rasters
_extract_transect was calling .compute() on the full dask array just to
read a handful of transect cells. Now uses vindex fancy indexing so only
the relevant chunks are materialized.
cumulative_viewshed was allocating a full-size np.zeros count array and
calling .values on each viewshed result, forcing materialization every
iteration. Now accumulates lazily with da.zeros and dask array addition
when the input is dask-backed.
* Tighten viewshed Tier B memory estimate and avoid needless copy
The dask Tier B memory guard underestimated peak usage at 280 bytes/pixel.
Actual peak during lexsort reaches ~360 bytes/pixel (sorted + unsorted
event_list coexist) plus 8 bytes/pixel for the computed raster. Updated
estimate to 368 bytes/pixel to prevent borderline OOM.
Also use astype(copy=False) to skip the float64 copy when data is already
float64.
* Add sieve GDAL parity tests (#1168)
Cross-validates xrspatial.sieve() against rasterio.features.sieve()
(GDAL wrapper) on identical inputs. 30 tests covering thresholds,
connectivity modes, nodata, dtypes, and edge cases.
Documents one behavioral difference: GDAL runs a single pass while
xrspatial iterates. When all regions are below threshold, GDAL leaves
the raster unchanged; xrspatial cascades merges to convergence.
* Drop Author of Proposal from issue template (#1168)
GitHub already shows who opened an issue. Removed the field from the
feature-proposal template and updated the rockout command to note it
should be skipped.
* Align sieve with GDAL single-pass semantics (#1168)
GDAL's sieve only merges a small region into a neighbor whose size
is already >= threshold. If no such neighbor exists, the region stays.
Previously xrspatial iterated up to 50 passes and merged into any
neighbor regardless of its size, causing cascading merges that GDAL
does not perform.
Changes:
- _sieve_numpy: remove iteration loop, filter merge targets to
neighbors >= threshold
- Remove _MAX_ITERATIONS and convergence warning (single pass
always completes)
- Update docstrings to document GDAL-matching semantics
- Update tests: checkerboard/stripe/all-small-regions cases now
correctly leave the raster unchanged
- All 30 GDAL parity tests now assert exact equality1 parent 26bde73 commit 641d74a
File tree
5 files changed
+571
-104
lines changed- .claude/commands
- .github/ISSUE_TEMPLATE
- xrspatial
- tests
5 files changed
+571
-104
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | | - | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
208 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
241 | 248 | | |
242 | | - | |
243 | | - | |
244 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
245 | 252 | | |
246 | | - | |
247 | | - | |
248 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
249 | 259 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
254 | 263 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
264 | 268 | | |
265 | | - | |
266 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
267 | 277 | | |
268 | | - | |
| 278 | + | |
269 | 279 | | |
270 | 280 | | |
271 | 281 | | |
| |||
277 | 287 | | |
278 | 288 | | |
279 | 289 | | |
280 | | - | |
| 290 | + | |
281 | 291 | | |
282 | 292 | | |
283 | | - | |
| 293 | + | |
284 | 294 | | |
285 | 295 | | |
286 | 296 | | |
| |||
320 | 330 | | |
321 | 331 | | |
322 | 332 | | |
323 | | - | |
| 333 | + | |
324 | 334 | | |
325 | 335 | | |
326 | | - | |
| 336 | + | |
327 | 337 | | |
328 | 338 | | |
329 | 339 | | |
| |||
345 | 355 | | |
346 | 356 | | |
347 | 357 | | |
348 | | - | |
| 358 | + | |
349 | 359 | | |
350 | 360 | | |
351 | | - | |
| 361 | + | |
352 | 362 | | |
353 | 363 | | |
354 | 364 | | |
| |||
367 | 377 | | |
368 | 378 | | |
369 | 379 | | |
370 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
371 | 384 | | |
372 | 385 | | |
373 | 386 | | |
| |||
417 | 430 | | |
418 | 431 | | |
419 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
420 | 438 | | |
421 | 439 | | |
422 | 440 | | |
| |||
442 | 460 | | |
443 | 461 | | |
444 | 462 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 463 | + | |
448 | 464 | | |
449 | | - | |
450 | | - | |
451 | | - | |
| 465 | + | |
452 | 466 | | |
453 | 467 | | |
454 | | - | |
| 468 | + | |
455 | 469 | | |
456 | 470 | | |
457 | 471 | | |
458 | | - | |
459 | | - | |
460 | | - | |
| 472 | + | |
461 | 473 | | |
462 | 474 | | |
463 | 475 | | |
464 | 476 | | |
465 | 477 | | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | 478 | | |
475 | 479 | | |
476 | 480 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
| 119 | + | |
121 | 120 | | |
122 | 121 | | |
123 | 122 | | |
| |||
425 | 424 | | |
426 | 425 | | |
427 | 426 | | |
428 | | - | |
| 427 | + | |
429 | 428 | | |
430 | 429 | | |
431 | 430 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
| 431 | + | |
| 432 | + | |
438 | 433 | | |
439 | 434 | | |
440 | | - | |
441 | | - | |
442 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
443 | 439 | | |
444 | 440 | | |
445 | 441 | | |
446 | 442 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
451 | 447 | | |
452 | 448 | | |
453 | 449 | | |
| |||
486 | 482 | | |
487 | 483 | | |
488 | 484 | | |
489 | | - | |
| 485 | + | |
490 | 486 | | |
491 | 487 | | |
492 | 488 | | |
| |||
498 | 494 | | |
499 | 495 | | |
500 | 496 | | |
501 | | - | |
502 | | - | |
| 497 | + | |
| 498 | + | |
0 commit comments