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

Adjust to_edisp_kernel input to MapAxis #5186

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Astro-Kirsty
Copy link
Member

@Astro-Kirsty Astro-Kirsty commented Mar 29, 2024

This PR is to resolve #5142.
I left it as a draft as I am not sure if this is the correct procedure to take.
This is two part issue, we want to change the variables to be consistent with the other naming for axis

def to_edisp_kernel_map(self, energy_axis):

We also need to change the variable to no longer be a quantity but a MapAxis.

This was the best way I could think to achieve this.

Note: there are a number of failing tests, but I did not want to fix them all with the deprecation warning until a method was decided upon.

I am open to suggestions.

@registerrier registerrier self-requested a review April 26, 2024 13:20
@Astro-Kirsty Astro-Kirsty marked this pull request as ready for review April 29, 2024 13:20
@Astro-Kirsty Astro-Kirsty self-assigned this Apr 29, 2024
Copy link
Member

@AtreyeeS AtreyeeS 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 !

I do not think you need to adapt internet tests to check for the deprecation warning, eg as done in gammapy/datasets/tests/test_map.py
It only needs to be checked when the user passes a quantity instead of a MapAxis in the to_edisp_kernel function, and internally within Gammapy we should pass a MapAxis.

def to_edisp_kernel(self, offset, energy_true=None, energy=None):
@deprecated_renamed_argument(
["energy_true", "energy"],
["energy_axis_true", "energy_axis"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to rename the argument name or keep the name and change the type?
Either of the two should suffice, no?

If a DepricationWarning is raised about the argument name, then the warning below is not necessary.

I think we can keep the argument same same, and just allow a MapAxis on input. Then, we can raise a deprecation warning if a Quantity is passed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the argument name to be consistent with others in the code, for example here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion here - you can modify the name and remove the warning about passing the Quantity.
You will anyways need to adapt all calls to to_edisp_kernel to take a MapAxis now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay sure thing! Will do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So deprecated_renamed_argument will only let the user know that there was a name change, but not that it should now be a MapAxis

Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Signed-off-by: Astro-Kirsty <AstroKirsty@gmail.com>
Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 75.28%. Comparing base (637570a) to head (36ae743).
Report is 5 commits behind head on main.

Files Patch % Lines
gammapy/irf/edisp/tests/test_core.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5186   +/-   ##
=======================================
  Coverage   75.27%   75.28%           
=======================================
  Files         234      234           
  Lines       35148    35150    +2     
=======================================
+ Hits        26458    26461    +3     
+ Misses       8690     8689    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@QRemy QRemy added cleanup api-change PRs and issues that change an existing API, possibly requiring a deprecation period and removed api-change PRs and issues that change an existing API, possibly requiring a deprecation period labels May 14, 2024
@QRemy QRemy added this to To do in gammapy.irf via automation May 14, 2024
@QRemy QRemy added this to the 1.3 milestone May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
gammapy.irf
  
To do
Development

Successfully merging this pull request may close these issues.

Expect the MapAxis directly in to_edisp_kernel
3 participants