diff --git a/src/droplet_growth/poisson.py b/src/droplet_growth/poisson.py index 17aba4fed48a3b6eda8be5a74e4b96353a909aaa..14a53ab0790d0323e05f59a59ea65a8680cbba42 100644 --- a/src/droplet_growth/poisson.py +++ b/src/droplet_growth/poisson.py @@ -8,7 +8,12 @@ def fit(numbers:np.ndarray, max_value=None, xlabel='Initial number of cells', title='', plot=True, save_fig_path=None): if max_value is None: 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 hist, bins= np.histogram(numbers, bins=bins, density=True) popt, pcov = curve_fit(poisson.pmf, vector, hist, p0=(1.,))