Skip to content

Commit 70cc6a3

Browse files
committed
Fix einsum doctest
1 parent 2413d99 commit 70cc6a3

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

pytensor/tensor/einsum.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,30 @@ def _iota(shape: TensorVariable, axis: int) -> TensorVariable:
8686
8787
.. testcode::
8888
89-
import pytensor as pt
90-
shape = pt.as_tensor('shape', (5,))
91-
print(pt._iota(shape, 0).eval())
89+
import pytensor.tensor as pt
90+
from pytensor.tensor.einsum import _iota
91+
92+
shape = pt.as_tensor((5,))
93+
print(_iota(shape, 0).eval())
9294
9395
.. testoutput::
9496
95-
[0., 1., 2., 3., 4.]
97+
[0 1 2 3 4]
9698
97-
In higher dimensions, it will look like many concatenated `pt.arange`:
99+
In higher dimensions, it will look like many concatenated `arange`:
98100
99101
.. testcode::
100102
101-
shape = pt.as_tensor('shape', (5, 5))
102-
print(pt._iota(shape, 1).eval())
103+
shape = pt.as_tensor((5, 5))
104+
print(_iota(shape, 1).eval())
103105
104106
.. testoutput::
105107
106-
[[0., 1., 2., 3., 4.],
107-
[0., 1., 2., 3., 4.],
108-
[0., 1., 2., 3., 4.],
109-
[0., 1., 2., 3., 4.],
110-
[0., 1., 2., 3., 4.]]
108+
[[0 1 2 3 4]
109+
[0 1 2 3 4]
110+
[0 1 2 3 4]
111+
[0 1 2 3 4]
112+
[0 1 2 3 4]]
111113
112114
Setting ``axis=0`` above would result in the transpose of the output.
113115
"""
@@ -218,14 +220,14 @@ def _general_dot(
218220
from pytensor.tensor.einsum import _general_dot
219221
import numpy as np
220222
221-
A = pt.tensor(shape = (3, 4, 5))
222-
B = pt.tensor(shape = (3, 5, 2))
223+
A = pt.tensor(shape=(3, 4, 5))
224+
B = pt.tensor(shape=(3, 5, 2))
223225
224226
result = _general_dot((A, B), axes=[[2], [1]], batch_axes=[[0], [0]])
225227
226228
A_val = np.empty((3, 4, 5))
227229
B_val = np.empty((3, 5, 2))
228-
print(result.shape.eval({A:A_val, B:B_val}))
230+
print(tuple(result.shape.eval({A:A_val, B:B_val})))
229231
230232
.. testoutput::
231233

0 commit comments

Comments
 (0)