Skip to content

Commit

Permalink
Merge pull request #66 from tronsgaard/tronsgaard-patch-3
Browse files Browse the repository at this point in the history
warnings library must be imported directly
  • Loading branch information
AWehrhahn authored Jul 28, 2023
2 parents 8e176c6 + 5e6d3b5 commit 27398d2
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pyreduce/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import logging
import os
import warnings
from itertools import product

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -317,8 +318,8 @@ def gaussfit2(x, y):

i = np.argmax(y * weights)
p0 = [y[i], x[i], 1]
with np.warnings.catch_warnings():
np.warnings.simplefilter("ignore")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
res = least_squares(
lambda c: gauss(x, *c, np.ma.min(y)) - y,
p0,
Expand Down Expand Up @@ -355,8 +356,8 @@ def gaussfit3(x, y):
i = np.argmax(y[len(y) // 4 : len(y) * 3 // 4]) + len(y) // 4
p0 = [y[i], x[i], 1, np.min(y)]

with np.warnings.catch_warnings():
np.warnings.simplefilter("ignore")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
popt, _ = curve_fit(gauss, x, y, p0=p0)

return popt
Expand Down Expand Up @@ -386,8 +387,8 @@ def gaussfit4(x, y):
i = np.argmax(y)
p0 = [y[i], x[i], 1, np.min(y)]

with np.warnings.catch_warnings():
np.warnings.simplefilter("ignore")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
popt, _ = curve_fit(gauss, x, y, p0=p0)

return popt
Expand Down

0 comments on commit 27398d2

Please sign in to comment.