Skip to content

Commit

Permalink
STY: Manually fix remaining ruff issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nstelter-slac committed Jan 30, 2024
1 parent 464791e commit 05093bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion scripts/ancillaryMethods.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import binned_statistic


Expand All @@ -18,7 +19,8 @@ def makeProfile(x, y, bins, range=None, spread=False):
root_N[root_N == 0] = root_N[root_N > 0].mean()
yErr = yErr / root_N
##yErr = yErr.clip(0, 6666666.)
bin_edges = means_result.bin_edges
# where is means_result defined?? (ignore from ruff for now)
bin_edges = means_result.bin_edges # noqa: F821
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2.0
usefulBins = bin_N > 0
return bin_centers[usefulBins], means[usefulBins], yErr[usefulBins]
Expand Down
5 changes: 3 additions & 2 deletions scripts/pixelAnalysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import matplotlib.pyplot as plt
import fitFunctions, ancillaryMethods
import fitFunctions
import ancillaryMethods
from scipy.optimize import curve_fit
import logging

Expand Down Expand Up @@ -142,7 +143,7 @@ def histogramAndFitGaussian(ax, energies, nBins):
fittedFunc = fitFunctions.gaussian(bins, *popt)
ax.plot(bins, fittedFunc, color="b")
return popt
except:
except Exception:
return 0, 0, 0


Expand Down
3 changes: 2 additions & 1 deletion tests/test_FitFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def test_estimateGaussianParametersFromXY():
y = np.array([2, 4, 6, 4, 2])
result_amp, result_mean, result_sigma = estimateGaussianParametersFromXY(x, y)
expected_amp, expected_mean, expected_sigma = 2.482238418490429, 3.0, 1.1547005383792515
print(result_amp, result_mean, result_sigma)
assert np.isclose(result_amp, expected_amp)
assert result_mean == expected_mean
assert np.isclose(result_sigma, expected_sigma)


Expand Down

0 comments on commit 05093bb

Please sign in to comment.