Skip to content

Refactor get_tau_sigma to handle lists #5747

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 27 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b2a9e40
Refactor get_tau_sigma to handle lists
fonnesbeck May 5, 2022
f264bfa
Fixed syntax error
fonnesbeck May 5, 2022
277b5e7
Black formatted
fonnesbeck May 5, 2022
7902ab9
Change assertions to ValueError raises
fonnesbeck May 6, 2022
6679b61
Prior predictions constant data (#5723)
TimOliverMaier Apr 22, 2022
a20c970
Fix issue probably-meant-fstring found at https://codereview.doctor …
code-review-doctor Apr 24, 2022
4130f04
Add coords argument to pymc.set_data (#5588)
soma2000-lang Apr 24, 2022
64e01d5
remove MultinomialRV override
danhphan Mar 19, 2022
e89d803
⬆️ UPGRADE: Autoupdate pre-commit config
twiecki Apr 25, 2022
904eac8
Group GaussianRandomWalk tests in single class
ricardoV94 Apr 27, 2022
16b4afa
Infer steps from shape in GaussianRandomWalk
canyon289 Apr 5, 2022
fe8634f
Unpin upper limit on numpydoc
michaelosthege May 1, 2022
07501b9
⬆️ UPGRADE: Autoupdate pre-commit config
twiecki May 2, 2022
7eaea58
Standardize docstrings of input dists arguments and add warning about…
ricardoV94 May 3, 2022
1690482
Remove unnecessary tag in Simulator logp
ricardoV94 May 3, 2022
4401bf6
Replace deprecated tag.ignore_logprob
ricardoV94 May 3, 2022
8ff7c85
Group compile_pymc tests in own class
ricardoV94 May 3, 2022
20887a5
Remove remaining uses of default_updates in codebase
ricardoV94 May 3, 2022
bb614dd
Remove redundant/wrong docstrings from GaussianRandomWalk logp
ricardoV94 May 4, 2022
64b20e0
Add moment to GaussianRandomWalk and fix mu/sigma broadcasting bug
ricardoV94 May 4, 2022
345067e
Do not create temporary SymbolicDistribution just to retrieve number …
ricardoV94 Apr 29, 2022
a3d8844
Move SymbolicDistribution docstring to body of class
ricardoV94 May 4, 2022
5e34387
Refactor AR distribution
ricardoV94 Apr 29, 2022
8507956
Rename `pandas_to_array` to `convert_observed_data`
ricardoV94 May 5, 2022
be6fa5c
Obtain step information from dims and observed
ricardoV94 May 5, 2022
255c8e9
Make AR steps extend shape beyond initial_dist
ricardoV94 May 5, 2022
18cbb43
Merge branch 'main' into vector_sigma
fonnesbeck May 6, 2022
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
11 changes: 6 additions & 5 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@ def get_tau_sigma(tau=None, sigma=None):
if isinstance(sigma, Variable):
sigma_ = check_parameters(sigma, sigma > 0, msg="sigma > 0")
else:
assert np.all(np.asarray(sigma) > 0)
sigma_ = sigma
sigma_ = np.asarray(sigma)
if np.any(sigma_ <= 0):
raise ValueError("sigma must be positive")
tau = sigma_**-2.0

else:
Expand All @@ -237,9 +238,9 @@ def get_tau_sigma(tau=None, sigma=None):
if isinstance(tau, Variable):
tau_ = check_parameters(tau, tau > 0, msg="tau > 0")
else:
assert np.all(np.asarray(tau) > 0)
tau_ = tau

tau_ = np.asarray(tau)
if np.any(tau_ <= 0):
raise ValueError("tau must be positive")
sigma = tau_**-0.5

return floatX(tau), floatX(sigma)
Expand Down
5 changes: 5 additions & 0 deletions pymc/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2399,6 +2399,11 @@ def test_get_tau_sigma(self):
with pytest.raises(ParameterValueError):
sigma.eval()

sigma = [1, 2]
assert_almost_equal(
get_tau_sigma(sigma=sigma), [1.0 / np.array(sigma) ** 2, np.array(sigma)]
)

@pytest.mark.parametrize(
"value,mu,sigma,nu,logp",
[
Expand Down