From 36fdfb26d4d4fa093f82a1579b81bc5df64cd337 Mon Sep 17 00:00:00 2001 From: Linjian Date: Thu, 16 Jul 2026 22:18:31 -0700 Subject: [PATCH 1/2] feat: Add pt.multiply as an alias for pt.mul --- pytensor/tensor/math.py | 4 ++++ tests/tensor/test_math.py | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pytensor/tensor/math.py b/pytensor/tensor/math.py index 84d0be7ae2..b0c5ab1000 100644 --- a/pytensor/tensor/math.py +++ b/pytensor/tensor/math.py @@ -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: @@ -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", diff --git a/tests/tensor/test_math.py b/tests/tensor/test_math.py index 8ade530891..6e27d988e4 100644 --- a/tests/tensor/test_math.py +++ b/tests/tensor/test_math.py @@ -102,6 +102,7 @@ minimum, mod, mul, + multiply, nan_to_num, neg, neq, @@ -3972,3 +3973,14 @@ 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) + From 314657108e6cf333900285e22881a04249a1e6ba Mon Sep 17 00:00:00 2001 From: Linjian Date: Thu, 16 Jul 2026 22:28:27 -0700 Subject: [PATCH 2/2] style: Fix ruff formatting issue --- tests/tensor/test_math.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tensor/test_math.py b/tests/tensor/test_math.py index 6e27d988e4..73a27a3cab 100644 --- a/tests/tensor/test_math.py +++ b/tests/tensor/test_math.py @@ -3983,4 +3983,3 @@ def test_multiply(): 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) -