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+
312This 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
1424Like regular PyTensor, we don't need an Op for every possible method or function in the public API of xarray.
1525If 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
2535import pytensor.tensor as pt
26- import pytensor.xtensor as px
36+ import pytensor.xtensor as ptx
2737
2838a = pt.tensor(" a" , shape = (3 ,))
2939b = 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
3444zx = 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
3747z = zx.values
3848z.dprint()
@@ -64,6 +74,3 @@ fn.dprint()
6474# └─ ExpandDims{axis=0} [id D] 0
6575# └─ b [id E]
6676```
67-
68-
69-
0 commit comments