-
Notifications
You must be signed in to change notification settings - Fork 37
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
Tidied up imports and testing #2
Tidied up imports and testing #2
Conversation
Looks good to me! I have some additional refactoring + testing ideas that I promise to spend some time on in the near future |
@@ -109,9 +109,9 @@ Unit Tests and Benchmarks | |||
Several unit tests are included, and are also installed with the package. |
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.
This line needs to be updated, as I believe the tests and benchmarks are no longer installed with the package.
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.
The tests are still installed with the package, and I'm adding the benchmark back too.
@astrofrog, this looks great. Personally, I prefer that tests and benchmarks get installed with the package (helps when providing support to end users since you can then ask them to run tests even if they didn't install the package themselves), but I don't think it's a big deal. As for I think what you need to replace it is
|
Ah-ha, I didn't realize it also checked the values without worrying about the order. I'll fix that. I'll also add the benchmark back to the source tree. |
Note that the next thing I would like to do is make it so that tests can be simply run with
for exactly the reason @bradenmacdonald suggests, that we want to be able to provide support to users who have installed it and no longer have the source tree. But I'll leave that for the next PR. |
@bradenmacdonald - I thin I've implemented your suggestions - could you double check? Is this ok to merge? |
👍 Looks great! |
Tidied up imports and testing
This PR changes from using unittest to py.test for testing (which has a number of advantages, such as parametrized tests, coverage tests, etc.). This involves:
runtests.py
at the root of the package directory (this should not be moved to e.g.scripts
) as it should not be installed, and updatesetup.py
appropriately. Note thatruntests.py
contains everything needed to run py.test, so no need to install it as a separate dependency.unittest
specific syntax to normal asserts, which py.test understands - this makes the asserts more readable in my opinionastrodendro
To run tests:
Note that one test is failing due to a change from
assertItemsEqual
toassert np.all(x == y)
which I am not sure if it is correct. @bradenmacdonald - what were you intending to do withassertItemsEqual
? That function just asserts that the elements have elements with the same length, but not that the actual values are equal - is that intentional?I also used this as a chance to fix PEP8 warnings, but it makes the diff harder to read. To ignore whitespace changes, add
?w=0
to the URL once you are viewing the diff.I also moved
benchmark.py
outside the source package, as I don't think it belongs in the installed source.@bradenmacdonald and @ChrisBeaumont - let me know what you think!