Skip to content

Commit b218ffe

Browse files
authored
Correct indexing links in docs (#1463)
1 parent fb016d6 commit b218ffe

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

doc/library/tensor/basic.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,9 +1144,9 @@ Indexing
11441144

11451145
Like NumPy, PyTensor distinguishes between *basic* and *advanced* indexing.
11461146
PyTensor fully supports basic indexing
1147-
(see `NumPy's indexing <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_)
1147+
(see `NumPy's indexing <https://numpy.org/doc/stable/user/basics.indexing.html>`_)
11481148
and `integer advanced indexing
1149-
<http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer>`_.
1149+
<https://numpy.org/doc/stable/user/basics.indexing.html#integer-array-indexing>`_.
11501150

11511151
Index-assignment is *not* supported. If you want to do something like ``a[5]
11521152
= b`` or ``a[5]+=b``, see :func:`pytensor.tensor.subtensor.set_subtensor` and

pytensor/tensor/subtensor.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,10 +1453,16 @@ def set_subtensor(x, y, inplace=False, tolerate_inplace_aliasing=False):
14531453
14541454
Examples
14551455
--------
1456-
To replicate the numpy expression "r[10:] = 5", type
1457-
>>> from pytensor.tensor import vector
1458-
>>> r = vector("r")
1459-
>>> new_r = set_subtensor(r[10:], 5)
1456+
To replicate the numpy expression ``r[10:] = 5``, type
1457+
1458+
.. code-block:: python
1459+
1460+
from pytensor.tensor import set_subtensor, vector
1461+
1462+
r = vector("r")
1463+
new_r = set_subtensor(r[10:], 5)
1464+
1465+
Consider using :meth:`pytensor.tensor.variable.TensorVariable.set` instead.
14601466
14611467
"""
14621468
return inc_subtensor(
@@ -1504,17 +1510,21 @@ def inc_subtensor(
15041510
--------
15051511
To replicate the expression ``r[10:] += 5``:
15061512
1507-
..code-block:: python
1513+
.. code-block:: python
1514+
1515+
from pytensor.tensor import ivector, inc_subtensor
15081516
1509-
r = ivector()
1517+
r = ivector("r")
15101518
new_r = inc_subtensor(r[10:], 5)
15111519
15121520
To replicate the expression ``r[[0, 1, 0]] += 5``:
15131521
1514-
..code-block:: python
1522+
.. code-block:: python
1523+
1524+
r = ivector("r")
1525+
new_r = inc_subtensor(r[[0, 1, 0]], 5, ignore_duplicates=True)
15151526
1516-
r = ivector()
1517-
new_r = inc_subtensor(r[10:], 5, ignore_duplicates=True)
1527+
Consider using :meth:`pytensor.tensor.variable.TensorVariable.inc` instead.
15181528
15191529
"""
15201530
# First of all, y cannot have a higher dimension than x,

0 commit comments

Comments
 (0)