summaryrefslogtreecommitdiff
path: root/numpy/lib/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* ENH: implement may_share_memory in CJulian Taylor2013-05-281-0/+15
| | | | | | | | | memmap needs to call it in __array_finalize__ to determine if it can drop the references on copies. The python version if may_share_memory caused significant slowdowns when slicing these maps. closes gh-3364
* ENH: improved, faster algorithm for array paddingJosh Warner (Mac)2013-05-191-15/+15
| | | | | | | | | | | | New padding method which scales much better with dimensionality. This new implementation is fully vectorized, builds each abstracted n-dimensional padding block in a single step, and takes advantage of separability. The API is completely preserved, and the old algorithm is used if a vector function is input for `mode`. The new algorithm is faster for all tested combinations of inputs, and scales much better with dimensionality. Execution time reductions from ~25% for small rank 1 arrays to >99% for rank 4+ arrays observed.
* Merge pull request #3280 from seberg/issue-3279seberg2013-04-271-0/+4
|\ | | | | BUG: np.insert must copy index array
| * BUG: np.insert must copy index arraySebastian Berg2013-04-271-0/+4
| | | | | | | | Otherwise it would do in-place changes to it. Fixes gh-3279.
* | 2to3: Apply unicode fixer.Charles Harris2013-04-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The unicode fixer strips the u from u'hi' and converts the unicode type to str. The first won't work for Python 2 and instead we replace the u prefix with the sixu function borrowed from the six compatibility package. That function calls the unicode constructor with the 'unicode_escape' encoder so that the many tests using escaped unicode characters like u'\u0900' will be handled correctly. That makes the sixu function a bit different from the asunicode function currently in numpy.compat and also provides a target that can be converted back to the u prefix when support for Python 3.2 is dropped. Python 3.3 reintroduced the u prefix for compatibility. The unicode fixer also replaces 'unicode' with 'str' as 'unicode' is no longer a builtin in Python 3. For code compatibility, 'unicode' is defined either as 'str' or 'unicode' in numpy.compat so that checks like if isinstance(x, unicode): ... will work properly for all python versions. Closes #3089.
* | 2to3: Apply urllib fixer.Charles Harris2013-04-141-6/+10
| | | | | | | | | | | | | | | | | | | | | | Various functions have been moved around in the stdlib for Python 3, this fixes that up so that the code is valid in both Python 2 and Python 3. Note: monkey patching the stlib urlopen for testing looks a bit hokey to me, but I don't see an easier, more reliable way to do the test. Closes #3090.
* | 2to3: Apply zip fixer.Charles Harris2013-04-133-16/+16
| | | | | | | | | | | | | | | | | | | | In Python 3 zip returns an iterator instead of a list. Consequently, in places where an iterator won't do it must be enclosed in list(...). Lists instead of iterators are also used in array constructors as using iterators there usually results in an object array containing an iterator object. Closes #3094
* | 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-134-6/+7
|/ | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* MAINT: np.delete keep old out of bound/negative index behaviorSebastian Berg2013-04-111-10/+13
|
* TST: New tests for insert/delete covering warnings and corner casesSebastian Berg2013-04-111-9/+65
|
* ENH: larger fixes for np.delete and np.insert functionsSebastian Berg2013-04-111-2/+51
| | | | | | | | | | | | | | | | | | There were several smaller to larger problems for these two functions, that this addresses: * delete did not handle out of bound values graciously (ignoring negative ones) * both were unnecessarily slow due to use of sets * insert did not handle unsorted indices correctly Further changes: * Add FutureWarning for boolean obj, so it can be handled similar to a boolean mask with indexing. * Add FutureWarning to remove inconsistent special cases for 0-d arrays (neither insertion nor deletion along an axis make sense for a scalar) * Allow insertion of an array with more then one element along axis when obj is a sequence with a single item. (i.e. array([1])). * Reintroduce speed optimization for scalar in insert that existed in 1.6.
* ENH: add `invert` parameter to numpy.in1d().Julien Phalip2013-04-081-0/+9
|
* Merge pull request #3205 from charris/2to3-apply-dict-fixerCharles Harris2013-04-071-2/+2
|\ | | | | 2to3: apply `dict` fixer.
| * 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