Skip to content
Snippets Groups Projects
Commit 81000023 authored by Andrey Aristov's avatar Andrey Aristov
Browse files

prevent ValueError

parent 6303de15
No related branches found
No related tags found
No related merge requests found
Pipeline #83173 passed
...@@ -8,7 +8,12 @@ def fit(numbers:np.ndarray, max_value=None, xlabel='Initial number of cells', ...@@ -8,7 +8,12 @@ def fit(numbers:np.ndarray, max_value=None, xlabel='Initial number of cells',
title='', plot=True, save_fig_path=None): title='', plot=True, save_fig_path=None):
if max_value is None: if max_value is None:
max_value = numbers.max() max_value = numbers.max()
bins = np.arange(max_value + 1) - .5 try:
bins = np.arange(max_value + 1) - .5
except ValueError as e:
print('poisson error in bins:', *e.args)
return None
vector = bins[:-1] +.5 vector = bins[:-1] +.5
hist, bins= np.histogram(numbers, bins=bins, density=True) hist, bins= np.histogram(numbers, bins=bins, density=True)
popt, pcov = curve_fit(poisson.pmf, vector, hist, p0=(1.,)) popt, pcov = curve_fit(poisson.pmf, vector, hist, p0=(1.,))
......
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