Unverified 提交 b218ffe3 authored 作者: Will Dean's avatar Will Dean 提交者: GitHub

Correct indexing links in docs (#1463)

上级 fb016d62
...@@ -1144,9 +1144,9 @@ Indexing ...@@ -1144,9 +1144,9 @@ Indexing
Like NumPy, PyTensor distinguishes between *basic* and *advanced* indexing. Like NumPy, PyTensor distinguishes between *basic* and *advanced* indexing.
PyTensor fully supports basic indexing PyTensor fully supports basic indexing
(see `NumPy's indexing <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_) (see `NumPy's indexing <https://numpy.org/doc/stable/user/basics.indexing.html>`_)
and `integer advanced indexing and `integer advanced indexing
<http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer>`_. <https://numpy.org/doc/stable/user/basics.indexing.html#integer-array-indexing>`_.
Index-assignment is *not* supported. If you want to do something like ``a[5] Index-assignment is *not* supported. If you want to do something like ``a[5]
= b`` or ``a[5]+=b``, see :func:`pytensor.tensor.subtensor.set_subtensor` and = b`` or ``a[5]+=b``, see :func:`pytensor.tensor.subtensor.set_subtensor` and
......
...@@ -1453,10 +1453,16 @@ def set_subtensor(x, y, inplace=False, tolerate_inplace_aliasing=False): ...@@ -1453,10 +1453,16 @@ def set_subtensor(x, y, inplace=False, tolerate_inplace_aliasing=False):
Examples Examples
-------- --------
To replicate the numpy expression "r[10:] = 5", type To replicate the numpy expression ``r[10:] = 5``, type
>>> from pytensor.tensor import vector
>>> r = vector("r") .. code-block:: python
>>> new_r = set_subtensor(r[10:], 5)
from pytensor.tensor import set_subtensor, vector
r = vector("r")
new_r = set_subtensor(r[10:], 5)
Consider using :meth:`pytensor.tensor.variable.TensorVariable.set` instead.
""" """
return inc_subtensor( return inc_subtensor(
...@@ -1504,17 +1510,21 @@ def inc_subtensor( ...@@ -1504,17 +1510,21 @@ def inc_subtensor(
-------- --------
To replicate the expression ``r[10:] += 5``: To replicate the expression ``r[10:] += 5``:
..code-block:: python .. code-block:: python
from pytensor.tensor import ivector, inc_subtensor
r = ivector() r = ivector("r")
new_r = inc_subtensor(r[10:], 5) new_r = inc_subtensor(r[10:], 5)
To replicate the expression ``r[[0, 1, 0]] += 5``: To replicate the expression ``r[[0, 1, 0]] += 5``:
..code-block:: python .. code-block:: python
r = ivector("r")
new_r = inc_subtensor(r[[0, 1, 0]], 5, ignore_duplicates=True)
r = ivector() Consider using :meth:`pytensor.tensor.variable.TensorVariable.inc` instead.
new_r = inc_subtensor(r[10:], 5, ignore_duplicates=True)
""" """
# First of all, y cannot have a higher dimension than x, # First of all, y cannot have a higher dimension than x,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论