From e6307230d7655aee6e403f25a92f2812769dcb1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=BCreth?= <69197289+choROPeNt@users.noreply.github.com> Date: Mon, 23 Feb 2026 17:53:51 +0000 Subject: [PATCH] Prevent zero division by adding a minimum threshold Added a maximum function to prevent zero division in calculations. --- structure_tensor/st3d.py | 1 + 1 file changed, 1 insertion(+) diff --git a/structure_tensor/st3d.py b/structure_tensor/st3d.py index 4aff244..cfe8c62 100644 --- a/structure_tensor/st3d.py +++ b/structure_tensor/st3d.py @@ -257,6 +257,7 @@ def eig_special_3d( l = lib.einsum("ij,ij->j", vec, vec, out=vec_tmp) lib.sqrt(l, out=l) + lib.maximum(l, 1e-12, out=l) # prevent zero division vec /= l val = val.reshape(val.shape[:-1] + input_shape[1:])