Skip to content
Open
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
4 changes: 4 additions & 0 deletions pytensor/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -2936,6 +2936,9 @@ def mul(a, *other_terms):
# see decorator for function body


multiply = mul


def variadic_mul(*args):
"""Mul that accepts arbitrary number of inputs, including zero or one."""
if not args:
Expand Down Expand Up @@ -4330,6 +4333,7 @@ def nan_to_num(x, nan=0.0, posinf=None, neginf=None):
"minimum",
"mod",
"mul",
"multiply",
"nan_to_num",
"neg",
"neq",
Expand Down
11 changes: 11 additions & 0 deletions tests/tensor/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
minimum,
mod,
mul,
multiply,
nan_to_num,
neg,
neq,
Expand Down Expand Up @@ -3972,3 +3973,13 @@ def test_median(ndim, axis):

assert np.allclose(result_odd, expected_odd)
assert np.allclose(result_even, expected_even)


def test_multiply():
x = vector()
y = vector()
z = multiply(x, y)
f = function([x, y], z)
a = np.array([1.0, 2.0, 3.0])
b = np.array([4.0, 5.0, 6.0])
assert np.allclose(f(a, b), a * b)