Commit 9d351769 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille

Merge remote-tracking branch 'google/master'

Conflicts:
	pyqt_fit/npr_methods.py
parents 8416612b 6553a802
......@@ -51,5 +51,8 @@ CSV file for further analysis in your favorite software (including most
spreadsheet programs).
:Note: Version 1.3.0 is not fully compatible with previous versions. Although
Note
----
Version 1.3.0 is not fully compatible with previous versions. Although
the interfaces offer better flexibility, it will require some code change.
......@@ -16,11 +16,6 @@ from . import bootstrap_workers
from .compat import irange, izip
def adapt_curve_fit(fct, x, y, p0, args=(), **kwrds):
popt, pcov = optimize.curve_fit(fct, x, y, **kwrds)
return (popt, pcov, fct(popt, x, *args) - y)
def percentile(array, p, axis=0):
"""
Compute the percentiles of the values in array
......@@ -248,6 +243,8 @@ def bootstrap(fit, xdata, ydata, CI, shuffle_method=bootstrap_residuals,
confidence intervals and, if requested, the shuffled X, Y and the full
estimated distributions.
"""
xdata = np.asarray(xdata)
ydata = np.asarray(ydata)
y_fit = fit(xdata, ydata, *fit_args, **fit_kwrds)
y_fit.fit()
......
......@@ -155,6 +155,8 @@ class NonParamRegression(object):
"""
Lower bound of the domain for each dimension
"""
if self._lower is None:
return -np.inf*np.ones(self.dim, dtype=float)
return self._lower
@lower.setter
......@@ -173,6 +175,8 @@ class NonParamRegression(object):
"""
Lower bound of the domain for each dimension
"""
if self._upper is None:
return np.inf*np.ones(self.dim, dtype=float)
return self._upper
@upper.setter
......@@ -269,13 +273,15 @@ class NonParamRegression(object):
D, N = self._xdata.shape
assert self._ydata.shape[0] == N, "There must be as many points for X and Y"
self._kernel = self._create_kernel(D)
if self._lower is None:
self._lower = -np.inf * np.ones((D,), dtype=float)
if self._upper is None:
self._upper = np.inf * np.ones((D,), dtype=float)
self._n = N
self._d = D
lower = self.lower
upper = self.upper
assert len(lower) == D, "The 'lower' property must have one value per dimension of the domain."
assert len(upper) == D, "The 'upper' property must have one value per dimension of the domain."
self._fitted_method = self._method.fit(self)
assert self.bandwidth.shape == (D, D), "The bandwidth should have a shape of ({0},{0}) (actual: {1})".format(D, self.bandwidth.shape)
assert self.covariance.shape == (D, D), "The covariance should have a shape of ({0},{0}) (actual: {1})".format(D, self.covariance.shape)
self._fitted = True
def evaluate(self, points, out=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment