-
Notifications
You must be signed in to change notification settings - Fork 70
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
Filter warnings #764
Filter warnings #764
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.
Please add closes #762
to the commit message of this commit.
I trust that we agree that, wherever possible, rather than suppressing or ignoring the warning, the cause of the warning should be removed. In some cases (for example, in a test that checks the behaviour of the code in precisely the situation that is being warned about) it's obvious that the warning should simply be ignored. In other cases, this isn't obvious. Can you give some justifications of the cases where warnings are being ignored rather than their causes being removed? Ideally these would appear in the commit messages of the relevant commit (or a comment at the point of suppression). |
This one still shows up on Travis:
I think that preceding the string with |
45acb26
to
3b686f6
Compare
Yes, I think they are justified although in some cases there might be alternatives. The
Should be we be worried that it only shows up on Travis? Especially since it's a |
Now two new warnings hace appeared, there might be something going on behind the scenes |
Apologies for the silence. I am afraid that I will be unavailable for some 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.
Probably should also look into filterwarnings
of pytest.ini file. One (import error of collections) is fixed in 06f09f9 so maybe you can just cherry-pick it.
def test_mcsensors_from_file_fast_returns_empty(ICDATADIR): | ||
file_in = os.path.join(ICDATADIR, "nexus_new_kr83m_fast.newformat.sim.h5") | ||
sns_gen = mcsensors_from_file([file_in], 'new', -7951) | ||
first_evt = next(sns_gen) | ||
with warnings.catch_warnings(): |
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.
Here you do expect No binning info available.
so maybe you can use
with pytest.warns(UserWarning, match='No binning info available.'):
first_evt = next(sns_gen)
invisible_cities/io/dst_io.py
Outdated
@@ -109,7 +109,7 @@ def df_writer(h5out : tb.file.File , | |||
|
|||
data_types = table.dtype | |||
if len(arr) == 0: | |||
warnings.warn(f'dataframe is empty', UserWarning) | |||
warnings.warn('dataframe is empty', UserWarning) |
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 know that this is not strictly related to this PR but I wonder if we really need this warnings. For example, in pandas to_hdf
no warning is raised if dataframe is empty, so maybe we should just keep the same behavior, ie removing the warning completely. Especially since it is almost never guaranteed to have non-empty df in our flows...
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.
Anybody care to share an opinion on this?
Does anyone ever notice or appreciate this warning appearing? Can anyone remember an instance when this warning helped them? If not, it should probably go.
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.
Marija and I discussed it and we decided to remove it in the final version of this PR. That's why it shows as outdated above.
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 that it shows as outdated, because you have rebased, and the commit id has changed. In my latest checkout of the branch, I can still see the warning being raised (strangely enough, with the superfluous 'f' which was removed here!)
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.
Strange. It's changed in the first commit of the current history and I can't find anywhere in the other commits where it could have been accidentally reintroduced.
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.
Apologies. I failed to notice that a Git LFS error prevented me from looking at the right branch. I confirm that it's gone from the current version.
a4222e1
to
ea40530
Compare
@andLaing You wrote 'closes issue #762' in the commit message, but I think that the presence of 'issue' between 'closes' and '#762' interferes with the pattern that GitHub recognizes: https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword |
Ah, ok, it seemed more natural to specify but I should have checked the standard. My bad, I'll edit the commit message now |
ea40530
to
5b3fdd1
Compare
A fresh installation on a pristine Debian 10 with both Python 3.7 and 3.8 passes all tests with zero warnings. The latest Travis run produces this single warning:
Anyone recognize this? (The Mac OS run fails, but we'll deal with that in a separate PR.) |
Some of the commit messages contain justifications/explanations of why warnings are suppressed/ignored. These should probably be added as comments in the code itself. |
Minor niggle: in 'Change string to r-string in tbl_functions_test' the commit message contains 'Suppress DeprecationWarning', but the warning isn't being suppressed (which would require justification) bit it's being heeded (which requires no further explanation). |
We should also do a review of all the skipped and xfail tests. Probably in a separate PR, unless it can be done quickly. |
Latest Travis run shows no warnings. Add justifications (from commit messages) as comments to source code, and I'm ready to approve. |
In theory, our |
5b3fdd1
to
d1fe416
Compare
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.
All stable warnings have been eliminated, either by addressing the issue they point out, or, where appropriate, ignoring them explicitly. In the latter cases, justifications have been added to both the commit messages and as comments to the code.
This eliminates the deluge of warnings that accompanied each run of the test suite, causing all warnings to be ignored by any humans looking at the test output.
We should go through a similar exercise for skipped and xfailing tests in a separate PR.
Suppresses expected warnings in MC writer and tests as well as tidying imports.