From d87ae97d36919cc81864e9a64556f610dfafad97 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Fri, 10 Jan 2025 11:09:34 -0500
Subject: [PATCH] insert_neutron: ignore failed fit (flaky) (#124)

---
 benchmarks/insert_neutron/analysis/neutron_plots.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/benchmarks/insert_neutron/analysis/neutron_plots.py b/benchmarks/insert_neutron/analysis/neutron_plots.py
index 424295cf..451b6cf1 100644
--- a/benchmarks/insert_neutron/analysis/neutron_plots.py
+++ b/benchmarks/insert_neutron/analysis/neutron_plots.py
@@ -79,11 +79,12 @@ slc=abs(bc)<3
 fnc=gauss
 sigma=np.sqrt(y[slc])+(y[slc]==0)
 p0=(100, 0, 5)
-coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
-xx=np.linspace(-5,5,100)
-plt.plot(xx,fnc(xx,*coeff))
-# except:
-#     pass
+try:
+    coeff, var_matrix = curve_fit(fnc, list(bc[slc]), list(y[slc]), p0=p0, sigma=list(sigma), maxfev=10000)
+    xx=np.linspace(-5,5,100)
+    plt.plot(xx,fnc(xx,*coeff))
+except RuntimeError:
+    print("fit failed")
 plt.xlabel("$\\theta_{rec}-\\theta_{truth}$ [mrad]")
 plt.ylabel("events")
 plt.title(f"$p={p}$ GeV, ${eta_min}<\\eta<{eta_max}$")
-- 
GitLab