Skip to content

Commit 7147f7f

Browse files
committed
Developer note on Mean
1 parent edb5b11 commit 7147f7f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pytensor/tensor/math.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,12 +1304,18 @@ def complex_from_polar(abs, angle):
13041304

13051305

13061306
class Mean(FixedOpCAReduce):
1307+
# FIXME: Mean is not a true CAReduce in the PyTensor sense, because it needs to keep
1308+
# track of the number of elements already reduced in order to work iteratively.
1309+
# This should subclass a `ReduceOp` which `CAReduce` could also inherit from.
13071310
__props__ = ("axis",)
13081311
nfunc_spec = ("mean", 1, 1)
13091312

13101313
def __init__(self, axis=None):
13111314
super().__init__(ps.mean, axis)
1312-
assert self.axis is None or len(self.axis) == 1
1315+
if not (self.axis is None or len(self.axis) == 1):
1316+
raise NotImplementedError(
1317+
"Mean Op only supports axis=None or a single axis. Use `mean` function instead"
1318+
)
13131319

13141320
def __str__(self):
13151321
if self.axis is not None:

0 commit comments

Comments
 (0)