提交 f6be5213 authored 作者: Ricardo Vieira's avatar Ricardo Vieira 提交者: Luciano Paz

Rename `add` `inc_subtensor` helper method to `inc`

上级 230a8080
...@@ -835,7 +835,7 @@ class _tensor_py_operators: ...@@ -835,7 +835,7 @@ class _tensor_py_operators:
""" """
return at.subtensor.set_subtensor(self[idx], y, **kwargs) return at.subtensor.set_subtensor(self[idx], y, **kwargs)
def add(self, idx, y, **kwargs): def inc(self, idx, y, **kwargs):
"""Return a copy of self with the indexed values incremented by y. """Return a copy of self with the indexed values incremented by y.
Equivalent to inc_subtensor(self[idx], y). See docstrings for kwargs. Equivalent to inc_subtensor(self[idx], y). See docstrings for kwargs.
...@@ -846,7 +846,7 @@ class _tensor_py_operators: ...@@ -846,7 +846,7 @@ class _tensor_py_operators:
>>> import pytensor.tensor as pt >>> import pytensor.tensor as pt
>>> >>>
>>> x = pt.ones((3,)) >>> x = pt.ones((3,))
>>> out = x.add(1, 2) >>> out = x.inc(1, 2)
>>> out.eval() # array([1., 3., 1.]) >>> out.eval() # array([1., 3., 1.])
""" """
return at.inc_subtensor(self[idx], y, **kwargs) return at.inc_subtensor(self[idx], y, **kwargs)
......
...@@ -433,13 +433,13 @@ class TestTensorInstanceMethods: ...@@ -433,13 +433,13 @@ class TestTensorInstanceMethods:
# Test equivalent advanced indexing # Test equivalent advanced indexing
assert_array_equal(X[:, indices].eval({X: x}), x[:, indices]) assert_array_equal(X[:, indices].eval({X: x}), x[:, indices])
def test_set_add(self): def test_set_inc(self):
x = matrix("x") x = matrix("x")
idx = [0] idx = [0]
y = 5 y = 5
assert equal_computations([x.set(idx, y)], [set_subtensor(x[idx], y)]) assert equal_computations([x.set(idx, y)], [set_subtensor(x[idx], y)])
assert equal_computations([x.add(idx, y)], [inc_subtensor(x[idx], y)]) assert equal_computations([x.inc(idx, y)], [inc_subtensor(x[idx], y)])
def test_set_item_error(self): def test_set_item_error(self):
x = matrix("x") x = matrix("x")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论