Skip to content
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

Merged
merged 5 commits into from Jun 13, 2023

Conversation

Astro-Kirsty
Copy link
Member

@Astro-Kirsty Astro-Kirsty commented Jun 1, 2023

Description
The default for selection_optional in FluxPointsEstimator is None. This means that the is_ul column shows all False. This current behaviour seems non-intuitive because it is not False, rather it has not been calculated.

This PR proposes an alternative, such that if has_ul is False, then the is_ul column will be removed, as to avoid confusion for the user.

Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
@Astro-Kirsty Astro-Kirsty self-assigned this Jun 1, 2023
Comment on lines 372 to +374
table["is_ul"] = self.is_ul.data[idx]
if not self.has_ul:
table.remove_columns("is_ul")
Copy link
Member

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:

Suggested change
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]

Copy link
Member Author

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.

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

Copy link
Member

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....

Copy link
Contributor

@registerrier registerrier left a 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 .

@registerrier registerrier added this to the 1.2 milestone Jun 1, 2023
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Copy link
Contributor

@registerrier registerrier left a 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.

gammapy/estimators/points/tests/test_core.py Outdated Show resolved Hide resolved
gammapy/estimators/points/tests/test_core.py Outdated Show resolved Hide resolved
gammapy/estimators/points/tests/test_core.py Outdated Show resolved Hide resolved
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Merging #4546 (4286d6c) into main (e45cb44) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #4546   +/-   ##
=======================================
  Coverage   95.05%   95.06%           
=======================================
  Files         221      221           
  Lines       31448    31459   +11     
=======================================
+ Hits        29893    29905   +12     
+ Misses       1555     1554    -1     
Impacted Files Coverage Δ
gammapy/estimators/points/core.py 92.18% <100.00%> (+0.06%) ⬆️
gammapy/estimators/points/tests/test_core.py 95.17% <100.00%> (+0.19%) ⬆️

... and 6 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

registerrier
registerrier previously approved these changes Jun 9, 2023
Copy link
Contributor

@registerrier registerrier left a 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.

gammapy/estimators/points/tests/test_core.py Outdated Show resolved Hide resolved
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Copy link
Contributor

@registerrier registerrier left a 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.

@registerrier registerrier merged commit 7b48b53 into gammapy:main Jun 13, 2023
15 checks passed
@Astro-Kirsty Astro-Kirsty deleted the FluxPoints_table branch October 31, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants