I was working on a custom cctbx.xfel worker and found myself gathering + counting objects multiple times. I realized that mpi_helper could just as well use a simple count method that returns a Counter object (a dict-like that automatically counts every occurrence of input list or dict).
While at it, I realized that the mpi_helper methods could be simplified; in particular, the flex_type can be implicitly learned from flex_array – as long as the root rank has a not-None flex_array. Consequently, I allowed the flex_type to be inherited from flex_array if left undefined.
Initially, I wanted to simplify all instances where cumulative_flex and aggregate_flex use "redundant" flex_type, but since it works in case of completely empty input, I left it as it. After all, Explicit is better than implicit.
I was working on a custom
cctbx.xfel
worker and found myselfgather
ing +count
ing objects multiple times. I realized thatmpi_helper
could just as well use a simplecount
method that returns aCounter
object (a dict-like that automatically counts every occurrence of input list or dict).While at it, I realized that the mpi_helper methods could be simplified; in particular, the
flex_type
can be implicitly learned fromflex_array
– as long as theroot
rank has a not-Noneflex_array
. Consequently, I allowed theflex_type
to be inherited fromflex_array
if left undefined.Initially, I wanted to simplify all instances where
cumulative_flex
andaggregate_flex
use "redundant"flex_type
, but since it works in case of completely empty input, I left it as it. After all, Explicit is better than implicit.