Skip to content
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

Replace deprecation warnings with errors for cdf and ci #126

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:
- "3.6"
- "3.7"
script:
- pip install -U sphinx deprecated
- pip install -U sphinx
- sphinx-build -M html docs/ docs/_build/ -W # Try building it before installing the rest, should work
- pip install -U coveralls flaky pytest pytest-cov
- pip install .
Expand Down
19 changes: 4 additions & 15 deletions convoys/multi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from deprecated.sphinx import deprecated
import numpy
from convoys import regression
from convoys import single
Expand Down Expand Up @@ -44,14 +43,9 @@ def predict_ci(self, group, t, ci):
def rvs(self, group, *args, **kwargs):
return self.base_model.rvs(self._get_x(group), *args, **kwargs)

@deprecated(version='0.2.0',
reason='Use :meth:`predict` or :meth:`predict_ci` instead.')
def cdf(self, group, t, ci=None):
'''Returns the predicted values.'''
if ci is not None:
return self.predict_ci(group, t, ci)
else:
return self.predict(group, t)
raise Exception('This method has been removed in 0.3.0. '
'Use `predict` or `predict_ci`.')


class SingleToMulti(MultiModel):
Expand Down Expand Up @@ -79,14 +73,9 @@ def predict(self, group, t):
def predict_ci(self, group, t, ci):
return self._group2model[group].predict_ci(t, ci)

@deprecated(version='0.2.0',
reason='Use :meth:`predict` or :meth:`predict_ci` instead')
def cdf(self, group, t, ci=None):
'''Returns the predicted values.'''
if ci is not None:
return self.predict_ci(group, t, ci)
else:
return self.predict(group, t)
raise Exception('This method has been removed in 0.3.0. '
'Use `predict` or `predict_ci`.')


class Exponential(RegressionToMulti):
Expand Down
21 changes: 6 additions & 15 deletions convoys/regression.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from convoys import autograd_scipy_monkeypatch # NOQA
import autograd
from autograd_gamma import gammainc
from deprecated.sphinx import deprecated
import emcee
import numpy
from scipy.special import gammaincinv
Expand Down Expand Up @@ -174,9 +173,8 @@ def __init__(self, mcmc=False, fix_k=None, fix_p=None, hierarchical=True,
self._hierarchical = hierarchical
self._flavor = flavor
if ci is not None:
warnings.warn('The `ci` argument is deprecated in 0.2.1 in favor '
' of `mcmc`.', DeprecationWarning)
self._mcmc = ci
raise Exception('This method has been removed in 0.3.0. '
'Use the `mcmc` argument instead.')

def fit(self, X, B, T, W=None):
'''Fits the model.
Expand Down Expand Up @@ -367,20 +365,13 @@ def rvs(self, x, n_curves=1, n_samples=1, T=None):

return B, C

@deprecated(version='0.2.0',
reason='Use :meth:`predict` or :meth:`predict_ci` instead.')
def cdf(self, x, t, ci=False):
'''Returns the predicted values.'''
if ci:
return self.predict_ci(x, t)
else:
return self.predict(x, t)
raise Exception('This method has been removed in 0.3.0. '
'Use `predict` or `predict_ci`.')

@deprecated(version='0.2.0',
reason='Use :meth:`predict_posteriori` instead.')
def cdf_posteriori(self, x, t):
'''Returns the a posterior distribution of the predicted values.'''
return self.predict_posteriori(x, t)
raise Exception('This method has been removed in 0.3.0. '
'Use `predict_posteriori`.')


class Exponential(GeneralizedGamma):
Expand Down
10 changes: 2 additions & 8 deletions convoys/single.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from deprecated.sphinx import deprecated
import numpy
from scipy.special import expit, logit
import scipy.stats
Expand Down Expand Up @@ -87,11 +86,6 @@ def predict_ci(self, t, ci=0.8):
)
return res

@deprecated(version='0.2.0',
reason='Use :meth:`predict` or :meth:`predict_ci` instead.')
def cdf(self, t, ci=None):
'''Returns the predicted values.'''
if ci is not None:
return self.predict_ci(t)
else:
return self.predict(t)
raise Exception('This method has been removed in 0.3.0. '
'Use `predict` or `predict_ci`.')
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'''

setup(name='convoys',
version='0.2.1',
version='0.3.0',
description='Fit machine learning models to predict conversion using Weibull and Gamma distributions',
long_description=long_description,
url='https://better.engineering/convoys',
Expand All @@ -21,7 +21,6 @@
install_requires=[
'autograd',
'autograd-gamma>=0.2.0',
'deprecated',
'emcee>=3.0.0',
'matplotlib>=2.0.0',
'pandas>=0.24.0',
Expand Down
4 changes: 0 additions & 4 deletions test_convoys.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ def test_output_shapes(c=0.3, lambd=0.1, n=1000, k=5):
assert model.predict_ci([[X[0]], [X[1]]], [[0, 1, 2]], ci=0.8) \
.shape == (2, 3, 3)

# Assert old interface still works
assert model.cdf(X[0], 0).shape == ()
assert model.cdf(X[0], 0, ci=0.8).shape == (3,)

# Fit model without ci (should be the same)
model = convoys.regression.Exponential(mcmc=False)
model.fit(X, B, T)
Expand Down