Skip to content

Commit f3c4082

Browse files
committed
Merge remote-tracking branch 'origin/master' into master
2 parents 17878c4 + 5e83b93 commit f3c4082

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

doc/source/quickstart_pymc3.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ We'll use some time artificial data:::
5353
hare_data = np.array([
5454
30.0, 47.2, 70.2, 77.4, 36.3, 20.6, 18.1, 21.4, 22.0, 25.4,
5555
27.1, 40.3, 57.0, 76.6, 52.3, 19.5, 11.2, 7.6, 14.6, 16.2, 24.7
56+
])
5657
5758
We also define a function for the right-hand-side of the ODE:::
5859

@@ -138,12 +139,12 @@ We are only missing the likelihood now::
138139
with model:
139140
# We can access the individual variables of the solution using the
140141
# variable names.
141-
pm.Deterministic('hares_mu', y_hat['hares'])
142-
pm.Deterministic('lynx_mu', y_hat['lynx'])
142+
pm.Deterministic('hares_mu', solution['hares'])
143+
pm.Deterministic('lynxes_mu', solution['lynxes'])
143144

144145
sd = pm.HalfNormal('sd')
145-
pm.Lognormal('hares', mu=y_hat['hares'], sd=sd, observed=hare_data)
146-
pm.Lognormal('lynx', mu=y_hat['lynx'], sd=sd, observed=lynx_data)
146+
pm.Lognormal('hares', mu=solution['hares'], sd=sd, observed=hare_data)
147+
pm.Lognormal('lynxes', mu=solution['lynxes'], sd=sd, observed=lynx_data)
147148

148149
We can sample from the posterior with the gradient-based PyMC3 samplers:::
149150

doc/source/without_pymc.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ODE might look like this::
6262
dhares = p.alpha * hares - p.beta * lynxes * hares
6363
dlynxes = p.delta * hares * lynxes - p.gamma * lynxes
6464
return {
65-
'log_hares': dhares / hares
65+
'log_hares': dhares / hares,
6666
'log_lynxes': dlynxes / lynxes,
6767
}
6868

@@ -88,7 +88,8 @@ After defining states, parameters and right-hand-side function we can create a
8888
problem = sunode.SympyProblem(
8989
params=params,
9090
states=states,
91-
rhs_sympy=lotka_volterra
91+
rhs_sympy=lotka_volterra,
92+
derivative_params=()
9293
)
9394

9495
The problem provides structured numpy dtypes for states and parameters
@@ -106,7 +107,7 @@ This does not introduce runtime overhead.::
106107

107108
y0 = np.zeros((), dtype=problem.state_dtype)
108109
y0['hares'] = 1
109-
y0['lynx'] = 0.1
110+
y0['lynxes'] = 0.1
110111

111112
# At which time points do we want to evalue the solution
112113
tvals = np.linspace(0, 10)
@@ -127,4 +128,4 @@ We can convert the solution to an xarray Dataset or access the
127128
individual states as numpy record array::
128129

129130
solver.as_xarray(tvals, output).solution_hares.plot()
130-
plt.plot(output.view(problem.state_dtype)['hares']
131+
plt.plot(output.view(tvals, problem.state_dtype)['hares'])

sunode/build_cvodes.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,33 @@
1616
cvodes.sort()
1717

1818
headers = common + linsolve + cvodes
19+
include = []
20+
library_dirs = []
21+
extra_libs = []
1922

2023
if sys.platform == 'win32':
2124
with open(os.path.join(base, "source_cvodes_win.c")) as fsource:
2225
source_content = fsource.read()
23-
include = [os.path.join(os.environ["CONDA_PREFIX"], "Library", "include")]
24-
library_dirs = [
25-
os.path.join(os.environ["CONDA_PREFIX"], "Library", "lib")
26-
]
27-
extra_libs = []
26+
include += [os.path.join(os.environ["CONDA_PREFIX"], "Library", "include")]
27+
library_dirs += [os.path.join(os.environ["CONDA_PREFIX"], "Library", "lib")]
28+
2829
# lapackdense is not supported by the windows build of sundials
2930
for name in ['sunlinsol_lapackdense', 'sunlinsol_klu']:
3031
headers = [fn for fn in headers if name not in fn]
3132
else:
3233
with open(os.path.join(base, "source_cvodes.c")) as fsource:
3334
source_content = fsource.read()
34-
include = [os.path.join(os.environ["CONDA_PREFIX"], "include")]
35-
library_dirs = [os.path.join(os.environ["CONDA_PREFIX"], "lib")]
36-
extra_libs = [
37-
"blas",
38-
"lapack",
35+
36+
#test if we can use conda libraries
37+
if "CONDA_PREFIX" in os.environ:
38+
include += [os.path.join(os.environ["CONDA_PREFIX"], "include")]
39+
library_dirs += [os.path.join(os.environ["CONDA_PREFIX"], "lib")]
40+
extra_libs += ["blas", "lapack"]
41+
else:
42+
include += ["/usr/include/suitesparse/"]
43+
extra_libs.append("openblas")
44+
45+
extra_libs += [
3946
"pthread",
4047
"klu",
4148
"sundials_sunlinsollapackdense",

0 commit comments

Comments
 (0)