Skip to content

Commit

Permalink
r.vif: bugfix (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecodiv authored Oct 21, 2024
1 parent b24bf40 commit 8664278
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/raster/r.vif/r.vif.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# VIF. This will be repeated till the VIF falls below the user
# defined VIF threshold value.
#
# COPYRIGHT: (C) 2015 - 2022 Paulo van Breugel and the GRASS Development Team
# COPYRIGHT: (C) 2015 - 2024 Paulo van Breugel and the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
Expand Down Expand Up @@ -215,8 +215,10 @@ def compute_vif(mapx, mapy):
x_i = np.hstack((mapx, np.ones((mapx.shape[0], 1))))
unused, resid = np.linalg.lstsq(x_i, mapy, rcond=None)[:2]
if resid.size == 0:
resid = 0
r2 = float(1 - resid[0] / (mapy.size * mapy.var()))
resid_value = 0
else:
resid_value = resid[0]
r2 = float(1 - resid_value / (mapy.size * mapy.var()))
if float(r2) > 0.9999999999:
vif = float("inf")
sqrtvif = float("inf")
Expand Down

0 comments on commit 8664278

Please sign in to comment.