diff --git a/.gitignore b/.gitignore index 4318043..403472c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ __pycache__/ *.py[cod] *$py.class +.ruff_cache # C extensions *.so diff --git a/yaff/common_likelihoods.py b/yaff/common_likelihoods.py index 6cf0e0d..73e9ed4 100644 --- a/yaff/common_likelihoods.py +++ b/yaff/common_likelihoods.py @@ -65,6 +65,11 @@ def chi2_likelihood(data: fitting.DataPacket, model: np.ndarray): # Some count bins might be negative, or have zero error, # so use nan_to_num - return -np.nan_to_num((numerator / total_sq_err)[restriction]).sum() + return -np.nan_to_num( + (numerator / total_sq_err)[restriction], + nan=0, + neginf=0, + posinf=0 + ).sum() return chi2_likelihood