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

Expose standard_normal to RandomStream #530

Merged
merged 2 commits into from
Jul 22, 2021
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
9 changes: 9 additions & 0 deletions aesara/tensor/random/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ def __call__(self, loc=0.0, scale=1.0, size=None, **kwargs):
normal = NormalRV()


class StandardNormalRV(NormalRV):
def __call__(self, size=None, **kwargs):
return super().__call__(loc=0.0, scale=1.0, size=size, **kwargs)


standard_normal = StandardNormalRV()


class HalfNormalRV(ScipyRandomVariable):
name = "halfnormal"
ndim_supp = 0
Expand Down Expand Up @@ -815,4 +823,5 @@ def __call__(self, x, **kwargs):
"beta",
"triangular",
"uniform",
"standard_normal",
]
3 changes: 2 additions & 1 deletion tests/tensor/random/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
poisson,
polyagamma,
randint,
standard_normal,
triangular,
truncexpon,
uniform,
Expand Down Expand Up @@ -290,7 +291,7 @@ def test_normal_samples(mean, sigma, size):


def test_normal_default_args():
rv_numpy_tester(normal)
rv_numpy_tester(standard_normal)


@pytest.mark.parametrize(
Expand Down
3 changes: 3 additions & 0 deletions tests/tensor/random/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def test_basics(self, rng_ctor):
with pytest.raises(AttributeError):
random.blah

# test if standard_normal is available in the namespace, See: GH issue #528
random.standard_normal

with pytest.raises(AttributeError):
np_random = RandomStream(namespace=np, rng_ctor=rng_ctor)
np_random.ndarray
Expand Down