-
Notifications
You must be signed in to change notification settings - Fork 10
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
increase test coverage #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import os | ||
from astropy.io import fits | ||
from glue.config import data_translator | ||
from jdaviz.core.registries import data_parser_registry | ||
from lightkurve import LightCurve, KeplerLightCurve, TessLightCurve | ||
from lightkurve.io.detect import detect_filetype | ||
import lightkurve | ||
|
||
__all__ = ["light_curve_parser"] | ||
|
||
|
@@ -17,21 +15,11 @@ def light_curve_parser(app, file_obj, data_label=None, show_in_viewer=True, **kw | |
if data_label is None: | ||
data_label = os.path.splitext(os.path.basename(file_obj))[0] | ||
|
||
# detect the type light curve in a FITS file: | ||
with fits.open(file_obj) as hdulist: | ||
filetype = detect_filetype(hdulist) | ||
|
||
# get the constructor for this type of light curve: | ||
filetype_to_cls = { | ||
'KeplerLightCurve': KeplerLightCurve, | ||
'TessLightCurve': TessLightCurve | ||
} | ||
cls = filetype_to_cls[filetype] | ||
# read the light curve: | ||
light_curve = cls.read(file_obj) | ||
light_curve = lightkurve.read(file_obj) | ||
Comment on lines
-20
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bmorris3 - any reason why we can't rely on lightkurve functionality here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure this was a workaround in #10 until lightkurve/lightkurve#1299 was merged (see #10 (comment)). If this is simplification is working correctly now, then we're all good! |
||
|
||
# load a LightCurve object: | ||
elif isinstance(file_obj, LightCurve): | ||
elif isinstance(file_obj, lightkurve.LightCurve): | ||
light_curve = file_obj | ||
|
||
# make a data label: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
def test_reset_limits(helper, light_curve_like_kepler_quarter): | ||
helper.load_data(light_curve_like_kepler_quarter) | ||
tv = helper.app.get_viewer(helper._default_time_viewer_reference_name) | ||
|
||
orig_xlims = (tv.state.x_min, tv.state.x_max) | ||
orig_ylims = (tv.state.y_min, tv.state.y_max) | ||
# set xmin and ymin to midpoints | ||
new_xmin = (tv.state.x_min + tv.state.x_max) / 2 | ||
new_ymin = (tv.state.y_min + tv.state.y_max) / 2 | ||
tv.state.x_min = new_xmin | ||
tv.state.y_min = new_ymin | ||
|
||
tv.state._reset_x_limits() | ||
assert tv.state.x_min == orig_xlims[0] | ||
assert tv.state.y_min == new_ymin | ||
|
||
tv.state._reset_y_limits() | ||
assert tv.state.y_min == orig_ylims[0] |
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.
Well, that's one way to improve coverage 😉
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.
it's my favorite way! (I just figured we didn't need coverage on simple input-errors, so might as well have that officially noted)