Bug introduced in 10.3.0 and fixed in 10.3.1
Bug introduced in 10.3.0 and fixed in 10.4.0
First bug, see first part of the question
Second bug, see update part
Some aggregation queries applied to a list of associations (or Dataset
's with this structure) lock up the front end or crash the kernel in Version 10.3.
xx = {<|"a" -> 1|>, <|"a" -> 3|>};
Mean[xx]
(* locked up front end, with cell bracket highlighted as evaluating *)
The behavior is observed in Mathematica 10.3 on OS X El Capitan. It is not observed in 10.2. A bug report has been sent to Wolfram support, and I will update this post and tag it appropriately when I get a reply.
In the meantime, we are fortunate that Total
still works, so my workaround is
myMean[listofassoc:{_Association..}] :=Total[listofassoc]/Length[listofassoc];
myMean[args___]:=Mean[args];
Note that the above code does not catch the Dataset
case.
Update: As pointed out in the comments, this bug only occurs when the associations contain single items, so
Mean[{<|"a" -> 1, "b" -> 2|>, <|"a" -> 3, "b" -> 12|>}]
(* <|"a" -> 2, "b" -> 7|> *)
However, when the list contains a single association, a list is returned instead of a singleton
Mean[{<|"a" -> 1, "b" -> 2|>}]
(* {<|"a" -> 1, "b" -> 2|>} *)
which is unexpected behavior, and also different from 10.2 behavior.
Plus@@listofassoc
also works. $\endgroup$Merge[xx, Mean]
$\endgroup$