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
Remove is_ul column in FluxPointsEstimator if no upper limit is defined #4546
Conversation
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
table["is_ul"] = self.is_ul.data[idx] | ||
if not self.has_ul: | ||
table.remove_columns("is_ul") |
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.
I think this would be even simpler:
table["is_ul"] = self.is_ul.data[idx] | |
if not self.has_ul: | |
table.remove_columns("is_ul") | |
if self.has_ul: | |
table["is_ul"] = self.is_ul.data[idx] |
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 was also my initial idea, however, this section of code already creates the column is_ul
and fills that column with data.
gammapy/gammapy/estimators/points/core.py
Lines 361 to 364 in 0655a46
for quantity in self.all_quantities(sed_type=sed_type): | |
data = getattr(self, quantity, None) | |
if data: | |
table[quantity] = data.quantity[idx] |
Open to further suggestion
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.
You are right, just leave the suggestion open....
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.
Thanks @Astro-Kirsty . This looks good. A test for this specific situation should be added .
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.
Thanks @Astro-Kirsty . See inline comments.
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #4546 +/- ##
=======================================
Coverage 95.05% 95.06%
=======================================
Files 221 221
Lines 31448 31459 +11
=======================================
+ Hits 29893 29905 +12
+ Misses 1555 1554 -1
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Thanks @Astro-Kirsty .
the test was not testing anything. I have left an inline suggestion to make it work: you have to create a new table from the FluxPoints
object and check that is_ul
is not one of its columns.
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
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.
Thanks @Astro-Kirsty . No further comment on my side.
Description
The default for
selection_optional
inFluxPointsEstimator
isNone
. This means that theis_ul
column shows allFalse
. This current behaviour seems non-intuitive because it is notFalse
, rather it has not been calculated.This PR proposes an alternative, such that if
has_ul
isFalse
, then theis_ul
column will be removed, as to avoid confusion for the user.