[GRASS-git] [OSGeo/grass-addons] 393a08: r.vif: preserve active MASK when read_data() exits...
Valyrian-Code
noreply at github.com
Tue Aug 4 23:10:30 PDT 2026
Branch: refs/heads/grass8
Home: https://github.com/OSGeo/grass-addons
Commit: 393a0885773182a87ff03d3965af2e4203de3e3b
https://github.com/OSGeo/grass-addons/commit/393a0885773182a87ff03d3965af2e4203de3e3b
Author: Rajveer* <irajveer.bishnoi2310 at gmail.com>
Date: 2026-08-05 (Wed, 05 Aug 2026)
Changed paths:
M src/raster/r.vif/r.vif.py
Log Message:
-----------
r.vif: preserve active MASK when read_data() exits with an error (#1715)
* r.vif: preserve active MASK when read_data() exits with an error
Track the backup mask name in a module-level variable instead of CLEAN_RAST,
and restore it from cleanup() before the temp-map removal loop so MASK
survives crashes during r.stats / numpy processing. If a MASK already
exists at restore time (left over from the internal r.mask call), remove
it first; at cleanup time any MASK present is one r.vif created itself.
Also wrap the r.stats/numpy block in try/finally so the internal mask is
removed and the backup restored on the normal-exception path.
Fixes #1702
* r.vif: apply ruff formatting
* r.vif: use MaskManager on GRASS 8.5+ for the sampling mask
On 8.5+ (MaskManager available), apply the random-sample mask via a
MaskManager context. It restores the user's MASK automatically on exit,
including on error, and removes the internal mask, so no manual backup or
rename is needed there. The sample is drawn before entering the context so it
still respects an active user MASK, matching the 8.4 path.
The manual backup/restore path is kept for 8.4 compatibility, selected by
trying to import grass.script.MaskManager. Addresses @wenzeslaus's review.
To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass-addons/settings/notifications
More information about the grass-commit
mailing list