-
Notifications
You must be signed in to change notification settings - Fork 40
More robust handling of samples that fail to filter #848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: toast3
Are you sure you want to change the base?
Conversation
Copilot-generated fix to my PR. Yay! Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
The PR enhances the robustness of sample filtering by flagging any samples that fail filter cuts so they aren’t projected onto maps.
- Updated
SparseTemplates.mask
to track failed slices alongside masked templates. - Added checks in
_exec
to ensure filter flags overlap expected masks and to flag failed samples during execution. - Improved handling in
_build_template_covariance
to treat infinite condition numbers as failures.
Comments suppressed due to low confidence (1)
src/toast/ops/filterbin.py:95
- Update the
mask
docstring to indicate it now returns a(masked, failed)
tuple instead of a singleSparseTemplates
object.
"""Return a new SparseTemplates instance that complies with the
src/toast/ops/filterbin.py
Outdated
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with det bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with shared bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string isn’t an f-string, so the placeholders won’t be formatted. Change to msg += f"{self.filter_flag_mask} & {self.shared_flag_mask} = 0"
.
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" | |
msg += f"{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
Copilot uses AI. Check for mistakes.
src/toast/ops/filterbin.py
Outdated
msg += "{self.filter_flag_mask} & {self.det_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.shared_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with shared mask: " | ||
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with det bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with shared bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string isn’t an f-string, so the placeholders won’t be formatted. Change to msg += f"{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0"
.
msg += "{self.filter_flag_mask} & {self.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared mask: " | |
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" | |
msg += f"{self.filter_flag_mask} & {self.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared mask: " | |
msg += f"{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
Copilot uses AI. Check for mistakes.
src/toast/ops/filterbin.py
Outdated
msg += "{self.filter_flag_mask} & {self.det_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.shared_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with shared mask: " | ||
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with det bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | ||
raise RuntimeError(msg) | ||
|
||
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | ||
msg = f"Filter flag mask does not overlap with shared bin mask: " | ||
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string isn’t an f-string, so the placeholders won’t be formatted. Change to msg += f"{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0"
.
msg += "{self.filter_flag_mask} & {self.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared mask: " | |
msg += "{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += "{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" | |
msg += f"{self.filter_flag_mask} & {self.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared mask: " | |
msg += f"{self.filter_flag_mask} & {self.shared_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.det_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with det bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.det_flag_mask} = 0" | |
raise RuntimeError(msg) | |
if self.filter_flag_mask & self.binning.shared_flag_mask == 0: | |
msg = f"Filter flag mask does not overlap with shared bin mask: " | |
msg += f"{self.filter_flag_mask} & {self.binning.shared_flag_mask} = 0" |
Copilot uses AI. Check for mistakes.
Another useful catch by copilot. Co-authored-by: Copilot <[email protected]>
When filter flags prevent a template from being applied, flag all affected samples so they are not projected onto a map.
This is relevant when filters are subject to a processing mask that is not applied in map projection. Certain subscans may be entirely covered by the processing mask and escape subscan filtering. Unfiltered samples are subject to large uncertainties and should not be projected.