Skip to content

Commit b82e761

Browse files
committed
Add xtensor docs
1 parent 0bb15f9 commit b82e761

File tree

6 files changed

+88
-13
lines changed

6 files changed

+88
-13
lines changed

pytensor/xtensor/readme.md renamed to doc/library/xtensor/index.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1+
(libdoc_xtensor)=
12
# XTensor Module
23

4+
:::{toctree}
5+
:maxdepth: 1
6+
xtensor/linalg
7+
xtensor/math
8+
xtensor/random
9+
xtensor/type
10+
:::
11+
312
This module implements as abstraction layer on regular tensor operations, that behaves like Xarray.
413

5-
A new type `XTensorType`, generalizes the `TensorType` with the addition of a `dims` attribute,
6-
that labels the dimensions of the tensor.
14+
A new type :class:`pytensor.xtensor.type.XTensorType`, generalizes the :class:`pytensor.tensor.type.TensorType`
15+
with the addition of a `dims` attribute, that labels the dimensions of the tensor.
716

8-
Variables of `XTensorType` (i.e., `XTensorVariable`s) are the symbolic counterpart to xarray DataArray objects.
17+
Variables of XTensorType (i.e., :class:`pytensor.xtensor.type.XTensorVariable`s) are the symbolic counterpart
18+
to xarray DataArray objects.
919

10-
The module implements several PyTensor operations `XOp`s, whose signature mimics that of xarray (and xarray_einstants) DataArray operations.
11-
These operations, unlike most regular PyTensor operations, cannot be directly evaluated, but require a rewrite (lowering) into
12-
a regular tensor graph that can itself be evaluated as usual.
20+
The module implements several PyTensor operations :class:`pytensor.xtensor.basic.XOp`s, whose signature mimics that of
21+
xarray (and xarray_einstants) DataArray operations. These operations, unlike most regular PyTensor operations, cannot
22+
be directly evaluated, but require a rewrite (lowering) into a regular tensor graph that can itself be evaluated as usual.
1323

1424
Like regular PyTensor, we don't need an Op for every possible method or function in the public API of xarray.
1525
If the existing XOps can be composed to produce the desired result, then we can use them directly.
@@ -23,16 +33,16 @@ Coords involve aspects of Pandas/database query and joining that are not trivial
2333

2434
```python
2535
import pytensor.tensor as pt
26-
import pytensor.xtensor as px
36+
import pytensor.xtensor as ptx
2737

2838
a = pt.tensor("a", shape=(3,))
2939
b = pt.tensor("b", shape=(4,))
3040

31-
ax = px.as_xtensor(a, dims=["x"])
32-
bx = px.as_xtensor(b, dims=["y"])
41+
ax = ptx.as_xtensor(a, dims=["x"])
42+
bx = ptx.as_xtensor(b, dims=["y"])
3343

3444
zx = ax + bx
35-
assert zx.type == px.type.XTensorType("float64", dims=["x", "y"], shape=(3, 4))
45+
assert zx.type == ptx.type.XTensorType("float64", dims=["x", "y"], shape=(3, 4))
3646

3747
z = zx.values
3848
z.dprint()
@@ -64,6 +74,3 @@ fn.dprint()
6474
# └─ ExpandDims{axis=0} [id D] 0
6575
# └─ b [id E]
6676
```
67-
68-
69-

doc/library/xtensor/linalg.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(libdoc_xtensor_linalg)=
2+
## XTensor linalg operations
3+
4+
```{eval-rst}
5+
.. automodule:: pytensor.xtensor.linalg
6+
.. autosummary::
7+
:toctree: generated/
8+
:members:
9+
```

doc/library/xtensor/math.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(libdoc_xtensor_math)=
2+
## XTensor math operations
3+
4+
```{eval-rst}
5+
.. automodule:: pytensor.xtensor.math
6+
.. autosummary::
7+
:toctree: generated/
8+
:members:
9+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(libdoc_xtensor_module_function)=
2+
## XTensor module operations
3+
4+
```{eval-rst}
5+
.. automodule:: pytensor.xtensor
6+
.. autosummary::
7+
:toctree: generated/
8+
9+
concat
10+
dot
11+
```

doc/library/xtensor/random.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(libdoc_xtensor_random)=
2+
## XTensor random operations
3+
4+
```{eval-rst}
5+
.. automodule:: pytensor.xtensor.random
6+
.. autosummary::
7+
:toctree: generated/
8+
:members:
9+
```

doc/library/xtensor/type.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(libdoc_xtenor_type)=
2+
3+
# XTensor Type and Variable
4+
5+
## XTensorVariable creation functions
6+
7+
```{eval-rst}
8+
.. currentmodule:: pytensor.xtensor.type
9+
.. autosummary::
10+
:toctree: generated/
11+
12+
xtensor
13+
xtensor_constant
14+
as_xtensor
15+
```
16+
17+
## XTensor Type and Variable classes
18+
19+
```{eval-rst}
20+
.. currentmodule:: pytensor.xtensor.type
21+
.. autosummary::
22+
:toctree: generated/
23+
24+
25+
XTensorType
26+
XTensorVariable
27+
XTensorConstant
28+
```
29+
30+

0 commit comments

Comments
 (0)