common dim_messages should use warnings
Issue #174
resolved
Instead of using logger.warning
, the freud.common
dim_message
should be output using warnings.warn(dim_message)
. Also the test for freud.common
should ensure that the warning is raised.
Comments (5)
-
-
reporter Sorry, I didn't specify the reason that I wanted to do this. This message pops up every time that tests are run, like this:
$ python -m unittest discover . ..................................ref_points must be a 2 dimensional array ........s.s.s.s.s..................................s.............................................. ---------------------------------------------------------------------- Ran 132 tests in 53.374s OK (skipped=6)
I think this is a little confusing and it's not clear if something is wrong with the tests until you dig in and find where it's coming from. Using
warnings
andassertRaises
is a better solution. -
Got it. My follow-ups:
- Do you think it actually serves a purpose? Is there any reason to not just remove it entirely?
- If you actually think that it is worth keeping as a debugging tool, why not change it to logger.debug? That would better address the fact that it's meant as a debugging tool, and not as a real warning since it should error out anyway unless the subsequent TypeError is explicitly caught.
- If we wanted to add a test for warnings, it would be a bit more complicated than that. We would need to use the catch_warnings function in the warnings package, assertRaises won't catch warnings.
-
reporter Closing after merge of PR 167: https://bitbucket.org/glotzer/freud/pull-requests/167
-
- changed status to resolved
Resolved by Pull Request #167
- Log in to comment
Why should we change this? There's already a TypeError raised, the logger is only for debugging purposes. Although tbh I'm not even sure that should be retained since the error should be sufficient for debugging purposes, we may want to remove it entirely.