summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
...
| * 2to3: apply `dict` fixer.Charles Harris2013-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python3 `dict.items()`, `dict.keys()`, and `dict.values()` are iterators. This causes problems when a list is needed so the 2to3 fixer explicitly constructs a list when is finds on of those functions. However, that is usually not necessary, so a lot of the work here has been cleaning up those places where the fix is not needed. The big exception to that is the `numpy/f2py/crackfortran.py` file. The code there makes extensive use of loops that modify the contents of the dictionary being looped through, which raises an error. That together with the obscurity of the code in that file made it safest to let the `dict` fixer do its worst. Closes #3050.
* | Merge pull request #3202 from charris/2to3-reduce-fixupsnjsmith2013-04-071-3/+1
|\ \ | |/ |/| MAINT: Cleanup some imports involving reduce.
| * MAINT: Cleanup some imports involving reduce.Charles Harris2013-04-061-3/+1
| | | | | | | | | | | | | | | | | | | | Because reduce has been available in functools since Python 2.6 we can get rid of the version checks we currently have before we import it. Also removes some reduce related skips in tools/py3tool.py. We were already skipping the reduce fixer so this has no effect other than cleaning up the code.
* | 2to3: Apply `print` fixer.Charles Harris2013-04-0619-19/+19
|/ | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Apply `imports` fixer.Charles Harris2013-04-026-269/+277
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The `imports` fixer deals with the standard packages that have been renamed, removed, or methods that have moved. cPickle -- removed, use pickle commands -- removed, getoutput, getstatusoutput moved to subprocess urlparse -- removed, urlparse moved to urllib.parse cStringIO -- removed, use StringIO or io.StringIO copy_reg -- renamed copyreg _winreg -- renamed winreg ConfigParser -- renamed configparser __builtin__ -- renamed builtins In the case of `cPickle`, it is imported as `pickle` when python < 3 and performance may be a consideration, but otherwise plain old `pickle` is used. Dealing with `StringIO` is a bit tricky. There is an `io.StringIO` function in the `io` module, available since Python 2.6, but it expects unicode whereas `StringIO.StringIO` expects ascii. The Python 3 equivalent is then `io.BytesIO`. What I have done here is used BytesIO for anything that is emulating a file for testing purposes. That is more explicit than using a redefined StringIO as was done before we dropped support for Python 2.4 and 2.5. Closes #3180.
* 2to3: Use absolute imports.Charles Harris2013-03-2819-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* 2to3: Replace xrange by range and use list(range(...)) where neededCharles Harris2013-03-274-6/+6
| | | | | | | | | | | | | | | In python3 range is an iterator and `xrange` has been removed. This has two consequence for code: 1) Where a list is needed `list(range(...))` must be used. 2) `xrange` must be replaced by `range` Both of these changes also work in python2 and this patch makes both. There are three places fixed that do not need it, but I left them in so that the result would be `xrange` clean. Closes #3092
* TST: Get rid of a ResourceWarning.Charles Harris2013-03-031-6/+15
| | | | | | | | I'm not sure this is the right fix, but test_closing_fid need to check that garbage collection will close a file that goes through a bunch of openings followed by dropping the reference. So the fix is to ignore warnings during the test. I'd just ignore ResourceWarning, but it does not look to be a built in warning in Python 2.7.
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-0119-7/+43
| | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* 2to3: Use modern exception syntax.Charles Harris2013-02-262-3/+3
| | | | Example: except ValueError,msg: -> except ValueError as msg:
* BUG: Make nansum work with booleans.Charles Harris2013-02-121-0/+9
| | | | | | | | This broke when function_base._nannop tried to fill a boolean array with integer zeros, raising a 'safe_casting' error. It looks like nanargmax and nanargmin would also break, and were probably incorrect for booleans in any case. The fix is not to use fill values for boolean and integer dtypes. Previously that was only done for the integer dtypes.
* TST: Add a test for ndindex call.Travis E. Oliphant2013-01-211-0/+4
|
* Fix the test for numpy.ndindex()Travis E. Oliphant2013-01-111-0/+6
| | | | | Fix ndindex for 0-d arrays. Add tests for tuple arguments to ndindex
* Fix the test for numpy.ndindex()Travis E. Oliphant2013-01-101-1/+1
|
* Add test for optional size argument for ndindexJay Bourque2013-01-091-0/+4
|
* TST: Add test for in1d ravellingSebastian Berg2012-12-161-0/+13
| | | | | | The behavior of in1d is not really defined here, but it should be at least consistent over different execution branches. This is what it has been for most usages.
* BUG: Fix regression for in1d with non-array inputSebastian Berg2012-12-081-2/+3
| | | | | | | | | There was a regression introduced by the speed improvement in commit 6441c2a. This fixes it, and generally ravels the arrays for np.in1d. However it can be argued that at least the first array should not be ravelled in the future. Fixes "Issue gh-2755"
* [FIX] preserve memory order in np.copy()Nathaniel J. Smith2012-10-011-0/+26
| | | | | This switches us back to the behaviour seen in numpy 1.6 and earlier, which it turns out that scikit-learn (and probably others) relied on.
* TST: Add test for boolean insertHan Genuit2012-09-071-0/+2
|
* TST: Add extra test for multidimensional inserts.Han Genuit2012-09-071-0/+7
|
* Improve ndindex execution speed.Stefan van der Walt2012-09-021-1/+7
|
* BUG: Fix some tests in PR #192Travis E. Oliphant2012-07-171-8/+8
|
* Merge pull request #352 from HackerSchool12/bugfix808Travis E. Oliphant2012-07-171-1/+2
|\ | | | | BF bug #808
| * BUG: Ticket #808: Insert was not performing properly when an integer wasLoftie Ellis2012-07-151-1/+2
| | | | | | | | | | | | | | the argument passed to be used as the item to be insterted, and a list was passed as the positions. This was fixed by simply duplicating the item to be inserted so that it was a list of equal length and then control was passed to the already exsisting code to handel this case
* | Merge pull request #192 from rgommers/meshgrid3dTravis E. Oliphant2012-07-171-0/+28
|\ \ | | | | | | Meshgrid enhancements (>2-D, sparse grids, matrix indexing)
| * | STY: meshgrid: some minor changes to address review comments.Ralf Gommers2012-02-051-4/+1
| | |
| * | TST: meshgrid: test expected shapes for Cartesian and matrix indexing.Ralf Gommers2011-12-281-1/+12
| | |
| * | BUG: meshgrid: raise error on single input.Ralf Gommers2011-12-281-0/+4
| | |
| * | MAINT: clean up docstring and some minor items in meshgrid. Remove ndgrid.Ralf Gommers2011-12-131-2/+0
| | |
| * | ENH: enhance meshgrid to generate 3D grids, sparse grids, matrix indexing.Per A. Brodtkorb2011-12-131-0/+18
| | |
* | | Fix `WindowsError: [Error 32]` in test_not_closing_opened_fid ↵cgohlke2012-07-161-0/+1
| |/ |/| | | | | (test_io.TestSavezLoad)
* | Merge pull request #337 from rgommers/pull-335-genfromtxtRalf Gommers2012-07-111-3/+8
|\ \ | | | | | | BUG: make genfromtxt work with comments=None. Closes Github issue 329.
| * | BUG: genfromtxt: make comments=None work with spaces in strings.Ralf Gommers2012-07-111-0/+3
| | |
| * | BUG: make genfromtxt work with comments=None. Closes Github issue 329.martingoodson2012-07-101-3/+5
| | |
* | | BUG: test_unique needs to test bigger arrays.Charles Harris2012-07-111-37/+31
| | | | | | | | | | | | | | | | | | | | | | | | Small arrays are sorted with insertion sort, which is a stable sort. Consequently larger arrays are needed to check that the sort used is properly stable. The test was also refactored to make it more compact.
* | | TST: Improve type coverage in test_unique.Charles Harris2012-07-111-20/+57
|/ /
* | BF(PY3): open file handles in tests in binary modeYaroslav Halchenko2012-07-061-3/+3
| | | | | | | | | | otherwise zipfile of python3 gets confused to receive bytes for the header whenever handle is opened for a text (unicode) file
* | ENH: added a rudimentary test for having #1517 (too many open files) fixedYaroslav Halchenko2012-07-051-0/+24
| |
* | ENH: unittest for preceeding commit fixing #2178Yaroslav Halchenko2012-07-021-0/+21
| |
* | Merge pull request #290 from mforbes/new-vectorize-cleanTravis E. Oliphant2012-06-121-27/+128
|\ \ | | | | | | ENH: Add kwarg support for vectorize (tickets #2100, #1156, and #1487) (clean)
| * | ENH: Add kwarg support for vectorize (tickets #2100, #1156, and #1487)Michael McNeil Forbes2012-05-311-27/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a substantial rewrite of vectorize to remove all introspection and caching behaviour. This greatly simplifies the logic of the code, and allows for much more generalized behaviour, simultaneously fixing tickets #1156, #1487, and #2100. There will probably be a performance hit because caching is no longer used (but should be able to be reinstated if needed). As vectorize is a convenience function with poor performance in general, perhaps this is okay. Rather than trying to inspect the function to determine the number of arguments, defaults, and argument names, we just use the arguments passed on the call to determine the behaviour on each call. All tests pass and code is fully covered Fixes: Ticket #2100: kwarg support for vectorize - API: Optional excluded argument to exclude some args from vectorization. - Added documentation, examples, and coverage tests - Added additional coverage test and base case for functions with no args - Factored original behaviour into _vectorize_call - Some minor documentation and error message corrections Ticket #1156: Support vectorizing over instance methods - No longer an issue since everything is determined by the call. Ticket: #1487: result depends on execution order - No longer caching, so the behaviour is as was expected. ENH: Simple cache for vectorize - Added simple cache to prevent vectorize from calling pyfunc twice on the first argument when determining the output types and added regression test. - Added documentation for excluded positional arguments. - Documentation cleanups. - Cleaned up variable names. ENH: Performance improvements for backward compatibility of vectorize. After some simple profiling, I found that the wrapping used to support the caching of the previous commit wasted more time than it saved, so I added a flag to allow the user to toggle. Moral: caching makes sense only if the function is expensive and is off by default. I also compared performance with the original vectorize and opted for keeping a cache of _ufunc if otypes is specified and there are no kwargs/excluded vars. This case is easy to implement, and allows users to reproduce (almost) the old performance characteristics if needed. (The new version is about 5% slower in this case). It would be much more complicated to add a similar cache in the case where kwargs are used, and since a wrapper is used here, the performance gain would be negligible (profiling showed that wrapping was a more significant slowdown than the extra call to frompyfunc). - API: Added cache kwarg which allows the user to toggle caching of the first result. - DOC: Added Notes section with a discussion of performance and a warning that vectorize should not be used for performance. - Added private _ufunc member to implement old-style of cache for special case with no kwargs, excluded, and with otypes specified. - Modified test case. Partially address ticket #1982 - I tried to use hasattr(outputs, '__len__') rather than isinstance(outputs, tuple) in order to allow for functions to return lists. This, however, means that strings will get vectorized over each character which breaks previous behaviour. Keeping old behaviour for now.
* | | add the warp parameter to fill_diagonal for people that could want the old ↵Frederic2012-06-111-0/+16
| | | | | | | | | | | | behavior.
* | | fix the wrapping problem of fill_diagonal with tall matrix.Frederic2012-06-111-0/+22
|/ /
* | BUG: Changed ipmt to accept array_like arguments.Tim Cera2012-05-201-0/+80
| | | | | | | | | | The ipmt function was also fixed to handle broadcasting. The tests were improved and extended to cover the broadcasting capability.
* | BUG: Fix some test bugs.Charles Harris2012-05-021-4/+4
| | | | | | | | | | Fix incorrect python version checks in test_print.py. Fix missing build_err_msg import and wrong variable in test_io.py.
* | BUG: Fix missing np prefix in test_function_base.py.Charles Harris2012-04-051-1/+1
| |
* | Merge pull request #245 from jseabold/digitize-open-rightTravis E. Oliphant2012-04-041-2/+25
|\ \ | | | | | | ENH: Give digitize left or right open interval option
| * | TST: Add namespaces to digitize tests + one more testSkipper Seabold2012-04-031-9/+17
| | |
| * | ENH: Give digitize left or right open interval optionSkipper Seabold2012-04-031-0/+15
| | |
* | | ENH: Add module containing functions for padding n-dimensional arrays.tim cera2012-04-041-0/+530
|/ / | | | | | | | | | | | | | | | | | | | | | | | | The various padding functions are exposed as options to a public 'pad' function. Example: pad(a, 5, mode='mean') Current modes are 'constant', 'edge', 'linear_ramp', 'maximum', 'mean', 'median', 'minimum', 'reflect', 'symmetric', 'wrap', and <function> This commit includes unit tests and doctests and is based on feature request ticket #655.