arviz 0.23.3__py3-none-any.whl → 1.0.0rc0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- arviz/__init__.py +52 -367
- arviz-1.0.0rc0.dist-info/METADATA +182 -0
- arviz-1.0.0rc0.dist-info/RECORD +5 -0
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/WHEEL +1 -2
- {arviz-0.23.3.dist-info → arviz-1.0.0rc0.dist-info}/licenses/LICENSE +0 -1
- arviz/data/__init__.py +0 -55
- arviz/data/base.py +0 -596
- arviz/data/converters.py +0 -203
- arviz/data/datasets.py +0 -161
- arviz/data/example_data/code/radon/radon.json +0 -326
- arviz/data/example_data/data/centered_eight.nc +0 -0
- arviz/data/example_data/data/non_centered_eight.nc +0 -0
- arviz/data/example_data/data_local.json +0 -12
- arviz/data/example_data/data_remote.json +0 -58
- arviz/data/inference_data.py +0 -2386
- arviz/data/io_beanmachine.py +0 -112
- arviz/data/io_cmdstan.py +0 -1036
- arviz/data/io_cmdstanpy.py +0 -1233
- arviz/data/io_datatree.py +0 -23
- arviz/data/io_dict.py +0 -462
- arviz/data/io_emcee.py +0 -317
- arviz/data/io_json.py +0 -54
- arviz/data/io_netcdf.py +0 -68
- arviz/data/io_numpyro.py +0 -497
- arviz/data/io_pyjags.py +0 -378
- arviz/data/io_pyro.py +0 -333
- arviz/data/io_pystan.py +0 -1095
- arviz/data/io_zarr.py +0 -46
- arviz/data/utils.py +0 -139
- arviz/labels.py +0 -210
- arviz/plots/__init__.py +0 -61
- arviz/plots/autocorrplot.py +0 -171
- arviz/plots/backends/__init__.py +0 -223
- arviz/plots/backends/bokeh/__init__.py +0 -166
- arviz/plots/backends/bokeh/autocorrplot.py +0 -101
- arviz/plots/backends/bokeh/bfplot.py +0 -23
- arviz/plots/backends/bokeh/bpvplot.py +0 -193
- arviz/plots/backends/bokeh/compareplot.py +0 -167
- arviz/plots/backends/bokeh/densityplot.py +0 -239
- arviz/plots/backends/bokeh/distcomparisonplot.py +0 -23
- arviz/plots/backends/bokeh/distplot.py +0 -183
- arviz/plots/backends/bokeh/dotplot.py +0 -113
- arviz/plots/backends/bokeh/ecdfplot.py +0 -73
- arviz/plots/backends/bokeh/elpdplot.py +0 -203
- arviz/plots/backends/bokeh/energyplot.py +0 -155
- arviz/plots/backends/bokeh/essplot.py +0 -176
- arviz/plots/backends/bokeh/forestplot.py +0 -772
- arviz/plots/backends/bokeh/hdiplot.py +0 -54
- arviz/plots/backends/bokeh/kdeplot.py +0 -268
- arviz/plots/backends/bokeh/khatplot.py +0 -163
- arviz/plots/backends/bokeh/lmplot.py +0 -185
- arviz/plots/backends/bokeh/loopitplot.py +0 -211
- arviz/plots/backends/bokeh/mcseplot.py +0 -184
- arviz/plots/backends/bokeh/pairplot.py +0 -328
- arviz/plots/backends/bokeh/parallelplot.py +0 -81
- arviz/plots/backends/bokeh/posteriorplot.py +0 -324
- arviz/plots/backends/bokeh/ppcplot.py +0 -379
- arviz/plots/backends/bokeh/rankplot.py +0 -149
- arviz/plots/backends/bokeh/separationplot.py +0 -107
- arviz/plots/backends/bokeh/traceplot.py +0 -436
- arviz/plots/backends/bokeh/violinplot.py +0 -164
- arviz/plots/backends/matplotlib/__init__.py +0 -124
- arviz/plots/backends/matplotlib/autocorrplot.py +0 -72
- arviz/plots/backends/matplotlib/bfplot.py +0 -78
- arviz/plots/backends/matplotlib/bpvplot.py +0 -177
- arviz/plots/backends/matplotlib/compareplot.py +0 -135
- arviz/plots/backends/matplotlib/densityplot.py +0 -194
- arviz/plots/backends/matplotlib/distcomparisonplot.py +0 -119
- arviz/plots/backends/matplotlib/distplot.py +0 -178
- arviz/plots/backends/matplotlib/dotplot.py +0 -116
- arviz/plots/backends/matplotlib/ecdfplot.py +0 -70
- arviz/plots/backends/matplotlib/elpdplot.py +0 -189
- arviz/plots/backends/matplotlib/energyplot.py +0 -113
- arviz/plots/backends/matplotlib/essplot.py +0 -180
- arviz/plots/backends/matplotlib/forestplot.py +0 -656
- arviz/plots/backends/matplotlib/hdiplot.py +0 -48
- arviz/plots/backends/matplotlib/kdeplot.py +0 -177
- arviz/plots/backends/matplotlib/khatplot.py +0 -241
- arviz/plots/backends/matplotlib/lmplot.py +0 -149
- arviz/plots/backends/matplotlib/loopitplot.py +0 -144
- arviz/plots/backends/matplotlib/mcseplot.py +0 -161
- arviz/plots/backends/matplotlib/pairplot.py +0 -355
- arviz/plots/backends/matplotlib/parallelplot.py +0 -58
- arviz/plots/backends/matplotlib/posteriorplot.py +0 -348
- arviz/plots/backends/matplotlib/ppcplot.py +0 -478
- arviz/plots/backends/matplotlib/rankplot.py +0 -119
- arviz/plots/backends/matplotlib/separationplot.py +0 -97
- arviz/plots/backends/matplotlib/traceplot.py +0 -526
- arviz/plots/backends/matplotlib/tsplot.py +0 -121
- arviz/plots/backends/matplotlib/violinplot.py +0 -148
- arviz/plots/bfplot.py +0 -128
- arviz/plots/bpvplot.py +0 -308
- arviz/plots/compareplot.py +0 -177
- arviz/plots/densityplot.py +0 -284
- arviz/plots/distcomparisonplot.py +0 -197
- arviz/plots/distplot.py +0 -233
- arviz/plots/dotplot.py +0 -233
- arviz/plots/ecdfplot.py +0 -372
- arviz/plots/elpdplot.py +0 -174
- arviz/plots/energyplot.py +0 -147
- arviz/plots/essplot.py +0 -319
- arviz/plots/forestplot.py +0 -304
- arviz/plots/hdiplot.py +0 -211
- arviz/plots/kdeplot.py +0 -357
- arviz/plots/khatplot.py +0 -236
- arviz/plots/lmplot.py +0 -380
- arviz/plots/loopitplot.py +0 -224
- arviz/plots/mcseplot.py +0 -194
- arviz/plots/pairplot.py +0 -281
- arviz/plots/parallelplot.py +0 -204
- arviz/plots/plot_utils.py +0 -599
- arviz/plots/posteriorplot.py +0 -298
- arviz/plots/ppcplot.py +0 -369
- arviz/plots/rankplot.py +0 -232
- arviz/plots/separationplot.py +0 -167
- arviz/plots/styles/arviz-bluish.mplstyle +0 -1
- arviz/plots/styles/arviz-brownish.mplstyle +0 -1
- arviz/plots/styles/arviz-colors.mplstyle +0 -2
- arviz/plots/styles/arviz-cyanish.mplstyle +0 -1
- arviz/plots/styles/arviz-darkgrid.mplstyle +0 -40
- arviz/plots/styles/arviz-doc.mplstyle +0 -88
- arviz/plots/styles/arviz-docgrid.mplstyle +0 -88
- arviz/plots/styles/arviz-grayscale.mplstyle +0 -41
- arviz/plots/styles/arviz-greenish.mplstyle +0 -1
- arviz/plots/styles/arviz-orangish.mplstyle +0 -1
- arviz/plots/styles/arviz-plasmish.mplstyle +0 -1
- arviz/plots/styles/arviz-purplish.mplstyle +0 -1
- arviz/plots/styles/arviz-redish.mplstyle +0 -1
- arviz/plots/styles/arviz-royish.mplstyle +0 -1
- arviz/plots/styles/arviz-viridish.mplstyle +0 -1
- arviz/plots/styles/arviz-white.mplstyle +0 -40
- arviz/plots/styles/arviz-whitegrid.mplstyle +0 -40
- arviz/plots/traceplot.py +0 -273
- arviz/plots/tsplot.py +0 -440
- arviz/plots/violinplot.py +0 -192
- arviz/preview.py +0 -58
- arviz/py.typed +0 -0
- arviz/rcparams.py +0 -606
- arviz/sel_utils.py +0 -223
- arviz/static/css/style.css +0 -340
- arviz/static/html/icons-svg-inline.html +0 -15
- arviz/stats/__init__.py +0 -37
- arviz/stats/density_utils.py +0 -1013
- arviz/stats/diagnostics.py +0 -1013
- arviz/stats/ecdf_utils.py +0 -324
- arviz/stats/stats.py +0 -2422
- arviz/stats/stats_refitting.py +0 -119
- arviz/stats/stats_utils.py +0 -609
- arviz/tests/__init__.py +0 -1
- arviz/tests/base_tests/__init__.py +0 -1
- arviz/tests/base_tests/test_data.py +0 -1679
- arviz/tests/base_tests/test_data_zarr.py +0 -143
- arviz/tests/base_tests/test_diagnostics.py +0 -511
- arviz/tests/base_tests/test_diagnostics_numba.py +0 -87
- arviz/tests/base_tests/test_helpers.py +0 -18
- arviz/tests/base_tests/test_labels.py +0 -69
- arviz/tests/base_tests/test_plot_utils.py +0 -342
- arviz/tests/base_tests/test_plots_bokeh.py +0 -1288
- arviz/tests/base_tests/test_plots_matplotlib.py +0 -2197
- arviz/tests/base_tests/test_rcparams.py +0 -317
- arviz/tests/base_tests/test_stats.py +0 -925
- arviz/tests/base_tests/test_stats_ecdf_utils.py +0 -166
- arviz/tests/base_tests/test_stats_numba.py +0 -45
- arviz/tests/base_tests/test_stats_utils.py +0 -384
- arviz/tests/base_tests/test_utils.py +0 -376
- arviz/tests/base_tests/test_utils_numba.py +0 -87
- arviz/tests/conftest.py +0 -46
- arviz/tests/external_tests/__init__.py +0 -1
- arviz/tests/external_tests/test_data_beanmachine.py +0 -78
- arviz/tests/external_tests/test_data_cmdstan.py +0 -398
- arviz/tests/external_tests/test_data_cmdstanpy.py +0 -496
- arviz/tests/external_tests/test_data_emcee.py +0 -166
- arviz/tests/external_tests/test_data_numpyro.py +0 -434
- arviz/tests/external_tests/test_data_pyjags.py +0 -119
- arviz/tests/external_tests/test_data_pyro.py +0 -260
- arviz/tests/external_tests/test_data_pystan.py +0 -307
- arviz/tests/helpers.py +0 -677
- arviz/utils.py +0 -773
- arviz/wrappers/__init__.py +0 -13
- arviz/wrappers/base.py +0 -236
- arviz/wrappers/wrap_pymc.py +0 -36
- arviz/wrappers/wrap_stan.py +0 -148
- arviz-0.23.3.dist-info/METADATA +0 -264
- arviz-0.23.3.dist-info/RECORD +0 -183
- arviz-0.23.3.dist-info/top_level.txt +0 -1
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
# pylint: disable=redefined-outer-name
|
|
2
|
-
import os
|
|
3
|
-
import sys
|
|
4
|
-
import tempfile
|
|
5
|
-
from glob import glob
|
|
6
|
-
|
|
7
|
-
import numpy as np
|
|
8
|
-
import pytest
|
|
9
|
-
|
|
10
|
-
from ... import from_cmdstanpy
|
|
11
|
-
|
|
12
|
-
from ..helpers import ( # pylint: disable=unused-import
|
|
13
|
-
chains,
|
|
14
|
-
check_multiple_attrs,
|
|
15
|
-
draws,
|
|
16
|
-
eight_schools_params,
|
|
17
|
-
importorskip,
|
|
18
|
-
load_cached_models,
|
|
19
|
-
pystan_version,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def _create_test_data():
|
|
24
|
-
"""Create test data to local folder.
|
|
25
|
-
|
|
26
|
-
This function is needed when test data needs to be updated.
|
|
27
|
-
"""
|
|
28
|
-
import platform
|
|
29
|
-
import shutil
|
|
30
|
-
from pathlib import Path
|
|
31
|
-
|
|
32
|
-
import cmdstanpy
|
|
33
|
-
|
|
34
|
-
model_code = """
|
|
35
|
-
data {
|
|
36
|
-
int<lower=0> J;
|
|
37
|
-
real y[J];
|
|
38
|
-
real<lower=0> sigma[J];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
parameters {
|
|
42
|
-
real mu;
|
|
43
|
-
real<lower=0> tau;
|
|
44
|
-
real eta[2, J / 2];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
transformed parameters {
|
|
48
|
-
real theta[J];
|
|
49
|
-
for (j in 1:J/2) {
|
|
50
|
-
theta[j] = mu + tau * eta[1, j];
|
|
51
|
-
theta[j + 4] = mu + tau * eta[2, j];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
model {
|
|
56
|
-
mu ~ normal(0, 5);
|
|
57
|
-
tau ~ cauchy(0, 5);
|
|
58
|
-
eta[1] ~ normal(0, 1);
|
|
59
|
-
eta[2] ~ normal(0, 1);
|
|
60
|
-
y ~ normal(theta, sigma);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
generated quantities {
|
|
64
|
-
vector[J] log_lik;
|
|
65
|
-
vector[J] y_hat;
|
|
66
|
-
for (j in 1:J) {
|
|
67
|
-
log_lik[j] = normal_lpdf(y[j] | theta[j], sigma[j]);
|
|
68
|
-
y_hat[j] = normal_rng(theta[j], sigma[j]);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
"""
|
|
72
|
-
stan_file = "stan_test_data.stan"
|
|
73
|
-
with open(stan_file, "w", encoding="utf8") as file_handle:
|
|
74
|
-
print(model_code, file=file_handle)
|
|
75
|
-
model = cmdstanpy.CmdStanModel(stan_file=stan_file)
|
|
76
|
-
os.remove(stan_file)
|
|
77
|
-
stan_data = {
|
|
78
|
-
"J": 8,
|
|
79
|
-
"y": np.array([28.0, 8.0, -3.0, 7.0, -1.0, 1.0, 18.0, 12.0]),
|
|
80
|
-
"sigma": np.array([15.0, 10.0, 16.0, 11.0, 9.0, 11.0, 10.0, 18.0]),
|
|
81
|
-
}
|
|
82
|
-
fit_no_warmup = model.sample(
|
|
83
|
-
data=stan_data, iter_sampling=100, iter_warmup=1000, save_warmup=False
|
|
84
|
-
)
|
|
85
|
-
fit_no_warmup.save_csvfiles(dir=".")
|
|
86
|
-
fit_files = {
|
|
87
|
-
"cmdstanpy_eight_schools_nowarmup": [],
|
|
88
|
-
"cmdstanpy_eight_schools_warmup": [],
|
|
89
|
-
}
|
|
90
|
-
for path in fit_no_warmup.runset.csv_files:
|
|
91
|
-
path = Path(path)
|
|
92
|
-
_, num = path.stem.rsplit("-", 1)
|
|
93
|
-
new_path = path.parent / ("cmdstanpy_eight_schools_nowarmup-" + num + path.suffix)
|
|
94
|
-
shutil.move(path, new_path)
|
|
95
|
-
fit_files["cmdstanpy_eight_schools_nowarmup"].append(new_path)
|
|
96
|
-
fit_warmup = model.sample(data=stan_data, iter_sampling=100, iter_warmup=500, save_warmup=True)
|
|
97
|
-
fit_warmup.save_csvfiles(dir=".")
|
|
98
|
-
for path in fit_no_warmup.runset.csv_files:
|
|
99
|
-
path = Path(path)
|
|
100
|
-
_, num = path.stem.rsplit("-", 1)
|
|
101
|
-
new_path = path.parent / ("cmdstanpy_eight_schools_warmup-" + num + path.suffix)
|
|
102
|
-
shutil.move(path, new_path)
|
|
103
|
-
fit_files["cmdstanpy_eight_schools_warmup"].append(new_path)
|
|
104
|
-
path = Path(stan_file)
|
|
105
|
-
os.remove(str(path.parent / (path.stem + (".exe" if platform.system() == "Windows" else ""))))
|
|
106
|
-
os.remove(str(path.parent / (path.stem + ".hpp")))
|
|
107
|
-
return fit_files
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
@pytest.mark.skipif(sys.version_info < (3, 6), reason="CmdStanPy is supported only Python 3.6+")
|
|
111
|
-
class TestDataCmdStanPy:
|
|
112
|
-
@pytest.fixture(scope="session")
|
|
113
|
-
def data_directory(self):
|
|
114
|
-
here = os.path.dirname(os.path.abspath(__file__))
|
|
115
|
-
data_directory = os.path.join(here, "..", "saved_models")
|
|
116
|
-
return data_directory
|
|
117
|
-
|
|
118
|
-
@pytest.fixture(scope="class")
|
|
119
|
-
def filepaths(self, data_directory):
|
|
120
|
-
files = {
|
|
121
|
-
"nowarmup": glob(
|
|
122
|
-
os.path.join(
|
|
123
|
-
data_directory, "cmdstanpy", "cmdstanpy_eight_schools_nowarmup-[1-4].csv"
|
|
124
|
-
)
|
|
125
|
-
),
|
|
126
|
-
"warmup": glob(
|
|
127
|
-
os.path.join(
|
|
128
|
-
data_directory, "cmdstanpy", "cmdstanpy_eight_schools_warmup-[1-4].csv"
|
|
129
|
-
)
|
|
130
|
-
),
|
|
131
|
-
}
|
|
132
|
-
return files
|
|
133
|
-
|
|
134
|
-
@pytest.fixture(scope="class")
|
|
135
|
-
def data(self, filepaths):
|
|
136
|
-
# Skip tests if cmdstanpy not installed
|
|
137
|
-
cmdstanpy = importorskip("cmdstanpy")
|
|
138
|
-
CmdStanModel = cmdstanpy.CmdStanModel # pylint: disable=invalid-name
|
|
139
|
-
CmdStanMCMC = cmdstanpy.CmdStanMCMC # pylint: disable=invalid-name
|
|
140
|
-
RunSet = cmdstanpy.stanfit.RunSet # pylint: disable=invalid-name
|
|
141
|
-
CmdStanArgs = cmdstanpy.model.CmdStanArgs # pylint: disable=invalid-name
|
|
142
|
-
SamplerArgs = cmdstanpy.model.SamplerArgs # pylint: disable=invalid-name
|
|
143
|
-
|
|
144
|
-
class Data:
|
|
145
|
-
args = CmdStanArgs(
|
|
146
|
-
"dummy.stan",
|
|
147
|
-
"dummy.exe",
|
|
148
|
-
list(range(1, 5)),
|
|
149
|
-
method_args=SamplerArgs(iter_sampling=100),
|
|
150
|
-
)
|
|
151
|
-
runset_obj = RunSet(args)
|
|
152
|
-
runset_obj._csv_files = filepaths["nowarmup"] # pylint: disable=protected-access
|
|
153
|
-
obj = CmdStanMCMC(runset_obj)
|
|
154
|
-
obj._assemble_draws() # pylint: disable=protected-access
|
|
155
|
-
|
|
156
|
-
args_warmup = CmdStanArgs(
|
|
157
|
-
"dummy.stan",
|
|
158
|
-
"dummy.exe",
|
|
159
|
-
list(range(1, 5)),
|
|
160
|
-
method_args=SamplerArgs(iter_sampling=100, iter_warmup=500, save_warmup=True),
|
|
161
|
-
)
|
|
162
|
-
runset_obj_warmup = RunSet(args_warmup)
|
|
163
|
-
runset_obj_warmup._csv_files = filepaths["warmup"] # pylint: disable=protected-access
|
|
164
|
-
obj_warmup = CmdStanMCMC(runset_obj_warmup)
|
|
165
|
-
obj_warmup._assemble_draws() # pylint: disable=protected-access
|
|
166
|
-
|
|
167
|
-
_model_code = """model { real y; } generated quantities { int eta; int theta[N]; }"""
|
|
168
|
-
_tmp_dir = tempfile.TemporaryDirectory(prefix="arviz_tests_")
|
|
169
|
-
_stan_file = os.path.join(_tmp_dir.name, "stan_model_test.stan")
|
|
170
|
-
with open(_stan_file, "w", encoding="utf8") as f:
|
|
171
|
-
f.write(_model_code)
|
|
172
|
-
model = CmdStanModel(stan_file=_stan_file, compile=False)
|
|
173
|
-
|
|
174
|
-
return Data
|
|
175
|
-
|
|
176
|
-
def get_inference_data(self, data, eight_schools_params):
|
|
177
|
-
"""vars as str."""
|
|
178
|
-
return from_cmdstanpy(
|
|
179
|
-
posterior=data.obj,
|
|
180
|
-
posterior_predictive="y_hat",
|
|
181
|
-
predictions="y_hat",
|
|
182
|
-
prior=data.obj,
|
|
183
|
-
prior_predictive="y_hat",
|
|
184
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
185
|
-
constant_data={"y": eight_schools_params["y"]},
|
|
186
|
-
predictions_constant_data={"y": eight_schools_params["y"]},
|
|
187
|
-
log_likelihood={"y": "log_lik"},
|
|
188
|
-
coords={"school": np.arange(eight_schools_params["J"])},
|
|
189
|
-
dims={
|
|
190
|
-
"y": ["school"],
|
|
191
|
-
"log_lik": ["school"],
|
|
192
|
-
"y_hat": ["school"],
|
|
193
|
-
"theta": ["school"],
|
|
194
|
-
},
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
def get_inference_data2(self, data, eight_schools_params):
|
|
198
|
-
"""vars as lists."""
|
|
199
|
-
return from_cmdstanpy(
|
|
200
|
-
posterior=data.obj,
|
|
201
|
-
posterior_predictive=["y_hat"],
|
|
202
|
-
predictions=["y_hat", "log_lik"],
|
|
203
|
-
prior=data.obj,
|
|
204
|
-
prior_predictive=["y_hat"],
|
|
205
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
206
|
-
constant_data=eight_schools_params,
|
|
207
|
-
predictions_constant_data=eight_schools_params,
|
|
208
|
-
log_likelihood=["log_lik", "y_hat"],
|
|
209
|
-
coords={
|
|
210
|
-
"school": np.arange(eight_schools_params["J"]),
|
|
211
|
-
"log_lik_dim": np.arange(eight_schools_params["J"]),
|
|
212
|
-
},
|
|
213
|
-
dims={
|
|
214
|
-
"eta": ["extra_dim", "half school"],
|
|
215
|
-
"y": ["school"],
|
|
216
|
-
"y_hat": ["school"],
|
|
217
|
-
"theta": ["school"],
|
|
218
|
-
"log_lik": ["log_lik_dim"],
|
|
219
|
-
},
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
def get_inference_data3(self, data, eight_schools_params):
|
|
223
|
-
"""multiple vars as lists."""
|
|
224
|
-
return from_cmdstanpy(
|
|
225
|
-
posterior=data.obj,
|
|
226
|
-
posterior_predictive=["y_hat", "log_lik"],
|
|
227
|
-
prior=data.obj,
|
|
228
|
-
prior_predictive=["y_hat", "log_lik"],
|
|
229
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
230
|
-
coords={
|
|
231
|
-
"school": np.arange(eight_schools_params["J"]),
|
|
232
|
-
"half school": ["a", "b", "c", "d"],
|
|
233
|
-
"extra_dim": ["x", "y"],
|
|
234
|
-
},
|
|
235
|
-
dims={
|
|
236
|
-
"eta": ["extra_dim", "half school"],
|
|
237
|
-
"y": ["school"],
|
|
238
|
-
"y_hat": ["school"],
|
|
239
|
-
"theta": ["school"],
|
|
240
|
-
"log_lik": ["log_lik_dim"],
|
|
241
|
-
},
|
|
242
|
-
dtypes=data.model,
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
def get_inference_data4(self, data, eight_schools_params):
|
|
246
|
-
"""multiple vars as lists."""
|
|
247
|
-
return from_cmdstanpy(
|
|
248
|
-
posterior=data.obj,
|
|
249
|
-
posterior_predictive=None,
|
|
250
|
-
prior=data.obj,
|
|
251
|
-
prior_predictive=None,
|
|
252
|
-
log_likelihood=False,
|
|
253
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
254
|
-
coords=None,
|
|
255
|
-
dims=None,
|
|
256
|
-
dtypes={"eta": int, "theta": int},
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
def get_inference_data5(self, data, eight_schools_params):
|
|
260
|
-
"""multiple vars as lists."""
|
|
261
|
-
return from_cmdstanpy(
|
|
262
|
-
posterior=data.obj,
|
|
263
|
-
posterior_predictive=None,
|
|
264
|
-
prior=data.obj,
|
|
265
|
-
prior_predictive=None,
|
|
266
|
-
log_likelihood="log_lik",
|
|
267
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
268
|
-
coords=None,
|
|
269
|
-
dims=None,
|
|
270
|
-
dtypes=data.model.code(),
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
def get_inference_data_warmup_true_is_true(self, data, eight_schools_params):
|
|
274
|
-
"""vars as str."""
|
|
275
|
-
return from_cmdstanpy(
|
|
276
|
-
posterior=data.obj_warmup,
|
|
277
|
-
posterior_predictive="y_hat",
|
|
278
|
-
predictions="y_hat",
|
|
279
|
-
prior=data.obj_warmup,
|
|
280
|
-
prior_predictive="y_hat",
|
|
281
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
282
|
-
constant_data={"y": eight_schools_params["y"]},
|
|
283
|
-
predictions_constant_data={"y": eight_schools_params["y"]},
|
|
284
|
-
log_likelihood="log_lik",
|
|
285
|
-
coords={"school": np.arange(eight_schools_params["J"])},
|
|
286
|
-
dims={
|
|
287
|
-
"eta": ["extra_dim", "half school"],
|
|
288
|
-
"y": ["school"],
|
|
289
|
-
"log_lik": ["school"],
|
|
290
|
-
"y_hat": ["school"],
|
|
291
|
-
"theta": ["school"],
|
|
292
|
-
},
|
|
293
|
-
save_warmup=True,
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
def get_inference_data_warmup_false_is_true(self, data, eight_schools_params):
|
|
297
|
-
"""vars as str."""
|
|
298
|
-
return from_cmdstanpy(
|
|
299
|
-
posterior=data.obj,
|
|
300
|
-
posterior_predictive="y_hat",
|
|
301
|
-
predictions="y_hat",
|
|
302
|
-
prior=data.obj,
|
|
303
|
-
prior_predictive="y_hat",
|
|
304
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
305
|
-
constant_data={"y": eight_schools_params["y"]},
|
|
306
|
-
predictions_constant_data={"y": eight_schools_params["y"]},
|
|
307
|
-
log_likelihood="log_lik",
|
|
308
|
-
coords={"school": np.arange(eight_schools_params["J"])},
|
|
309
|
-
dims={
|
|
310
|
-
"eta": ["extra_dim", "half school"],
|
|
311
|
-
"y": ["school"],
|
|
312
|
-
"log_lik": ["school"],
|
|
313
|
-
"y_hat": ["school"],
|
|
314
|
-
"theta": ["school"],
|
|
315
|
-
},
|
|
316
|
-
save_warmup=True,
|
|
317
|
-
)
|
|
318
|
-
|
|
319
|
-
def get_inference_data_warmup_true_is_false(self, data, eight_schools_params):
|
|
320
|
-
"""vars as str."""
|
|
321
|
-
return from_cmdstanpy(
|
|
322
|
-
posterior=data.obj_warmup,
|
|
323
|
-
posterior_predictive="y_hat",
|
|
324
|
-
predictions="y_hat",
|
|
325
|
-
prior=data.obj_warmup,
|
|
326
|
-
prior_predictive="y_hat",
|
|
327
|
-
observed_data={"y": eight_schools_params["y"]},
|
|
328
|
-
constant_data={"y": eight_schools_params["y"]},
|
|
329
|
-
predictions_constant_data={"y": eight_schools_params["y"]},
|
|
330
|
-
log_likelihood="log_lik",
|
|
331
|
-
coords={"school": np.arange(eight_schools_params["J"])},
|
|
332
|
-
dims={
|
|
333
|
-
"eta": ["extra_dim", "half school"],
|
|
334
|
-
"y": ["school"],
|
|
335
|
-
"log_lik": ["school"],
|
|
336
|
-
"y_hat": ["school"],
|
|
337
|
-
"theta": ["school"],
|
|
338
|
-
},
|
|
339
|
-
save_warmup=False,
|
|
340
|
-
)
|
|
341
|
-
|
|
342
|
-
def test_sampler_stats(self, data, eight_schools_params):
|
|
343
|
-
inference_data = self.get_inference_data(data, eight_schools_params)
|
|
344
|
-
test_dict = {"sample_stats": ["lp", "diverging"]}
|
|
345
|
-
fails = check_multiple_attrs(test_dict, inference_data)
|
|
346
|
-
assert not fails
|
|
347
|
-
assert len(inference_data.sample_stats.lp.shape) == 2 # pylint: disable=no-member
|
|
348
|
-
|
|
349
|
-
def test_inference_data(self, data, eight_schools_params):
|
|
350
|
-
inference_data1 = self.get_inference_data(data, eight_schools_params)
|
|
351
|
-
inference_data2 = self.get_inference_data2(data, eight_schools_params)
|
|
352
|
-
inference_data3 = self.get_inference_data3(data, eight_schools_params)
|
|
353
|
-
inference_data4 = self.get_inference_data4(data, eight_schools_params)
|
|
354
|
-
inference_data5 = self.get_inference_data5(data, eight_schools_params)
|
|
355
|
-
|
|
356
|
-
# inference_data 1
|
|
357
|
-
test_dict = {
|
|
358
|
-
"posterior": ["theta"],
|
|
359
|
-
"predictions": ["y_hat"],
|
|
360
|
-
"observed_data": ["y"],
|
|
361
|
-
"constant_data": ["y"],
|
|
362
|
-
"predictions_constant_data": ["y"],
|
|
363
|
-
"log_likelihood": ["y", "~log_lik"],
|
|
364
|
-
"prior": ["theta"],
|
|
365
|
-
}
|
|
366
|
-
fails = check_multiple_attrs(test_dict, inference_data1)
|
|
367
|
-
assert not fails
|
|
368
|
-
|
|
369
|
-
# inference_data 2
|
|
370
|
-
test_dict = {
|
|
371
|
-
"posterior_predictive": ["y_hat"],
|
|
372
|
-
"predictions": ["y_hat", "log_lik"],
|
|
373
|
-
"observed_data": ["y"],
|
|
374
|
-
"sample_stats_prior": ["lp"],
|
|
375
|
-
"sample_stats": ["lp"],
|
|
376
|
-
"constant_data": list(eight_schools_params),
|
|
377
|
-
"predictions_constant_data": list(eight_schools_params),
|
|
378
|
-
"prior_predictive": ["y_hat"],
|
|
379
|
-
"log_likelihood": ["log_lik", "y_hat"],
|
|
380
|
-
}
|
|
381
|
-
fails = check_multiple_attrs(test_dict, inference_data2)
|
|
382
|
-
assert not fails
|
|
383
|
-
|
|
384
|
-
# inference_data 3
|
|
385
|
-
test_dict = {
|
|
386
|
-
"posterior_predictive": ["y_hat"],
|
|
387
|
-
"observed_data": ["y"],
|
|
388
|
-
"sample_stats_prior": ["lp"],
|
|
389
|
-
"sample_stats": ["lp"],
|
|
390
|
-
"prior_predictive": ["y_hat"],
|
|
391
|
-
"log_likelihood": ["log_lik"],
|
|
392
|
-
}
|
|
393
|
-
fails = check_multiple_attrs(test_dict, inference_data3)
|
|
394
|
-
assert not fails
|
|
395
|
-
assert inference_data3.posterior.eta.dtype.kind == "i" # pylint: disable=no-member
|
|
396
|
-
assert inference_data3.posterior.theta.dtype.kind == "i" # pylint: disable=no-member
|
|
397
|
-
|
|
398
|
-
# inference_data 4
|
|
399
|
-
test_dict = {
|
|
400
|
-
"posterior": ["eta", "mu", "theta"],
|
|
401
|
-
"prior": ["theta"],
|
|
402
|
-
"~log_likelihood": [""],
|
|
403
|
-
}
|
|
404
|
-
fails = check_multiple_attrs(test_dict, inference_data4)
|
|
405
|
-
assert not fails
|
|
406
|
-
assert len(inference_data4.posterior.theta.shape) == 3 # pylint: disable=no-member
|
|
407
|
-
assert len(inference_data4.posterior.eta.shape) == 4 # pylint: disable=no-member
|
|
408
|
-
assert len(inference_data4.posterior.mu.shape) == 2 # pylint: disable=no-member
|
|
409
|
-
assert inference_data4.posterior.eta.dtype.kind == "i" # pylint: disable=no-member
|
|
410
|
-
assert inference_data4.posterior.theta.dtype.kind == "i" # pylint: disable=no-member
|
|
411
|
-
|
|
412
|
-
# inference_data 5
|
|
413
|
-
test_dict = {
|
|
414
|
-
"posterior": ["eta", "mu", "theta"],
|
|
415
|
-
"prior": ["theta"],
|
|
416
|
-
"log_likelihood": ["log_lik"],
|
|
417
|
-
}
|
|
418
|
-
fails = check_multiple_attrs(test_dict, inference_data5)
|
|
419
|
-
assert inference_data5.posterior.eta.dtype.kind == "i" # pylint: disable=no-member
|
|
420
|
-
assert inference_data5.posterior.theta.dtype.kind == "i" # pylint: disable=no-member
|
|
421
|
-
|
|
422
|
-
def test_inference_data_warmup(self, data, eight_schools_params):
|
|
423
|
-
inference_data_true_is_true = self.get_inference_data_warmup_true_is_true(
|
|
424
|
-
data, eight_schools_params
|
|
425
|
-
)
|
|
426
|
-
inference_data_false_is_true = self.get_inference_data_warmup_false_is_true(
|
|
427
|
-
data, eight_schools_params
|
|
428
|
-
)
|
|
429
|
-
inference_data_true_is_false = self.get_inference_data_warmup_true_is_false(
|
|
430
|
-
data, eight_schools_params
|
|
431
|
-
)
|
|
432
|
-
inference_data_false_is_false = self.get_inference_data(data, eight_schools_params)
|
|
433
|
-
# inference_data warmup
|
|
434
|
-
test_dict = {
|
|
435
|
-
"posterior": ["theta"],
|
|
436
|
-
"predictions": ["y_hat"],
|
|
437
|
-
"observed_data": ["y"],
|
|
438
|
-
"constant_data": ["y"],
|
|
439
|
-
"predictions_constant_data": ["y"],
|
|
440
|
-
"log_likelihood": ["log_lik"],
|
|
441
|
-
"prior": ["theta"],
|
|
442
|
-
"warmup_posterior": ["theta"],
|
|
443
|
-
"warmup_predictions": ["y_hat"],
|
|
444
|
-
"warmup_log_likelihood": ["log_lik"],
|
|
445
|
-
"warmup_prior": ["theta"],
|
|
446
|
-
}
|
|
447
|
-
fails = check_multiple_attrs(test_dict, inference_data_true_is_true)
|
|
448
|
-
assert not fails
|
|
449
|
-
# inference_data no warmup
|
|
450
|
-
test_dict = {
|
|
451
|
-
"posterior": ["theta"],
|
|
452
|
-
"predictions": ["y_hat"],
|
|
453
|
-
"observed_data": ["y"],
|
|
454
|
-
"constant_data": ["y"],
|
|
455
|
-
"predictions_constant_data": ["y"],
|
|
456
|
-
"log_likelihood": ["log_lik"],
|
|
457
|
-
"prior": ["theta"],
|
|
458
|
-
"~warmup_posterior": [""],
|
|
459
|
-
"~warmup_predictions": [""],
|
|
460
|
-
"~warmup_log_likelihood": [""],
|
|
461
|
-
"~warmup_prior": [""],
|
|
462
|
-
}
|
|
463
|
-
fails = check_multiple_attrs(test_dict, inference_data_false_is_true)
|
|
464
|
-
assert not fails
|
|
465
|
-
# inference_data no warmup
|
|
466
|
-
test_dict = {
|
|
467
|
-
"posterior": ["theta"],
|
|
468
|
-
"predictions": ["y_hat"],
|
|
469
|
-
"observed_data": ["y"],
|
|
470
|
-
"constant_data": ["y"],
|
|
471
|
-
"predictions_constant_data": ["y"],
|
|
472
|
-
"log_likelihood": ["log_lik"],
|
|
473
|
-
"prior": ["theta"],
|
|
474
|
-
"~warmup_posterior": [""],
|
|
475
|
-
"~warmup_predictions": [""],
|
|
476
|
-
"~warmup_log_likelihood": [""],
|
|
477
|
-
"~warmup_prior": [""],
|
|
478
|
-
}
|
|
479
|
-
fails = check_multiple_attrs(test_dict, inference_data_true_is_false)
|
|
480
|
-
assert not fails
|
|
481
|
-
# inference_data no warmup
|
|
482
|
-
test_dict = {
|
|
483
|
-
"posterior": ["theta"],
|
|
484
|
-
"predictions": ["y_hat"],
|
|
485
|
-
"observed_data": ["y"],
|
|
486
|
-
"constant_data": ["y"],
|
|
487
|
-
"predictions_constant_data": ["y"],
|
|
488
|
-
"log_likelihood": ["y"],
|
|
489
|
-
"prior": ["theta"],
|
|
490
|
-
"~warmup_posterior": [""],
|
|
491
|
-
"~warmup_predictions": [""],
|
|
492
|
-
"~warmup_log_likelihood": [""],
|
|
493
|
-
"~warmup_prior": [""],
|
|
494
|
-
}
|
|
495
|
-
fails = check_multiple_attrs(test_dict, inference_data_false_is_false)
|
|
496
|
-
assert not fails
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
# pylint: disable=no-member, invalid-name, redefined-outer-name
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
import numpy as np
|
|
5
|
-
import pytest
|
|
6
|
-
|
|
7
|
-
from ... import from_emcee
|
|
8
|
-
|
|
9
|
-
from ..helpers import _emcee_lnprior as emcee_lnprior
|
|
10
|
-
from ..helpers import _emcee_lnprob as emcee_lnprob
|
|
11
|
-
from ..helpers import ( # pylint: disable=unused-import
|
|
12
|
-
chains,
|
|
13
|
-
check_multiple_attrs,
|
|
14
|
-
draws,
|
|
15
|
-
eight_schools_params,
|
|
16
|
-
importorskip,
|
|
17
|
-
load_cached_models,
|
|
18
|
-
needs_emcee3_func,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
# Skip all tests if emcee not installed
|
|
22
|
-
emcee = importorskip("emcee")
|
|
23
|
-
|
|
24
|
-
needs_emcee3 = needs_emcee3_func()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class TestDataEmcee:
|
|
28
|
-
arg_list = [
|
|
29
|
-
({}, {"posterior": ["var_0", "var_1", "var_7"], "observed_data": ["arg_0", "arg_1"]}),
|
|
30
|
-
(
|
|
31
|
-
{"var_names": ["mu", "tau", "eta"], "slices": [0, 1, slice(2, None)]},
|
|
32
|
-
{
|
|
33
|
-
"posterior": ["mu", "tau", "eta"],
|
|
34
|
-
"observed_data": ["arg_0", "arg_1"],
|
|
35
|
-
"sample_stats": ["lp"],
|
|
36
|
-
},
|
|
37
|
-
),
|
|
38
|
-
(
|
|
39
|
-
{
|
|
40
|
-
"arg_groups": ["observed_data", "constant_data"],
|
|
41
|
-
"blob_names": ["y", "y"],
|
|
42
|
-
"blob_groups": ["log_likelihood", "posterior_predictive"],
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"posterior": ["var_0", "var_1", "var_7"],
|
|
46
|
-
"observed_data": ["arg_0"],
|
|
47
|
-
"constant_data": ["arg_1"],
|
|
48
|
-
"log_likelihood": ["y"],
|
|
49
|
-
"posterior_predictive": ["y"],
|
|
50
|
-
"sample_stats": ["lp"],
|
|
51
|
-
},
|
|
52
|
-
),
|
|
53
|
-
(
|
|
54
|
-
{
|
|
55
|
-
"blob_names": ["log_likelihood", "y"],
|
|
56
|
-
"dims": {"eta": ["school"], "log_likelihood": ["school"], "y": ["school"]},
|
|
57
|
-
"var_names": ["mu", "tau", "eta"],
|
|
58
|
-
"slices": [0, 1, slice(2, None)],
|
|
59
|
-
"arg_names": ["y", "sigma"],
|
|
60
|
-
"arg_groups": ["observed_data", "constant_data"],
|
|
61
|
-
"coords": {"school": range(8)},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"posterior": ["mu", "tau", "eta"],
|
|
65
|
-
"observed_data": ["y"],
|
|
66
|
-
"constant_data": ["sigma"],
|
|
67
|
-
"log_likelihood": ["log_likelihood", "y"],
|
|
68
|
-
"sample_stats": ["lp"],
|
|
69
|
-
},
|
|
70
|
-
),
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
@pytest.fixture(scope="class")
|
|
74
|
-
def data(self, eight_schools_params, draws, chains):
|
|
75
|
-
class Data:
|
|
76
|
-
# chains are not used
|
|
77
|
-
# emcee uses lots of walkers
|
|
78
|
-
obj = load_cached_models(eight_schools_params, draws, chains, "emcee")["emcee"]
|
|
79
|
-
|
|
80
|
-
return Data
|
|
81
|
-
|
|
82
|
-
def get_inference_data_reader(self, **kwargs):
|
|
83
|
-
from emcee import backends # pylint: disable=no-name-in-module
|
|
84
|
-
|
|
85
|
-
here = os.path.dirname(os.path.abspath(__file__))
|
|
86
|
-
data_directory = os.path.join(here, "..", "saved_models")
|
|
87
|
-
filepath = os.path.join(data_directory, "reader_testfile.h5")
|
|
88
|
-
assert os.path.exists(filepath)
|
|
89
|
-
assert os.path.getsize(filepath)
|
|
90
|
-
reader = backends.HDFBackend(filepath, read_only=True)
|
|
91
|
-
return from_emcee(reader, **kwargs)
|
|
92
|
-
|
|
93
|
-
@pytest.mark.parametrize("test_args", arg_list)
|
|
94
|
-
def test_inference_data(self, data, test_args):
|
|
95
|
-
kwargs, test_dict = test_args
|
|
96
|
-
inference_data = from_emcee(data.obj, **kwargs)
|
|
97
|
-
fails = check_multiple_attrs(test_dict, inference_data)
|
|
98
|
-
assert not fails
|
|
99
|
-
|
|
100
|
-
@needs_emcee3
|
|
101
|
-
@pytest.mark.parametrize("test_args", arg_list)
|
|
102
|
-
def test_inference_data_reader(self, test_args):
|
|
103
|
-
kwargs, test_dict = test_args
|
|
104
|
-
kwargs = {k: i for k, i in kwargs.items() if k not in ("arg_names", "arg_groups")}
|
|
105
|
-
inference_data = self.get_inference_data_reader(**kwargs)
|
|
106
|
-
test_dict.pop("observed_data")
|
|
107
|
-
if "constant_data" in test_dict:
|
|
108
|
-
test_dict.pop("constant_data")
|
|
109
|
-
fails = check_multiple_attrs(test_dict, inference_data)
|
|
110
|
-
assert not fails
|
|
111
|
-
|
|
112
|
-
def test_verify_var_names(self, data):
|
|
113
|
-
with pytest.raises(ValueError):
|
|
114
|
-
from_emcee(data.obj, var_names=["not", "enough"])
|
|
115
|
-
|
|
116
|
-
def test_verify_arg_names(self, data):
|
|
117
|
-
with pytest.raises(ValueError):
|
|
118
|
-
from_emcee(data.obj, arg_names=["not enough"])
|
|
119
|
-
|
|
120
|
-
@pytest.mark.parametrize("slices", [[0, 0, slice(2, None)], [0, 1, slice(1, None)]])
|
|
121
|
-
def test_slices_warning(self, data, slices):
|
|
122
|
-
with pytest.warns(UserWarning):
|
|
123
|
-
from_emcee(data.obj, slices=slices)
|
|
124
|
-
|
|
125
|
-
def test_no_blobs_error(self):
|
|
126
|
-
sampler = emcee.EnsembleSampler(6, 1, lambda x: -(x**2))
|
|
127
|
-
sampler.run_mcmc(np.random.normal(size=(6, 1)), 20)
|
|
128
|
-
with pytest.raises(ValueError):
|
|
129
|
-
from_emcee(sampler, blob_names=["inexistent"])
|
|
130
|
-
|
|
131
|
-
def test_peculiar_blobs(self, data):
|
|
132
|
-
sampler = emcee.EnsembleSampler(6, 1, lambda x: (-(x**2), (np.random.normal(x), 3)))
|
|
133
|
-
sampler.run_mcmc(np.random.normal(size=(6, 1)), 20)
|
|
134
|
-
inference_data = from_emcee(sampler, blob_names=["normal", "threes"])
|
|
135
|
-
fails = check_multiple_attrs({"log_likelihood": ["normal", "threes"]}, inference_data)
|
|
136
|
-
assert not fails
|
|
137
|
-
inference_data = from_emcee(data.obj, blob_names=["mix"])
|
|
138
|
-
fails = check_multiple_attrs({"log_likelihood": ["mix"]}, inference_data)
|
|
139
|
-
assert not fails
|
|
140
|
-
|
|
141
|
-
def test_single_blob(self):
|
|
142
|
-
sampler = emcee.EnsembleSampler(6, 1, lambda x: (-(x**2), 3))
|
|
143
|
-
sampler.run_mcmc(np.random.normal(size=(6, 1)), 20)
|
|
144
|
-
inference_data = from_emcee(sampler, blob_names=["blob"], blob_groups=["blob_group"])
|
|
145
|
-
fails = check_multiple_attrs({"blob_group": ["blob"]}, inference_data)
|
|
146
|
-
assert not fails
|
|
147
|
-
|
|
148
|
-
@pytest.mark.parametrize(
|
|
149
|
-
"blob_args",
|
|
150
|
-
[
|
|
151
|
-
(ValueError, ["a", "b"], ["prior"]),
|
|
152
|
-
(ValueError, ["too", "many", "names"], None),
|
|
153
|
-
(SyntaxError, ["a", "b"], ["posterior", "observed_data"]),
|
|
154
|
-
],
|
|
155
|
-
)
|
|
156
|
-
def test_bad_blobs(self, data, blob_args):
|
|
157
|
-
error, names, groups = blob_args
|
|
158
|
-
with pytest.raises(error):
|
|
159
|
-
from_emcee(data.obj, blob_names=names, blob_groups=groups)
|
|
160
|
-
|
|
161
|
-
def test_ln_funcs_for_infinity(self):
|
|
162
|
-
# after dropping Python 3.5 support use underscore 1_000_000
|
|
163
|
-
ary = np.ones(10)
|
|
164
|
-
ary[1] = -1
|
|
165
|
-
assert np.isinf(emcee_lnprior(ary))
|
|
166
|
-
assert np.isinf(emcee_lnprob(ary, ary[2:], ary[2:])[0])
|