From 742b306aa74bbb92094843d42542e43b03e3b71d Mon Sep 17 00:00:00 2001 From: Tyler Cox Date: Wed, 19 Feb 2025 00:50:51 -0800 Subject: [PATCH] ignore divide by zero warnings --- hera_filters/dspec.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hera_filters/dspec.py b/hera_filters/dspec.py index 5a7883f..55a32f9 100644 --- a/hera_filters/dspec.py +++ b/hera_filters/dspec.py @@ -2981,14 +2981,15 @@ def sparse_linear_fit_2D( if precondition_solver: # Compute separate preconditioners for the two axes # Start by computing separable weights for the two axes - axis_1_wgts = np.nanmean( - np.where(weights == 0, np.nan, weights), - axis=1, keepdims=True - ) - axis_2_wgts = np.nanmean( - np.where(weights == 0, np.nan, weights / axis_1_wgts), - axis=0, keepdims=True - ) + with np.errstate(invalid='ignore'): + axis_1_wgts = np.nanmean( + np.where(weights == 0, np.nan, weights), + axis=1, keepdims=True + ) + axis_2_wgts = np.nanmean( + np.where(weights == 0, np.nan, weights / axis_1_wgts), + axis=0, keepdims=True + ) axis_1_wgts[~np.isfinite(axis_1_wgts)] = 0.0 axis_2_wgts[~np.isfinite(axis_2_wgts)] = 0.0 axis_1_wgts = np.squeeze(axis_1_wgts)