-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use sigma instead of sd, remove deprecationwarning #4344
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
+10
−31
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6169b5b
remove sd deprecation warning
MarcoGorelli fbc9355
sd -> sigma in pymc3/tests/test_models_linear.py::TestGLM
MarcoGorelli 392b83c
update cls.sd in tests
MarcoGorelli 4173b5e
noop
MarcoGorelli b7ec8de
don't delete self.sd
MarcoGorelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -478,9 +478,8 @@ class Normal(Continuous): | |
def __init__(self, mu=0, sigma=None, tau=None, sd=None, **kwargs): | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
self.sigma = self.sd = tt.as_tensor_variable(sigma) | ||
self.sigma = tt.as_tensor_variable(sigma) | ||
self.tau = tt.as_tensor_variable(tau) | ||
|
||
self.mean = self.median = self.mode = self.mu = mu = tt.as_tensor_variable(floatX(mu)) | ||
|
@@ -640,9 +639,8 @@ def __init__( | |
): | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
self.sigma = self.sd = tt.as_tensor_variable(sigma) | ||
self.sigma = tt.as_tensor_variable(sigma) | ||
self.tau = tt.as_tensor_variable(tau) | ||
self.lower_check = tt.as_tensor_variable(floatX(lower)) if lower is not None else lower | ||
self.upper_check = tt.as_tensor_variable(floatX(upper)) if upper is not None else upper | ||
|
@@ -835,11 +833,10 @@ class HalfNormal(PositiveContinuous): | |
def __init__(self, sigma=None, tau=None, sd=None, *args, **kwargs): | ||
if sd is not None: | ||
sigma = sd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of deleting, could you raise an error here and advice using sigma The reason being that |
||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
super().__init__(*args, **kwargs) | ||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
|
||
self.sigma = self.sd = sigma = tt.as_tensor_variable(sigma) | ||
self.sigma = sigma = tt.as_tensor_variable(sigma) | ||
self.tau = tau = tt.as_tensor_variable(tau) | ||
|
||
self.mean = tt.sqrt(2 / (np.pi * self.tau)) | ||
|
@@ -1218,7 +1215,6 @@ def __init__(self, alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, * | |
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
alpha, beta = self.get_alpha_beta(alpha, beta, mu, sigma) | ||
self.alpha = alpha = tt.as_tensor_variable(floatX(alpha)) | ||
self.beta = beta = tt.as_tensor_variable(floatX(beta)) | ||
|
@@ -1724,13 +1720,12 @@ def __init__(self, mu=0, sigma=None, tau=None, sd=None, *args, **kwargs): | |
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
|
||
self.mu = mu = tt.as_tensor_variable(floatX(mu)) | ||
self.tau = tau = tt.as_tensor_variable(tau) | ||
self.sigma = self.sd = sigma = tt.as_tensor_variable(sigma) | ||
self.sigma = sigma = tt.as_tensor_variable(sigma) | ||
|
||
self.mean = tt.exp(self.mu + 1.0 / (2 * self.tau)) | ||
self.median = tt.exp(self.mu) | ||
|
@@ -1884,15 +1879,13 @@ class StudentT(Continuous): | |
""" | ||
|
||
def __init__(self, nu, mu=0, lam=None, sigma=None, sd=None, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
self.nu = nu = tt.as_tensor_variable(floatX(nu)) | ||
lam, sigma = get_tau_sigma(tau=lam, sigma=sigma) | ||
self.lam = lam = tt.as_tensor_variable(lam) | ||
self.sigma = self.sd = sigma = tt.as_tensor_variable(sigma) | ||
self.sigma = sigma = tt.as_tensor_variable(sigma) | ||
self.mean = self.median = self.mode = self.mu = mu = tt.as_tensor_variable(mu) | ||
|
||
self.variance = tt.switch((nu > 2) * 1, (1 / self.lam) * (nu / (nu - 2)), np.inf) | ||
|
@@ -2397,7 +2390,6 @@ def __init__(self, alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, * | |
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
alpha, beta = self.get_alpha_beta(alpha, beta, mu, sigma) | ||
self.alpha = alpha = tt.as_tensor_variable(floatX(alpha)) | ||
|
@@ -2545,7 +2537,6 @@ def __init__(self, alpha=None, beta=None, mu=None, sigma=None, sd=None, *args, * | |
|
||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
alpha, beta = InverseGamma._get_alpha_beta(alpha, beta, mu, sigma) | ||
self.alpha = alpha = tt.as_tensor_variable(floatX(alpha)) | ||
|
@@ -2902,12 +2893,11 @@ def __init__(self, nu=1, sigma=None, lam=None, sd=None, *args, **kwargs): | |
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
self.mode = tt.as_tensor_variable(0) | ||
lam, sigma = get_tau_sigma(lam, sigma) | ||
self.median = tt.as_tensor_variable(sigma) | ||
self.sigma = self.sd = tt.as_tensor_variable(sigma) | ||
self.sigma = tt.as_tensor_variable(sigma) | ||
self.lam = tt.as_tensor_variable(lam) | ||
self.nu = nu = tt.as_tensor_variable(floatX(nu)) | ||
|
||
|
@@ -3041,10 +3031,9 @@ def __init__(self, mu=0.0, sigma=None, nu=None, sd=None, *args, **kwargs): | |
|
||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
self.mu = mu = tt.as_tensor_variable(floatX(mu)) | ||
self.sigma = self.sd = sigma = tt.as_tensor_variable(floatX(sigma)) | ||
self.sigma = sigma = tt.as_tensor_variable(floatX(sigma)) | ||
self.nu = nu = tt.as_tensor_variable(floatX(nu)) | ||
self.mean = mu + nu | ||
self.variance = (sigma ** 2) + (nu ** 2) | ||
|
@@ -3317,12 +3306,11 @@ def __init__(self, mu=0.0, sigma=None, tau=None, alpha=1, sd=None, *args, **kwar | |
|
||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
self.mu = mu = tt.as_tensor_variable(floatX(mu)) | ||
self.tau = tt.as_tensor_variable(tau) | ||
self.sigma = self.sd = tt.as_tensor_variable(sigma) | ||
self.sigma = tt.as_tensor_variable(sigma) | ||
|
||
self.alpha = alpha = tt.as_tensor_variable(floatX(alpha)) | ||
|
||
|
@@ -3721,11 +3709,10 @@ def __init__(self, nu=None, sigma=None, b=None, sd=None, *args, **kwargs): | |
super().__init__(*args, **kwargs) | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
|
||
nu, b, sigma = self.get_nu_b(nu, b, sigma) | ||
self.nu = nu = tt.as_tensor_variable(floatX(nu)) | ||
self.sigma = self.sd = sigma = tt.as_tensor_variable(floatX(sigma)) | ||
self.sigma = sigma = tt.as_tensor_variable(floatX(sigma)) | ||
self.b = b = tt.as_tensor_variable(floatX(b)) | ||
|
||
nu_sigma_ratio = -(nu ** 2) / (2 * sigma ** 2) | ||
|
@@ -3994,10 +3981,9 @@ class LogitNormal(UnitContinuous): | |
def __init__(self, mu=0, sigma=None, tau=None, sd=None, **kwargs): | ||
if sd is not None: | ||
sigma = sd | ||
warnings.warn("sd is deprecated, use sigma instead", DeprecationWarning) | ||
self.mu = mu = tt.as_tensor_variable(floatX(mu)) | ||
tau, sigma = get_tau_sigma(tau=tau, sigma=sigma) | ||
self.sigma = self.sd = tt.as_tensor_variable(sigma) | ||
self.sigma = tt.as_tensor_variable(sigma) | ||
self.tau = tau = tt.as_tensor_variable(tau) | ||
|
||
self.median = invlogit(mu) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave
self.sd
too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can revert this, but wouldn't it be safer to have a single source of truth for the value of sigma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your sentiment, but from user perspective, setting
sd=x
I would expect there to be ay.sd
, and if we're keeping it around, which isn't the cleanest anyway, I don't see what we gain by changing this one thing in a subtle way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, thanks for explaining!