Skip to content

Commit b2ea0f3

Browse files
authored
Merge pull request #353 from lmfit/prep094rc2
Prep094rc2
2 parents 7043e5b + 0be33dd commit b2ea0f3

File tree

13 files changed

+446
-406
lines changed

13 files changed

+446
-406
lines changed

asv_benchmarking/asv.conf.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// List of branches to benchmark. If not provided, defaults to "master"
1717
// (for git) or "tip" (for mercurial).
18-
"branches": ["master", "param_minmax_inf"], // for git
18+
"branches": ["master", "prep094rc2"], // for git
1919
// "branches": ["tip"], // for mercurial
2020

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

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

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

4949
// The directory (relative to the current directory) that benchmarks are
5050
// stored in. If not provided, defaults to "benchmarks"

asv_benchmarking/benchmarks/benchmarks.py

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,36 @@ def time_minimize(self):
3838
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
3939
params.add('omega', value= 1.0, min=0, max=10)
4040

41-
out = minimize(obj_func, params, args=(x, data))
41+
return minimize(obj_func, params, args=(x, data))
42+
43+
def time_minimize_withnan(self):
44+
np.random.seed(201)
45+
x = np.linspace(0, 15, 601)
46+
x[53] = np.nan
47+
48+
data = (5. * np.sin(2 * x - 0.1) * np.exp(-x*x*0.025) +
49+
np.random.normal(size=len(x), scale=0.3) )
50+
params = Parameters()
51+
params.add('amp', value= 1, min=0, max=100)
52+
params.add('decay', value= 0.0, min=0, max=10)
53+
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
54+
params.add('omega', value= 1.0, min=0, max=10)
55+
56+
return minimize(obj_func, params, args=(x, data), nan_policy='omit')
57+
58+
def time_minimize_large(self):
59+
np.random.seed(201)
60+
x = np.linspace(0, 19, 70001)
61+
data = (5. * np.sin(0.6* x - 0.1) * np.exp(-x*x*0.0165) +
62+
np.random.normal(size=len(x), scale=0.3) )
63+
params = Parameters()
64+
params.add('amp', value= 1, min=0, max=100)
65+
params.add('decay', value= 0.0, min=0, max=10)
66+
params.add('shift', value= 0.0, min=-np.pi/2., max=np.pi/2)
67+
params.add('omega', value= 0.40, min=0, max=10)
68+
69+
return minimize(obj_func, params, args=(x, data))
70+
4271

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

5786
minimizer = Minimizer(residual, p)
5887
out = minimizer.leastsq()
59-
ci = conf_interval(minimizer, out)
88+
return conf_interval(minimizer, out)
6089

6190

6291
class MinimizerClassSuite:
@@ -91,10 +120,10 @@ def setup(self):
91120
fcn_args=(self.x, self.y))
92121

93122
def time_differential_evolution(self):
94-
self.mini_de.minimize(method='differential_evolution')
123+
return self.mini_de.minimize(method='differential_evolution')
95124

96125
def time_emcee(self):
97-
self.mini_emcee.emcee(self.p_emcee, steps=100, seed=1)
126+
return self.mini_emcee.emcee(self.p_emcee, steps=100, seed=1)
98127

99128

100129
def Minimizer_Residual(p, x, y):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from benchmarks.benchmarks import MinimizerClassSuite, MinimizeSuite
2+
3+
4+
mtest = MinimizeSuite()
5+
mtest.setup()
6+
out = mtest.time_minimize()
7+
out = mtest.time_minimize_large()
8+
out = mtest.time_minimize_withnan()
9+
out = mtest.time_confinterval()
10+
11+
mtest = MinimizerClassSuite()
12+
mtest.setup()
13+
out = mtest.time_differential_evolution()
14+
out = mtest.time_emcee()

doc/_images/model_fit3a.png

2.45 KB
Loading

doc/_images/model_fit3b.png

2.58 KB
Loading

doc/_images/models_stepfit.png

1.89 KB
Loading

0 commit comments

Comments
 (0)