Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST, MAINT: Lots of new tests for fromnumeric.py #7027

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

Merged
merged 1 commit into from
Jan 19, 2016
Merged

TST, MAINT: Lots of new tests for fromnumeric.py #7027

merged 1 commit into from
Jan 19, 2016

Conversation

gfyoung
Copy link
Contributor

@gfyoung gfyoung commented Jan 16, 2016

Follow-up from #7000 in which I found there seemed to be a gap in testing for the numpy/numpy/core/fromnumeric.py file. This PR improves the coverage on the methods defined in that file.

@gfyoung gfyoung changed the title TST: Lots of new tests for fromnumeric.py TST, MAINT: Lots of new tests for fromnumeric.py Jan 16, 2016
@charris
Copy link
Member

charris commented Jan 17, 2016

Please don't rebase.

@gfyoung
Copy link
Contributor Author

gfyoung commented Jan 18, 2016

PR is no longer WIP. Travis + Appveyor are both passing. Should be good to merge now.


def test_basic(self):
A = np.choose(self.ind, (self.x, self.y))
A = self.ind.choose((self.x, self.y))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should keep the first version in order to test the funtion, not the method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@charris
Copy link
Member

charris commented Jan 18, 2016

Looks generally good, but the common mistake is to substitute methods for functions. The two aren't the same despite the apparent redundancy. The methods should actually be tested in the numpy/core/tests/test_multiarray.py huge TestMethods class. Note that Numeric was the first version of what became Numpy and didn't have many methods.

@gfyoung
Copy link
Contributor Author

gfyoung commented Jan 19, 2016

@charris : Changes made and Travis / Appveyor are happy.

@@ -1,17 +0,0 @@
from __future__ import division, absolute_import, print_function
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this file? fromnumeric.py is a package containing a number of functions. put is also a function implemented in fromnumeric.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that file myself from #7000 that served as a stopgap measure to test that put would not accept non-ndarray args. Also, a lot of the tests of fromnumeric.py functions are located elsewhere in the tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, at some point we need to reorganize numpy/core, but I suppose that is for another day.

@charris
Copy link
Member

charris commented Jan 19, 2016

I think you need to check carefully where functions/methods etc are defined. The easy way to check functions in ipython is to use the ? help option on the function name. Or you can look at the __all__ list in the modules to see what functions are exported. You can check ndarray methods with ndarray.<themethod>?.

@gfyoung
Copy link
Contributor Author

gfyoung commented Jan 19, 2016

If you look at the functions defined in fromnumeric.py, almost all of them are tested elsewhere in the code-base, even though they are in the __all__ array. For example np.prod is defined here, but the test is here.

My original intention was to write an entire test_fromnumeric.py but after searching the code base for many of these functions, I realized that I would just be duplicating already existing tests.

charris added a commit that referenced this pull request Jan 19, 2016
TST, MAINT: Lots of new tests for fromnumeric.py
@charris charris merged commit 275fa79 into numpy:master Jan 19, 2016
@charris
Copy link
Member

charris commented Jan 19, 2016

Thanks @gfyoung .

@gfyoung gfyoung deleted the test_fromnumeric_expand branch January 19, 2016 20:59
@homu homu mentioned this pull request Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants