Skip to content

Commit 2043a0d

Browse files
committed
Test: forbid np.sin out= on Expr/Variable
Add a unit test in tests/test_expr.py to assert that calling np.sin with an out= parameter on a Variable/Expr/GenExpr raises TypeError. This prevents in-place modification of expression objects via NumPy ufunc out arguments and documents the intended behavior.
1 parent 3c4c30f commit 2043a0d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tests/test_expr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ def test_unary(model):
272272
with pytest.raises(TypeError):
273273
np.arcsin(x)
274274

275+
with pytest.raises(TypeError):
276+
# forbid modifying Variable/Expr/GenExpr in-place via out parameter
277+
np.sin(x, out=np.array([0]))
278+
275279

276280
def test_mul():
277281
m = Model()

0 commit comments

Comments
 (0)