Skip to content
Snippets Groups Projects
Commit b848b3d2 authored by Robert Applin's avatar Robert Applin
Browse files

Refs #21401. Avoid divide by zero

parent 09971f26
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,13 @@ def _normalize_by_index(workspace, index): ...@@ -27,8 +27,13 @@ def _normalize_by_index(workspace, index):
y_values = workspace.readY(idx) y_values = workspace.readY(idx)
y_errors = workspace.readE(idx) y_errors = workspace.readE(idx)
# Avoid divide by zero
if y_values[index] == 0.0:
scale = np.reciprocal(1.0e-8)
else:
scale = np.reciprocal(y_values[index])
# Normalise y values # Normalise y values
scale = np.reciprocal(y_values[index])
y_values_normalised = scale * y_values y_values_normalised = scale * y_values
# Propagate y errors: C = A / B ; dC = sqrt( (dA/B)^2 + (A*dB/B^2)^2 ) # Propagate y errors: C = A / B ; dC = sqrt( (dA/B)^2 + (A*dB/B^2)^2 )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment