Skip to content

Commit

Permalink
Merge pull request #353 from lmfit/prep094rc2
Browse files Browse the repository at this point in the history
Prep094rc2
  • Loading branch information
newville authored Jul 21, 2016
2 parents 7043e5b + 0be33dd commit b2ea0f3
Show file tree
Hide file tree
Showing 13 changed files with 446 additions and 406 deletions.
10 changes: 5 additions & 5 deletions asv_benchmarking/asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// List of branches to benchmark. If not provided, defaults to "master"
// (for git) or "tip" (for mercurial).
"branches": ["master", "param_minmax_inf"], // for git
"branches": ["master", "prep094rc2"], // for git
// "branches": ["tip"], // for mercurial

// The DVCS being used. If not set, it will be automatically
Expand All @@ -36,15 +36,15 @@

// The Pythons you'd like to test against. If not provided, defaults
// to the current version of Python used to run `asv`.
// "pythons": ["2.7", "3.3"],
"pythons": ["2.7", "3.5"],

// The matrix of dependencies to test. Each key is the name of a
// package (in PyPI) and the values are version numbers. An empty
// list indicates to just test against the default (latest)
// version.
"matrix": {
"pip+emcee": [],
},
// "matrix": {
// "pip+emcee": [],
// },

// The directory (relative to the current directory) that benchmarks are
// stored in. If not provided, defaults to "benchmarks"
Expand Down
37 changes: 33 additions & 4 deletions asv_benchmarking/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,36 @@ def time_minimize(self):
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
params.add('omega', value= 1.0, min=0, max=10)

out = minimize(obj_func, params, args=(x, data))
return minimize(obj_func, params, args=(x, data))

def time_minimize_withnan(self):
np.random.seed(201)
x = np.linspace(0, 15, 601)
x[53] = np.nan

data = (5. * np.sin(2 * x - 0.1) * np.exp(-x*x*0.025) +
np.random.normal(size=len(x), scale=0.3) )
params = Parameters()
params.add('amp', value= 1, min=0, max=100)
params.add('decay', value= 0.0, min=0, max=10)
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
params.add('omega', value= 1.0, min=0, max=10)

return minimize(obj_func, params, args=(x, data), nan_policy='omit')

def time_minimize_large(self):
np.random.seed(201)
x = np.linspace(0, 19, 70001)
data = (5. * np.sin(0.6* x - 0.1) * np.exp(-x*x*0.0165) +
np.random.normal(size=len(x), scale=0.3) )
params = Parameters()
params.add('amp', value= 1, min=0, max=100)
params.add('decay', value= 0.0, min=0, max=10)
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
params.add('omega', value= 0.40, min=0, max=10)

return minimize(obj_func, params, args=(x, data))


def time_confinterval(self):
np.random.seed(0)
Expand All @@ -56,7 +85,7 @@ def residual(p):

minimizer = Minimizer(residual, p)
out = minimizer.leastsq()
ci = conf_interval(minimizer, out)
return conf_interval(minimizer, out)


class MinimizerClassSuite:
Expand Down Expand Up @@ -91,10 +120,10 @@ def setup(self):
fcn_args=(self.x, self.y))

def time_differential_evolution(self):
self.mini_de.minimize(method='differential_evolution')
return self.mini_de.minimize(method='differential_evolution')

def time_emcee(self):
self.mini_emcee.emcee(self.p_emcee, steps=100, seed=1)
return self.mini_emcee.emcee(self.p_emcee, steps=100, seed=1)


def Minimizer_Residual(p, x, y):
Expand Down
14 changes: 14 additions & 0 deletions asv_benchmarking/run_benchmark_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from benchmarks.benchmarks import MinimizerClassSuite, MinimizeSuite


mtest = MinimizeSuite()
mtest.setup()
out = mtest.time_minimize()
out = mtest.time_minimize_large()
out = mtest.time_minimize_withnan()
out = mtest.time_confinterval()

mtest = MinimizerClassSuite()
mtest.setup()
out = mtest.time_differential_evolution()
out = mtest.time_emcee()
Binary file modified doc/_images/model_fit3a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_images/model_fit3b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/_images/models_stepfit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b2ea0f3

Please sign in to comment.