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

Fix property setting from astropy #814

Merged
merged 4 commits into from
Mar 29, 2024

Conversation

matteobachetti
Copy link
Member

Resolve #813

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.43%. Comparing base (e4e477c) to head (775ec31).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #814   +/-   ##
=======================================
  Coverage   96.43%   96.43%           
=======================================
  Files          45       45           
  Lines        9027     9034    +7     
=======================================
+ Hits         8705     8712    +7     
  Misses        322      322           

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

Copy link
Collaborator

@mgullik mgullik left a comment

Choose a reason for hiding this comment

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

Hi @matteobachetti,

as you said this is an easy fix.
Just a curiosity, why using fits as key returned an error?

Copy link
Member

@dhuppenkothen dhuppenkothen left a comment

Choose a reason for hiding this comment

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

As @mgullik says, pretty straightforward. I'll approve it, but leave the comment on making the new warning more user-friendly there.

stingray/base.py Outdated
and getattr(cls.__class__, key.lower(), None).fset is None
):
warnings.warn(
f"{key} is a property of StingrayTimeseries without a setter. Not setting it"
Copy link
Member

Choose a reason for hiding this comment

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

Is this a warning that will be exposed to the user? If so, that seems pretty obscure (I don't think I would understand what to do with it, and how to fix it if necessary). Can we make this more user-friendly? What do you expect the user to do with the warning? Maybe another statement like "this is likely because ...", or "this means you can't do ..." or "you can safely ignore this warning" or something would maybe be helpful here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I changed it, hopefully it is more informative now

@matteobachetti
Copy link
Member Author

Our methods to read event lists from FITS files make choices about what information to read in the file. This is done by specifying "ogip" as the format.
When fmt="fits", we read FITS files with Astropy's default reader (so, no interpretation on what an EventList should contain on our side), and everything gets read, including the header keyword EXPOSURE. Then, our code tries to update the exposure attribute of EventList, which is instead calculated internally in StingrayTimeseries, through a special method called a property, and fails. This PR just avoids this failure and warns the user that that keyword is not being saved.

@matteobachetti matteobachetti force-pushed the fix_property_setting_from_astropy branch from 47744d1 to 1ed70bb Compare March 28, 2024 10:43
@matteobachetti matteobachetti added this pull request to the merge queue Mar 29, 2024
Merged via the queue into main with commit de9400a Mar 29, 2024
17 checks passed
@matteobachetti matteobachetti deleted the fix_property_setting_from_astropy branch March 29, 2024 10:53
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.

Error reading the event file
3 participants