Skip to content

Commit e08112f

Browse files
committed
fix "RuntimeWarning: invalid value encountered in sqrt" issue #11
1 parent 91f7796 commit e08112f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

azint/azint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ def integrate(self,
306306
errors_2d = None
307307
if self.error_model:
308308
# poisson error model
309-
errors = np.sqrt(self.sparse_matrix.spmv_corrected2(img)).reshape(self.output_shape)
309+
sparse = np.clip(self.sparse_matrix.spmv_corrected2(img), a_min=0, a_max=None)
310+
errors = np.sqrt(sparse).reshape(self.output_shape)
310311
if self.normalized:
311312
errors = np.divide(errors, norm, out=np.zeros_like(errors), where=norm!=0.0)
312313

0 commit comments

Comments
 (0)