Bug persisting through 13.1.0
GroupBy[{1, 1, 1, 1, 1, 1}, # > RandomReal[{0, 2}] &]
sometimes returns something like
<|False -> {1, 1, 1, 1}, True -> {1, 1}|>
but then again it might just return
<|True -> {1, 1, 1, 1}|>
Very strange. Apparently this issue can arise without duplicates though. The following two always have the same results.
a = 0.7;
GroupBy[{1, 1, 1, 1, 1, 1}, # > (a += 0.1) &]
(* <|False -> {1, 1, 1, 1}|> *)
a = 0.7;
GroupBy[{1.01, 1.02, 1.03, 1.04, 1.05, 1.06}, # > (a += 0.1) &]
(* <|False -> {1.04, 1.05, 1.06}|> *)
Is there a good reason for this? Seems like a bug.
a = 0.7; GroupBy[{1.01, 1.02, 1.03, 1.04, 1.05, 1.06}, Echo[#, "Check"] > (Echo[a += 0.1, "a ="]) &]
. It doesn't seem to check elements sequentially. $\endgroup$GroupBy[Table[i, {i,6}], Echo[#] > Echo[RandomReal[{0, 2}], "random"] &]
sometimes checks some list elements multiple times? weird... $\endgroup$GroupBy[Table[i, {i, 8}], Floor[Echo[#]/3] &]
. $\endgroup$GatherBy
using the criteria, then checks the same against the first member(s) of the result to build the association. When the latter test(s) are the same, only the latter is retained, as inAssociationThread
... $\endgroup$