Skip to content

Implement numba dispatch of StudentT #1402

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 1 commit into from
May 15, 2025
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 pytensor/link/numba/dispatch/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
return random


@numba_core_rv_funcify.register(ptr.StudentTRV)
def numba_core_StudentTRV(op, node):
@numba_basic.numba_njit
def random_fn(rng, df, loc, scale):
return loc + scale * rng.standard_t(df)

Check warning on line 109 in pytensor/link/numba/dispatch/random.py

View check run for this annotation

Codecov / codecov/patch

pytensor/link/numba/dispatch/random.py#L109

Added line #L109 was not covered by tests

return random_fn


@numba_core_rv_funcify.register(ptr.HalfNormalRV)
def numba_core_HalfNormalRV(op, node):
@numba_basic.numba_njit
Expand Down
17 changes: 17 additions & 0 deletions tests/link/numba/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,23 @@ def test_aligned_RandomVariable(rv_op, dist_args, size):
"gumbel_r",
lambda *args: args,
),
(
ptr.t,
[
(pt.scalar(), np.array(np.e, dtype=np.float64)),
(
pt.dvector(),
np.array([1.0, 2.0], dtype=np.float64),
),
(
pt.dscalar(),
np.array(np.pi, dtype=np.float64),
),
],
(2,),
"t",
lambda *args: args,
),
],
)
def test_unaligned_RandomVariable(rv_op, dist_args, base_size, cdf_name, params_conv):
Expand Down