Skip to content

Commit

Permalink
Suppress output of scipy optimize warning in resolution fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeilstenedmands committed Sep 17, 2024
1 parent 7cf56ea commit ea02ebe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/XXX.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``dials.resolution_analysis``: Suppress output of potential scipy OptimizeWarning.
6 changes: 4 additions & 2 deletions src/dials/util/resolution_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import math
import typing
import warnings

import numpy as np
import scipy.optimize
Expand Down Expand Up @@ -91,8 +92,9 @@ def tanh_fit(x, y, degree=None, n_obs=None):
p0 = np.array([0.2, 0.4]) # starting parameter estimates
sigma = np.array(standard_errors)
x = np.array(x)

result = scipy.optimize.curve_fit(tanh_cchalf, x, y, p0, sigma=sigma)
with warnings.catch_warnings():
warnings.simplefilter("ignore", scipy.optimize.OptimizeWarning)
result = scipy.optimize.curve_fit(tanh_cchalf, x, y, p0, sigma=sigma)

r = result[0][0]
s0 = result[0][1]
Expand Down

0 comments on commit ea02ebe

Please sign in to comment.