Skip to content

Commit

Permalink
ignore divide by zero warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-a-cox committed Feb 19, 2025
1 parent 121e7d0 commit 742b306
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hera_filters/dspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 742b306

Please sign in to comment.