Skip to content

raise not implemented error for non refactored distributions and functions #5799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pymc/distributions/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@ class GARCH11(distribution.Continuous):
initial_vol >= 0, initial volatility, sigma_0
"""

def __new__(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

@classmethod
def dist(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

def __init__(self, omega, alpha_1, beta_1, initial_vol, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -705,6 +712,13 @@ class EulerMaruyama(distribution.Continuous):
parameters of the SDE, passed as ``*args`` to ``sde_fn``
"""

def __new__(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

@classmethod
def dist(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

def __init__(self, dt, sde_fn, sde_pars, *args, **kwds):
super().__init__(*args, **kwds)
self.dt = dt = at.as_tensor_variable(dt)
Expand Down Expand Up @@ -757,6 +771,13 @@ class MvGaussianRandomWalk(distribution.Continuous):

"""

def __new__(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

@classmethod
def dist(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

def __init__(
self, mu=0.0, cov=None, tau=None, chol=None, lower=True, init=None, *args, **kwargs
):
Expand Down Expand Up @@ -879,6 +900,13 @@ class MvStudentTRandomWalk(MvGaussianRandomWalk):
distribution for initial value (Defaults to Flat())
"""

def __new__(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

@classmethod
def dist(cls, *args, **kwargs):
raise NotImplementedError(f"{cls.__name__} has not yet been ported to PyMC 4.0.")

def __init__(self, nu, *args, **kwargs):
super().__init__(*args, **kwargs)
self.nu = at.as_tensor_variable(nu)
Expand Down
2 changes: 2 additions & 0 deletions pymc/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,8 @@ def sample_posterior_predictive_w(
weighted models (default), or a dictionary with variable names as keys, and samples as
numpy arrays.
"""
raise NotImplementedError(f"sample_posterior_predictive_w has not yet been ported to PyMC 4.0.")

if isinstance(traces[0], InferenceData):
n_samples = [
trace.posterior.sizes["chain"] * trace.posterior.sizes["draw"] for trace in traces
Expand Down
4 changes: 2 additions & 2 deletions pymc/tests/test_distributions_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def test_moment(self, size, expected):
assert_moment_is_expected(model, expected, check_finite_logp=False)


@pytest.mark.xfail(reason="Timeseries not refactored")
@pytest.mark.xfail(reason="Timeseries not refactored", raises=NotImplementedError)
def test_GARCH11():
# test data ~ N(0, 1)
data = np.array(
Expand Down Expand Up @@ -496,7 +496,7 @@ def _gen_sde_path(sde, pars, dt, n, x0):
return np.array(xs)


@pytest.mark.xfail(reason="Timeseries not refactored")
@pytest.mark.xfail(reason="Timeseries not refactored", raises=NotImplementedError)
def test_linear():
lam = -0.78
sig2 = 5e-3
Expand Down
5 changes: 3 additions & 2 deletions pymc/tests/test_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,10 @@ def test_deterministics_out_of_idata(self, multitrace):
assert np.all(np.abs(ppc.posterior_predictive.c + 4) <= 0.1)


@pytest.mark.xfail(
reason="sample_posterior_predictive_w not refactored for v4", raises=NotImplementedError
)
class TestSamplePPCW(SeededTest):
@pytest.mark.xfail(reason="sample_posterior_predictive_w not refactored for v4")
def test_sample_posterior_predictive_w(self):
data0 = np.random.normal(0, 1, size=50)
warning_msg = "The number of samples is too small to check convergence reliably"
Expand Down Expand Up @@ -986,7 +988,6 @@ def test_sample_posterior_predictive_w(self):
):
pm.sample_posterior_predictive_w([trace_0, trace_2], 100, [model_0, model_2])

@pytest.mark.xfail(reason="sample_posterior_predictive_w not refactored for v4")
def test_potentials_warning(self):
warning_msg = "The effect of Potentials on other parameters is ignored during"
with pm.Model() as m:
Expand Down