Unverified Commit d59a6e80 authored by michaelosthege's avatar michaelosthege Committed by GitHub

Remove deprecated stuff (#3906)

* remove file which is not used

* remove deprecated code

* repair tests and notebooks that used deprecated API

* mention #3906
Co-authored-by: default avatarMichael Osthege <zufallsprinzip@hotmail.de>
parent cc45303b
# Build ePub (pdf is currently failing)
formats:
- epub
# pip requirements file for building sphinx docs (e.g. nbsphinx)
requirements_file: docs/requirements-docs.txt
# can also specify a conda env file if pip isn't enough, for example:
# conda:
# file: environment.yml
# Use python 3 for building
python:
version: 3.5
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
- Deprecated `sd` in version 3.7 has been replaced by `sigma` now raises `DepreciationWarning` on using `sd` in continuous, mixed and timeseries distributions. (see #3837 and #3688). - Deprecated `sd` in version 3.7 has been replaced by `sigma` now raises `DepreciationWarning` on using `sd` in continuous, mixed and timeseries distributions. (see #3837 and #3688).
- In named models, `pm.Data` objects now get model-relative names (see [#3843](https://github.com/pymc-devs/pymc3/pull/3843)). - In named models, `pm.Data` objects now get model-relative names (see [#3843](https://github.com/pymc-devs/pymc3/pull/3843)).
- `pm.sample` now takes 1000 draws and 1000 tuning samples by default, instead of 500 previously (see [#3855](https://github.com/pymc-devs/pymc3/pull/3855)). - `pm.sample` now takes 1000 draws and 1000 tuning samples by default, instead of 500 previously (see [#3855](https://github.com/pymc-devs/pymc3/pull/3855)).
- Dropped some deprecated kwargs and functions (see [#3906](https://github.com/pymc-devs/pymc3/pull/3906))
- Dropped the outdated 'nuts' initialization method for `pm.sample` (see [#3863](https://github.com/pymc-devs/pymc3/pull/3863)). - Dropped the outdated 'nuts' initialization method for `pm.sample` (see [#3863](https://github.com/pymc-devs/pymc3/pull/3863)).
- Moved argument division out of `NegativeBinomial` `random` method. Fixes [#3864](https://github.com/pymc-devs/pymc3/issues/3864) in the style of [#3509](https://github.com/pymc-devs/pymc3/pull/3509). - Moved argument division out of `NegativeBinomial` `random` method. Fixes [#3864](https://github.com/pymc-devs/pymc3/issues/3864) in the style of [#3509](https://github.com/pymc-devs/pymc3/pull/3509).
- The Dirichlet distribution now raises a ValueError when it's initialized with <= 0 values (see [#3853](https://github.com/pymc-devs/pymc3/pull/3853)). - The Dirichlet distribution now raises a ValueError when it's initialized with <= 0 values (see [#3853](https://github.com/pymc-devs/pymc3/pull/3853)).
......
...@@ -1284,7 +1284,7 @@ ...@@ -1284,7 +1284,7 @@
} }
], ],
"source": [ "source": [
"pm.gelman_rubin(trace)" "pm.rhat(trace)"
] ]
}, },
{ {
......
...@@ -594,7 +594,7 @@ ...@@ -594,7 +594,7 @@
} }
], ],
"source": [ "source": [
"max(np.max(gr_stats) for gr_stats in pm.gelman_rubin(weibull_trace).values())" "max(np.max(gr_stats) for gr_stats in pm.rhat(weibull_trace).values())"
] ]
}, },
{ {
...@@ -904,7 +904,7 @@ ...@@ -904,7 +904,7 @@
} }
], ],
"source": [ "source": [
"max(np.max(gr_stats) for gr_stats in pm.gelman_rubin(log_logistic_trace).values())" "max(np.max(gr_stats) for gr_stats in pm.rhat(log_logistic_trace).values())"
] ]
}, },
{ {
...@@ -1030,4 +1030,4 @@ ...@@ -1030,4 +1030,4 @@
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 2
} }
\ No newline at end of file
...@@ -801,7 +801,7 @@ ...@@ -801,7 +801,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"bfmi = np.max(pm.stats.bfmi(trace))\n", "bfmi = np.max(pm.stats.bfmi(trace))\n",
"max_gr = max(np.max(gr_stats) for gr_stats in pm.stats.gelman_rubin(trace).values()).values" "max_gr = max(np.max(gr_stats) for gr_stats in pm.stats.rhat(trace).values()).values"
] ]
}, },
{ {
...@@ -1470,4 +1470,4 @@ ...@@ -1470,4 +1470,4 @@
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 4 "nbformat_minor": 4
} }
\ No newline at end of file
...@@ -52,7 +52,7 @@ def run(steppers, p): ...@@ -52,7 +52,7 @@ def run(steppers, p):
runtimes[name] = time.time() - t_start runtimes[name] = time.time() - t_start
print('{} samples across {} chains'.format(len(mt) * mt.nchains, mt.nchains)) print('{} samples across {} chains'.format(len(mt) * mt.nchains, mt.nchains))
traces[name] = mt traces[name] = mt
en = pm.diagnostics.effective_n(mt) en = pm.ess(mt)
print('effective: {}\r\n'.format(en)) print('effective: {}\r\n'.format(en))
if USE_XY: if USE_XY:
effn[name] = np.mean(en['x']) / len(mt) / mt.nchains effn[name] = np.mean(en['x']) / len(mt) / mt.nchains
......
...@@ -368,36 +368,9 @@ def sample( ...@@ -368,36 +368,9 @@ def sample(
""" """
model = modelcontext(model) model = modelcontext(model)
nuts_kwargs = kwargs.pop("nuts_kwargs", None)
if nuts_kwargs is not None:
warnings.warn(
"The nuts_kwargs argument has been deprecated. Pass step "
"method arguments directly to sample instead",
DeprecationWarning,
)
kwargs.update(nuts_kwargs)
step_kwargs = kwargs.pop("step_kwargs", None)
if step_kwargs is not None:
warnings.warn(
"The step_kwargs argument has been deprecated. Pass step "
"method arguments directly to sample instead",
DeprecationWarning,
)
kwargs.update(step_kwargs)
if cores is None: if cores is None:
cores = min(4, _cpu_count()) cores = min(4, _cpu_count())
if "njobs" in kwargs:
cores = kwargs["njobs"]
warnings.warn(
"The njobs argument has been deprecated. Use cores instead.", DeprecationWarning
)
if "nchains" in kwargs:
chains = kwargs["nchains"]
warnings.warn(
"The nchains argument has been deprecated. Use chains instead.", DeprecationWarning
)
if chains is None: if chains is None:
chains = max(2, cores) chains = max(2, cores)
if isinstance(start, dict): if isinstance(start, dict):
...@@ -412,11 +385,6 @@ def sample( ...@@ -412,11 +385,6 @@ def sample(
random_seed = [np.random.randint(2 ** 30) for _ in range(chains)] random_seed = [np.random.randint(2 ** 30) for _ in range(chains)]
if not isinstance(random_seed, Iterable): if not isinstance(random_seed, Iterable):
raise TypeError("Invalid value for `random_seed`. Must be tuple, list or int") raise TypeError("Invalid value for `random_seed`. Must be tuple, list or int")
if "chain" in kwargs:
chain_idx = kwargs["chain"]
warnings.warn(
"The chain argument has been deprecated. Use chain_idx instead.", DeprecationWarning
)
if start is not None: if start is not None:
for start_vals in start: for start_vals in start:
......
...@@ -53,19 +53,6 @@ summary = map_args(az.summary) ...@@ -53,19 +53,6 @@ summary = map_args(az.summary)
waic = map_args(az.waic) waic = map_args(az.waic)
def gelman_rubin(*args, **kwargs):
warnings.warn("gelman_rubin has been deprecated. In the future, use rhat instead.")
return rhat(*args, **kwargs)
gelman_rubin.__doc__ = rhat.__doc__
def effective_n(*args, **kwargs):
warnings.warn("effective_n has been deprecated. In the future, use ess instead.")
return ess(*args, **kwargs)
effective_n.__doc__ = ess.__doc__
__all__ = [ __all__ = [
"bfmi", "bfmi",
"compare", "compare",
...@@ -78,6 +65,4 @@ __all__ = [ ...@@ -78,6 +65,4 @@ __all__ = [
"rhat", "rhat",
"summary", "summary",
"waic", "waic",
"gelman_rubin", # deprecated, remove after 3.8
"effective_n", # deprecated, remove after 3.8
] ]
...@@ -149,12 +149,12 @@ class BaseSampler(SeededTest): ...@@ -149,12 +149,12 @@ class BaseSampler(SeededTest):
def test_neff(self): def test_neff(self):
if hasattr(self, 'min_n_eff'): if hasattr(self, 'min_n_eff'):
n_eff = pm.effective_n(self.trace[self.burn:]) n_eff = pm.ess(self.trace[self.burn:])
for var in n_eff: for var in n_eff:
npt.assert_array_less(self.min_n_eff, n_eff[var]) npt.assert_array_less(self.min_n_eff, n_eff[var])
def test_Rhat(self): def test_Rhat(self):
rhat = pm.gelman_rubin(self.trace[self.burn:]) rhat = pm.rhat(self.trace[self.burn:])
for var in rhat: for var in rhat:
npt.assert_allclose(rhat[var], 1, rtol=0.01) npt.assert_allclose(rhat[var], 1, rtol=0.01)
......
...@@ -103,7 +103,7 @@ class TestSample(SeededTest): ...@@ -103,7 +103,7 @@ class TestSample(SeededTest):
assert "'foo'" in str(excinfo.value) assert "'foo'" in str(excinfo.value)
with pytest.raises(ValueError) as excinfo: with pytest.raises(ValueError) as excinfo:
pm.sample(50, tune=0, init=None, step_kwargs={"foo": {}}) pm.sample(50, tune=0, init=None, foo={})
assert "foo" in str(excinfo.value) assert "foo" in str(excinfo.value)
with pytest.raises(ValueError) as excinfo: with pytest.raises(ValueError) as excinfo:
......
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