cctbx_project
cctbx_project copied to clipboard
Mpi helper counter
I was working on a custom cctbx.xfel
worker and found myself gather
ing + count
ing 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.