-
Notifications
You must be signed in to change notification settings - Fork 272
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
ChargeExtractor tests and simplification #1023
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1023 +/- ##
==========================================
- Coverage 83.6% 83.59% -0.02%
==========================================
Files 189 189
Lines 10726 10647 -79
==========================================
- Hits 8968 8900 -68
+ Misses 1758 1747 -11
Continue to review full report at Codecov.
|
Since the title is "Major refactoring" I am already frightened :-D So in case you wanna make review easier, here just some thoughts: If one only modifies tests or adds tests, but not the code base, this is quite simple to review I think. So if you happen to be done already (or partly done) with refactoring and adding some tests, we could already merge it. |
I get where you are coming from. I just thought this process would be a bit messy if split into many pull requests. Not sure what is the best way in Github to handle a major pull request with many sub-pull-requests. I will try to split it into stages. |
If the single diffs are easy to review, that's maybe enough. |
Cool, thx. I can already say, that I like the current version better than the master. The master tested only the bare minimum, i.e. if the extractors could be called at all ... but it never tested the results. |
yeah ... you are right. I should start reviewing that way and not only look at the end result. |
Okay, this is the first PR for the refactoring of the ChargeExtractors. I have now created the issue #1026 to organise the large amount of planned changes. I began this PR by creating some tests for the return values of the charges, to make sure I maintain results in my changes. I have then simplified the implementations of the ChargeExtractor. |
This PR should not break API either |
Python 3.7 failing in travis due to pandoc version (I think) |
Travis passed... |
Okay... I will use the |
Why multiply and not index? I find it much more readable to use the index form. |
Need to keep the shape/dimensions for the sum. Indexing flattens the array. Could reshape back, but theres the potential that one could have different number of samples in integration window for different pixels. |
Should this be tagged work in progress? or is it basically done? |
This part is done |
Ah, I have realised a problem with this approach - configuring the window_width and window_shift traitlets cannot be easily done anymore. Before, one could specifiy the following in a aliases = Dict(
dict(
window_width='WindowIntegrator.window_width',
window_shift='WindowIntegrator.window_shift',
)
) But now, because the different width and shift traitlets are attached to each ChargeExtractor independently, one would have to include the traitlet for each ChargeExtractor. The only way I see to fix this is keep some inheritance of a common |
Just a comment, I think it is ok to use |
Of course, from what I've learned at PyGamma, you can also get some of the benefits of einsum by using Numba on a numpy function, keeping the readability (but then you have to ensure the function has simple ndarray inputs and outputs) |
I intend to do an optimisation study towards the end of #1026, which will include using numba. |
I'm not sure what is up with codacy, but this PR is ready for reviews and merge |
- Removed abstract classes that defined common traitlet - Each ChargeExtractor once again has its own traitlets defined - Tools have been updated to not expose the ChargeExtractor traitlets as aliases - can still be configured explicitly (via cmdline or config file)
I have adopted the approach mentioned in #1029, which suggests to more sparingly use the aliases feature. This therefore allows me to remove the abstract classes once again, returning to the simple Component-inheritence (only inherit from ChargeExtractor) I had intended for this PR. |
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.
I like this ... I have a few questions and remarks, but the overall structure looks very nice now.
- Replace None with np.newaxis where appropriate - Fix documentation
* master: Add tests to Tools to check that help message works (cta-observatory#1034) make codacy happy Fix neighbors (cta-observatory#1015) Fix component docs (cta-observatory#1016) related to cta-observatory#1013 allow enums in containers and support in tableio # Conflicts: # ctapipe/tools/bokeh/file_viewer.py # ctapipe/tools/extract_charge_resolution.py
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.
I have to run, so I approve now not waiting for the tests to pass. If they do not pass .... I obviously do not really approve :-D
@kosack Could you restore your approval for this PR? Or @thomasgas? |
This PR aims to improve the test for charge extractors, and begins the major refactoring described in #1026. Namely, the
ChargeExtractors
are significantly simplified with the intention that they more heavily use a composition approach instead of inheritance in the future.