-
Notifications
You must be signed in to change notification settings - Fork 137
Fix mean, var and std for XTensorVariables #1533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Also remove broadcast which is not a method in Xarray
d89351c
to
33e831a
Compare
Raises | ||
------ | ||
Value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value: | |
ValueError |
@@ -516,6 +578,48 @@ def set(self, value): | |||
return px.indexing.index_assignment(x, value, *idxs) | |||
|
|||
def inc(self, value): | |||
"""Return a copy of the variable indexed by self with the indexed values incremented by value. | |||
The original variable is not modified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation got messed up somehow
Raises | ||
------ | ||
Value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value: | |
ValueError |
import pytensor.xtensor as ptx | ||
x = ptx.as_xtensor([[1, 2], [3, 4]], dims=("a", "b")) | ||
stacked_cumsum = x.stack({"c": ["a", "b"]}).cumsum("c") | ||
unstacked_cumsum = stacked_x.unstack({"c": x.sizes}) | ||
unstacked_cumsum.eval() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be indented
Examples | ||
-------- | ||
.. test-code:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. test-code:: | |
.. testcode:: |
None of these blocks are being shown in the rendered version: https://pytensor--1533.org.readthedocs.build/en/1533/library/xtensor/type.html#pytensor.xtensor.type.XTensorVariable.inc
I think it is because the directive name is without hyphen: https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html#directive-testcode
@@ -720,7 +830,7 @@ def transpose( | |||
*dim: str | EllipsisType, | |||
missing_dims: Literal["raise", "warn", "ignore"] = "raise", | |||
): | |||
"""Transpose dimensions of the tensor. | |||
"""Transpose the dimensions of the variable. | |||
Parameters | |||
---------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the description of missing dims, if you want the bullet point list to be rendered as a list instead of as inline text (see current render https://pytensor--1533.org.readthedocs.build/en/1533/library/xtensor/type.html#pytensor.xtensor.type.XTensorVariable.transpose) there should be an empty line between previous line and start of list:
How to handle dimensions that don't exist in the tensor:
- "raise": Raise an error if any dimensions don't exist
- int: the new size | ||
- sequence: coordinates (length determines size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- int: the new size | |
- sequence: coordinates (length determines size) | |
- int: the new size | |
- sequence: coordinates (length determines size) |
no extra indentation and empty line between previous line and list should render as list instead of current quoted list render
Sorry for the noise, should have checked :l |
Also add docstrings to most methods and properties so they show up in the docs.
Removes broadcast as a method, since it is not one in xarray
📚 Documentation preview 📚: https://pytensor--1533.org.readthedocs.build/en/1533/