-
Notifications
You must be signed in to change notification settings - Fork 166
Fix err dist none #909
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
base: main
Are you sure you want to change the base?
Fix err dist none #909
Conversation
stingray/lightcurve.py
Outdated
@@ -39,7 +39,7 @@ | |||
|
|||
__all__ = ["Lightcurve"] | |||
|
|||
valid_statistics = ["poisson", "gauss", None] | |||
valid_statistics = ["poisson", "gauss", "None"] |
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 do .lower() so either "None" or "none" is fine from the user perspective. I kept "None" as that's what e.g. matplolib uses. But we could keep it as "none" in valid_statistics as poiss and gauss are not capitalized, but from the user perspective it does not matter.
Having None type would make the code more clunky and we would unnecessarily need to handle that case separately, while if "none" is taken as a string makes all the cases the same and the code more straightforward.
@andresgur Thanks for your PR. I made a slight modification to avoid breaking the API. |
thanks @matteobachetti ! Is there anything else for me to do? Sorry still learning this whole PR thing |
No worries! I'm taking care of solving the API change issues. Please write a changelog snippet according to https://docs.stingray.science/en/stable/contributing.html#updating-and-maintaining-the-changelog. It should be called docs/changes/909.bugfix.rst and briefly describe the changes |
Hey @andresgur , i didn't see your work here and fixes err_dist issue in #912 . |
@andresgur the change of default means that a warning is thrown everywhere in the code now during tests, making about 50 tests fail. with pytest.warns(UserWarning, match="Beware! Stingray only uses"):
<etc.> |
Added the file @matteobachetti |
Hey @andresgur, we also need to fix the tests raising above warning. |
which ones? No tests break for me... I thought the problem was keeping none as a string |
did u run pytest in your machine? |
for file in test*.py ; do echo $file; python $file -m unitest; done test_base.py Am I missing something? |
Hey @andresgur, for stingray we uses pytest for testing inside the stingray repository run u may refer this https://docs.stingray.science/en/stable/#test-suite |
thanks I see it now... so we should skip the warnings as @matteobachetti suggested? |
yes, |
@andresgur tests are run using |
All tests passing on my end now |
docs/simulator.rst
Outdated
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.
Hey @andresgur , rest of changes are fine, but
users when trying this example importing pytest
doesn't seem to good way.
>>> with pytest.warns(UserWarning, match="Beware! Stingray only supports poisson err_dist at the moment in many methods, and 'gauss' in a few more."):
... lc = sim.simulate(2)
instead this u can just suppress the warning
>>> lc = sim.simulate(2) # doctest: +IGNORE_WARNINGS
once this pr gets merged, i will write tests for #912
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.
Regarding this warning, I’m wondering if we could document which methods only support Poisson, which support Gauss and put that into the docs, with a link to that page in the warning? I feel like if I were the user, I’d like to know which methods I could use with which distribution. :)
I’m assuming this was probably in there before this PR, so we can address this elsewhere, but it seemed worth raising.
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.
probably worth of raising an issue.
see #916
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.
@ankitkhushwaha I made the requested change btw, and yes @dhuppenkothen that would be a very good idea to add detail of the methods that handle Gauss/Poiss errors
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.
Hey @andresgur, maintainers are quite busy around this time, so it might take a while for the PR to get reviewed.
Hope u understand.
@Sauravroy34 has mentioned some places where docs related to distribution error can be imporved.
Fixes #908
Provide an overview of the implemented solution or the fix and elaborate on the modifications.
I have modified the valid_statistics in lightcurve.py. Instead of the using the old None, now we use "None".
valid_statistics = ["poisson", "gauss", "None"]
I have also changed the default err_dist in the Lightcurve constructor to "None" to correctly reflect the docs.