[docs]classNoiseMaskUnion(Algorithm):"""Aggregate several NoiseMask into one by computing their union. I.E. For every bit of the NoiseMask, the output is an OR of the same bit across all NoiseMasks."""
[docs]defrun(self,elements:List[NoiseMask])->NoiseMask:"""Compute the union of a list of NoiseMask. Args: elements (List[NoiseMask]): input NoiseMasks. Raises: ValueError: if not all NoiseMask.mask do not have the same shape. Returns: NoiseMask: aggregated NoiseMasks """ifnotall([mask.mask.shape==elements[0].mask.shapeformaskinelements]):raiseValueError(f"Every NoiseMask.mask must have the same shape to be aggregated. "f"Received {[mask.mask.shapeformaskinelements]}")noise_union=np.sum([mask.maskformaskinelements],axis=0)>0returnNoiseMask(mask=noise_union)