-
Notifications
You must be signed in to change notification settings - Fork 1
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
Simplify TemplateSource, CombinedSource and SpectrumTemplateSource #69
Conversation
Pull Request Test Coverage Report for Build 5880564532
💛 - Coveralls |
Maybe we also want to test |
This PR depends on #68. |
alea/parameters.py
Outdated
@@ -1,5 +1,7 @@ | |||
from typing import Any, Dict, List, Optional, Tuple | |||
|
|||
import scipy |
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.
[pep8] reported by reviewdog 🐶
F401 'scipy' imported but unused
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.
Why do you import it though @dachengx ? If there's a reason you can also just put the #noqa: F401 to make clear that it is intentionally added here and nobody accidentally removes it in the future 😊
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.
Added.
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.
SOme comments-- at the moment, the only way I found testing it was to import binference plotting code, is there a better way, you think?
# ... and finally to probability density | ||
if 0 < self.events_per_day: | ||
if self.events_per_day > 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.
I can see how it is correct if read in english, but I have in general made many more mistakes when I did not consistently never use > (so all inequalities have the smaller number to the left)
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.
We will apply a < b < c
in the future.
alea/template_source.py
Outdated
ret[n] = t[:, i] | ||
return ret | ||
|
||
|
||
class CombinedSource(blueice.HistogramPdfSource): | ||
class CombinedSource(TemplateSource, HistogramPdfSource): | ||
""" | ||
Source that inherits structure from TH2DSource by Jelle, |
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.
HistogramPdfSource is the one in blueice originally written by Jelle
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.
removed.
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 meant rather in the docstring also :)
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.
Removed.
I think |
It depends on how you use it and I think we agreed that we try to avoid people using it. But really, the histogram is just multiplied with it, right? |
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 scrolled through the changes and it looks nice, for sure useful to clean up this part. Though a bit hard to keep track and check all the changes. Maybe it would make sense to add a test for the combined source or did I just miss it?
Also, could you maybe think of a case where this source would be used so that we can make a sensible example out of it?
The histogram is normalized to one and then multiplied by it. |
The test it at
I would postpone the meaningful test to the future when we really used the |
3b95e5c
to
07fb1c0
Compare
|
Ah, right @dachengx ! The |
Ok I see that for now there is no urgency to have a meaningful test but it would be very useful to have an idea when this source could be used and how one would want to use it, I think. Maybe we could also make this a bit clearer in the docstring since rn I have no idea what to do with it tbh 😄 |
For this to be merged, we need more example templates like #30 provided. Especially the 3D template with Unless we can live with the nonsense pytest. Currently the config .yaml files only. provide a runnable model definition. But the |
@kdund I moved the test of sources into another test module. They will not participate in CL calculation, to save time. |
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.
Thanks, @dachengx I think from my side this looks good now
@@ -56,7 +61,7 @@ parameter_definition: | |||
er_band_shift: | |||
nominal_value: 0 | |||
ptype: shape | |||
uncertainty: null # 'scipy.stats.uniform(loc=-1, scale=2)' | |||
uncertainty: null # stats.uniform(loc=0, scale=2).logpdf |
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 think making all our tests usig the same large config is not optimal-- could we make smaller likelihoods for each aspects of the test?
alea/parameters.py
Outdated
raise ValueError( | ||
f"Uncertainty string '{self._uncertainty}'" | ||
" must start with 'scipy.' or 'numpy.'") | ||
NotImplementedError( |
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.
What is the challenge in not including this functionality for now?
README.md
Outdated
|
||
## Ackgnowledgements |
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.
acknowledgements :)
What does the code in this PR do / what does it improve?
The functionality of
TemplateSource
,CombinedSource
, andSpectrumTemplateSource
are unchanged.Add test of
CombinedSource
.The weights can be set as shape parameters in the config. You can check it by:
But the
SpectrumTemplateSource
is not tested, also the configuration is too complex, especially the normalization.Can you briefly describe how it works?
I already tested that the results are the same in
main
andsimplify_source
.Can you give a minimal working example (or illustrate with a figure)?
Please refer to
test_blueice_extended_model.py
.What are the potential drawbacks of the codes?
Please include the following if applicable: