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

Make non-FITS table file from FluxPoints overwritable #5254

Merged
merged 2 commits into from May 16, 2024

Conversation

HealthyPear
Copy link
Contributor

@HealthyPear HealthyPear commented May 7, 2024

Description

See #5253.

Propagated astropy.table.Table.write() overwrite to FluxPoints.write() when file extension is not .fits.

This pull request closes #5253.

Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.25%. Comparing base (50bbef6) to head (a048535).
Report is 43 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5254       +/-   ##
===========================================
+ Coverage   75.26%   94.25%   +18.99%     
===========================================
  Files         234      234               
  Lines       35131    35226       +95     
===========================================
+ Hits        26442    33204     +6762     
+ Misses       8689     2022     -6667     

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

@registerrier registerrier added bug backport-v1.0.x on-merge: backport to v1.0.x backport-v1.2.x on-merge: backport to v1.2.x labels May 7, 2024
@registerrier registerrier added this to the 1.3 milestone May 7, 2024
registerrier
registerrier previously approved these changes May 7, 2024
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 @HealthyPear . This looks good. Could you maybe check why the test is not failing with the current version?

@HealthyPear
Copy link
Contributor Author

Sure. Could you point me to the test function? I am not familiar with the test suite of this project.

@registerrier
Copy link
Contributor

Sure. Could you point me to the test function? I am not familiar with the test suite of this project.

Here it is:

def test_write_ecsv(self, tmp_path, flux_points):

@HealthyPear
Copy link
Contributor Author

I think the problem is that you are writing that file in the tmp_path, but you never stored it there before, you load it from "$GAMMAPY_DATA/tests/spectrum/flux_points/, which is not the same path, so there is not overwriting in the first place.

We should either copy the original file in tmp_path (or maybe even touch a dummy one) and only then attempt to write the table file.

@registerrier
Copy link
Contributor

We should either copy the original file in tmp_path (or maybe even touch a dummy one) and only then attempt to write the table file.

touching a dummy file with the same name sounds good to me.

Signed-off-by: Régis Terrier <rterrier@apc.in2p3.fr>
@registerrier registerrier merged commit b828233 into gammapy:main May 16, 2024
15 of 16 checks passed
Copy link

lumberbot-app bot commented May 16, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v1.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 b8282337f83e61da71836c2c3d6f77fdf24d6dde
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #5254: Make non-FITS table file from FluxPoints overwritable'
  1. Push to a named branch:
git push YOURFORK v1.0.x:auto-backport-of-pr-5254-on-v1.0.x
  1. Create a PR against branch v1.0.x, I would have named this PR:

"Backport PR #5254 on branch v1.0.x (Make non-FITS table file from FluxPoints overwritable)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/gammapy that referenced this pull request May 16, 2024
registerrier added a commit that referenced this pull request May 16, 2024
…4-on-v1.2.x

Backport PR #5254 on branch v1.2.x (Make non-FITS table file from FluxPoints overwritable)
@registerrier
Copy link
Contributor

This cannot be backported to v1.0.x because export to non-FITS file was not available in v1.0.

if sed_type is None:
sed_type = self.sed_type_init
filename = make_path(filename)
table = self.to_table(sed_type=sed_type, format=format)
table.write(filename, **kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v1.2.x on-merge: backport to v1.2.x bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FluxPoints.write() is ignoring overwrite when file extension is not FITS
2 participants