-
Notifications
You must be signed in to change notification settings - Fork 3
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
Abstract base class for analysis functions #206
Conversation
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.
This look great @hombit. My main request is to update the docs where a few lingering issues remain, particularly there's a few instances where it looks like calc_sf2 is called on array data, and those should be changed to calc_sf2.calculate calls.
@dougbrn thank you! BTW, I'm not really happy about this |
Hmm, I'm not sure that
Renaming the calc functions seems more reasonable, it looks like you currently have calc_stetson_J being imported as it's assigned as |
I agree, with the only correction: currently |
Alternatively, we could define the "calculate" function as a staticmethod of the class, like this:
But this may be annoying to users as well that attempt to pass the static method to the ensemble, or try to act on the class like a function. |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@@ -16,7 +16,7 @@ | |||
"source": [ |
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.
Ah, this is tricky. Calculate should not be added here, as sf2 is a function of the timeseries class as invoked here. There's a few instances of that throughout this doc. It looks like timeseries.sf2 and ensemble.sf2 have also not been updated with the rename. As a future note, we may want to deprecate the unique sf2 functions in ensemble and timeseries in favor of a different batch function that serves a "glob" of lightcurves to a function.
Reply via ReviewNB
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.
Thank you, I did too mechanically! I'll fix it
5ffdece
to
79fb1b2
Compare
Codecov Report
@@ Coverage Diff @@
## main #206 +/- ##
==========================================
- Coverage 92.95% 92.20% -0.76%
==========================================
Files 20 21 +1
Lines 1051 1091 +40
==========================================
+ Hits 977 1006 +29
- Misses 74 85 +11
|
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.
Nice, this looks good now with all the CI squared away!
@dougbrn Should I improve test coverage? |
If you have ideas for further tests, feel free to add them. But I don't think that any of the loss in coverage here is especially impactful or merge-preventing |
I added a couple of new tests, but not going to add anything else |
I talked with @hombit today; and I just reiterate that the main functionality that I want to have preserved is that an user can invoke our ``special functions'' just as In best case scenario the flow is
I understand that this pull changes this. I think that I am fine with both options of |
@dougbrn and @nevencaplar. I've just pushed the code to 1) rename functions back to |
I'm in favor of the change to preserve the current interface for analysis functions. I just have one last question for the ensemble.batch side, doesn't this implementation mean that a user should supply the StetsonJ class to batch, as supplying the calc_stetson_J instance will not be picked up by ensemble.batch's check to see if it's a subclass of AnalysisFunction? If this is the case, we should point this out in the documentation as much as possible, as I can see users easily just using the calc_stetson_J instance with the ensemble. |
Actually this PR changes nothing in how we use analysis functions with In [2]: from tape.analysis import calc_stetson_J, AnalysisFunction
In [3]: isinstance(calc_stetson_J, AnalysisFunction)
Out[3]: True THat means that there is no need to use these classes directly, and the only reason I keep them as a part of the "public" interface is too allow subsequent inheritance. |
Oh! I see, that's really cool. |
acdc14c
to
9969b18
Compare
Here I introduce an abstract base class
AnalysisFunction
for built-in analysis functions, which could also be used to create user's analysis functions. The instances of its sub-classes can be evaluated viacalculate()
method.It also renames currently available analysis function removing
calc_
prefix from them,calc_stetson_J -> stetson_J
,calc_sf2 -> sf2
.Closes #200