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

Fixed: Inv Numba implementation now correctly returns non-integral in… #627

Merged
merged 1 commit into from Oct 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions aesara/link/numba/dispatch/scalar.py
Expand Up @@ -21,6 +21,7 @@
Clip,
Composite,
Identity,
Inv,
Mul,
ScalarOp,
Second,
Expand Down Expand Up @@ -170,3 +171,12 @@ def second(x, y):
return y

return second


@numba_funcify.register(Inv)
def numba_funcify_Inv(op, node, **kwargs):
@numba.njit(inline="always")
def inv(x):
return 1 / x

return inv
19 changes: 19 additions & 0 deletions tests/link/test_numba.py
Expand Up @@ -796,6 +796,25 @@ def test_Cast(v, dtype):
)


@pytest.mark.parametrize(
"v, dtype",
[
(set_test_value(aet.iscalar(), np.array(10, dtype="int32")), aesb.float64),
],
)
def test_Inv(v, dtype):
g = aesb.inv(v)
g_fg = FunctionGraph(outputs=[g])
compare_numba_and_py(
g_fg,
[
i.tag.test_value
for i in g_fg.inputs
if not isinstance(i, (SharedVariable, Constant))
],
)


@pytest.mark.parametrize(
"v, shape, ndim",
[
Expand Down