Closed aminnj closed 3 years ago
np.random.seed(42) h1 = Hist1D.from_random("poisson", params=[2], bins="50,0,20", size=100) h2 = Hist1D.from_random("poisson", params=[2], bins="50,0,20", size=100) (h1/h2).fit("a*x+b")
gives
ValueError Traceback (most recent call last) <ipython-input-88-c730772a78c7> in <module> 2 h1 = Hist1D.from_random("poisson", params=[2], bins="50,0,20", size=100) 3 h2 = Hist1D.from_random("poisson", params=[2], bins="50,0,20", size=100) ----> 4 (h1/h2).fit("a*x+b") 5 # h = h1.divide(h2) 6 # h.plot(show_errors=True) ~/sandbox/dev/yahist/yahist/hist1d.py in fit(self, func, **kwargs) 1089 1090 def fit(self, func, **kwargs): -> 1091 return fit_hist(func, self, **kwargs) 1092 1093 fit.__doc__ = fit_hist.__doc__ ~/sandbox/dev/yahist/yahist/utils.py in fit_hist(func, hist, nsamples, ax, draw, color, legend, label, band_style, likelihood, curve_fit_kwargs) 314 absolute_sigma=True, 315 likelihood=likelihood, --> 316 **curve_fit_kwargs, 317 ) 318 ~/sandbox/dev/yahist/yahist/utils.py in curve_fit_wrapper(func, xdata, ydata, sigma, absolute_sigma, likelihood, **kwargs) 193 sigma=sigma[~tomask], 194 absolute_sigma=absolute_sigma, --> 195 **kwargs, 196 ) 197 if likelihood: ~/Library/Python/3.7/lib/python/site-packages/scipy/optimize/minpack.py in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs) 732 # NaNs cannot be handled 733 if check_finite: --> 734 ydata = np.asarray_chkfinite(ydata, float) 735 else: 736 ydata = np.asarray(ydata, float) ~/Library/Python/3.7/lib/python/site-packages/numpy/lib/function_base.py in asarray_chkfinite(a, dtype, order) 484 if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all(): 485 raise ValueError( --> 486 "array must not contain infs or NaNs") 487 return a 488 ValueError: array must not contain infs or NaNs
Need to do some more NaN filtering before fitting?
fixed by https://github.com/aminnj/yahist/commit/05b456a077841ad2b29441de27365e29dabee258
gives
Need to do some more NaN filtering before fitting?