summaryrefslogtreecommitdiff
path: root/numpy/lib
Commit message (Collapse)AuthorAgeFilesLines
* MAINT: Use np.errstate context manager.Charles Harris2013-07-113-83/+26
| | | | | | | | | | | | | Now that Python < 2.6 is no longer supported we can use the errstate context manager in places where constructs like ``` old = seterr(invalid='ignore') try: blah finally: seterr(**old) ``` were used.
* TST: New test to ensure np.pad allows pad_width of zero.Jostein Bø Fløystad2013-07-051-0/+8
|
* BUG: Allow to pad arrays by zero entries.Jostein Bø Fløystad2013-07-051-1/+1
| | | | | np.pad will now accept a pad_width containing zeros. The functionality was already implemented, but validation of input was too strict.
* BUG: Make np.load transfer file ownership to the returned NpzFile.Charles Harris2013-06-222-5/+22
| | | | | | | This assures that when the loaded file is closed it also closes the file descriptor, avoiding a resource warning in Python3. Closes #3457.
* adjust the optimal IO buffer size for npz filesBartosz Telenczuk2013-06-123-15/+14
|
* Chunk reads in format.read_array.Alex Ford2013-06-121-3/+14
| | | | | | | | | Maximum data size limitations in the crc32 module cause errors when reading more than 2 ** 32 bytes from gzip streams. Work around this issue when reading large arrays from npz files by chunking reads to 256mb. This appears to resolve bug #2922.
* BUG: fix loading large npz files (fixes #2922)Bartosz Telenczuk2013-06-122-6/+25
|
* Merge pull request #3243 from seberg/deprecate-non-integer-arguments-newCharles Harris2013-06-092-2/+2
|\ | | | | Deprecate non integer arguments
| * STY: Style fixes for integer deprecation changesSebastian Berg2013-06-091-1/+1
| | | | | | | | Also minor changes in the documentation.
| * MAINT: adept divisions for truedivideSebastian Berg2013-05-312-2/+2
| | | | | | | | Following deprecations would cause problems otherwise.
* | BUG: The npv function in financial.py was incorrectly implemented.bebert2182013-05-292-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Correct the implementation of the npv function, its documentation, and the mirr function that depends on it. The test_financial.py is also corrected to take into account those modifications The npv function behavior was contrary to what the documentation stated as it summed indexes 1 to M instead of 0 to M-1. The mirr function used a corrective factor to get the correct result in spite of that error so that factor is removed. Closes #649
* | ENH: improve performance of byte_bounds for continous arraysJulian Taylor2013-05-281-2/+1
| |
* | ENH: implement may_share_memory in CJulian Taylor2013-05-282-31/+16
| | | | | | | | | | | | | | | | | | 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
* | DOC: Correcting docstring for asscalarDan Miller2013-05-251-1/+2
| |
* | Merge pull request #3339 from endolith/min_max_docstringsCharles Harris2013-05-201-18/+38
|\ \ | | | | | | DOC: Min max docstrings
| * | DOC: Harmonize max and min docstrings with each otherendolith2013-05-171-8/+10
| | |
| * | DOC: Mention all min/max functions from all others, clarify differencesendolith2013-05-161-10/+28
| |/
* | Merge pull request #3329 from JDWarner/faster_arraypadCharles Harris2013-05-192-429/+1102
|\ \ | |/ |/| ENH: improved, faster algorithm for array padding
| * ENH: improved, faster algorithm for array paddingJosh Warner (Mac)2013-05-192-429/+1102
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix issue with broadcast_arrays() and user defined dtypesJay Bourque2013-05-101-1/+4
|/ | | | broadcast_arrays() does not handle struct and custom dtypes correctly. Dtype of returned broadcasted arrays is always '|V8'. Fix broadcast_arrays() so that dtype of returned arrays is correct dtype for user defined dtypes.
* STY: pep8 and pep257 audit.Josh Warner (Mac)2013-05-071-89/+101
| | | | | | Audit numpy/lib/arraypad.py for pep8 and pep257 compliance. Also fix a few minor docstring corrections converting ] into ) or vice versa.
* Merge pull request #3264 from endolith/patch-1Charles Harris2013-05-041-8/+5
|\ | | | | DOC: Change example to demonstrate function
| * DOC: Change example to demonstrate functionendolith2013-04-191-8/+5
| | | | | | "a * 0.5" example might as well be new_func(a) directly, it doesn't demonstrate the purpose of apply_along_axis().
* | MAINT: Apply 2to3 idioms fixer.Charles Harris2013-05-029-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idioms fixer makes the following replacements. 1) int <- bool 2) comparison or identity of types <- isinstance 3) a.sort() <- sorted(a) There were two problems that needed to be dealt with after the application of the fixer. First, the replacement of comparison or identity of types by isinstance was not always correct. The isinstance function returns true for subtypes whereas many of the places where the fixer made a substitution needed to check for exact type equality. Second, the sorted function was applied to arrays, but because it treats them as iterators and constructs a sorted list from the result, that is the wrong thing to do. Closes #3062.
* | Merge pull request #3280 from seberg/issue-3279seberg2013-04-272-1/+6
|\ \ | | | | | | BUG: np.insert must copy index array
| * | BUG: np.insert must copy index arraySebastian Berg2013-04-272-1/+6
| | | | | | | | | | | | Otherwise it would do in-place changes to it. Fixes gh-3279.
* | | MAINT: Remove unneeded version checks.Charles Harris2013-04-242-13/+5
| | | | | | | | | | | | | | | | | | Now that only Python versions 2.6-2.7 and 3.2-3.3 are supported some version checks are no longer needed. This patch removes them so as to clean up the code.
* | | MAINT: Use from future_builtins zip and map.Charles Harris2013-04-212-10/+7
| | | | | | | | | | | | | | | | | | For Python versions 2.6 and 2.7 the iterator forms of zip and map can be imported from future_builtins. That is done here so as to avoid using itertools.{izip, imap}.
* | | 2to3: Apply unicode fixer.Charles Harris2013-04-213-7/+15
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #3249 from charris/2to3-apply-next-fixerCharles Harris2013-04-152-11/+16
|\ \ | | | | | | 2to3: Apply next fixer.
| * | 2to3: Apply next fixer.Charles Harris2013-04-152-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The next builtin has been available since Python 2.6 and allows `it.next()` to be replaced by `next(it)`. In Python 3 the `next` method is gone entirely, replaced entirely by the `__next__` method. The next fixer changes all the `it.next()` calls to the new form and renames the `next` methods to `__next__`. In order to keep Numpy code backwards compatible with Python 2, a `next` method was readded to all the Numpy iterators after the fixer was run so they all contain both methods. The presence of the appropriate method could have been made version dependent, but that looked unduly complicated. Closes #3072.
* | | 2to3: Apply urllib fixer.Charles Harris2013-04-142-10/+22
|/ / | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #3244 from charris/2to3-apply-zip-fixerCharles Harris2013-04-145-23/+23
|\ \ | | | | | | 2to3: Apply zip fixer.
| * | 2to3: Apply zip fixer.Charles Harris2013-04-135-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 basestring fixer.Charles Harris2013-04-134-3/+4
|/ / | | | | | | | | | | | | | | | | | | | | The basestring class is not defined in Python 3 and the fixer replaces it with str. In order to have a common code base we define basestring in numpy/compat/py3k.py to be str when the Python version is >= 3, otherwise basestring and import it where needed. That works for most cases, but there are a few files where the version dependent define needs to be in the file. Closes #3042.
* | 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-1310-16/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | 2to3: Apply itertools fixer.Charles Harris2013-04-122-4/+11
|/ | | | | | | | | | | | | In Python 3 zip, map, and filter are all iterators, consequently the itertools variants izip, imap, and ifilter have been removed and the itertools fixer replaces them with the unprefixed names. Because the places where the iterator variants are used in current look like places where the iterator version might be useful, the approach taken here is to define the prefixed versions to the unprefixed versions for Python 3, but otherwise import them from itertools. Closes #3233.
* FIX: rename xrange to range in python 2Sebastian Berg2013-04-111-1/+4
| | | | | | np.delete abuses range to calculate start/stop/step and len. This would create potentially large intermediates if it was a list, so for numpy/lib/function_base.py and python < 3, use range = xrange.
* MAINT: np.delete keep old out of bound/negative index behaviorSebastian Berg2013-04-112-19/+36
|
* TST: New tests for insert/delete covering warnings and corner casesSebastian Berg2013-04-111-9/+65
|
* FIX: insert/delete fixes and warnings for non-integer indicesSebastian Berg2013-04-111-25/+43
|
* ENH: larger fixes for np.delete and np.insert functionsSebastian Berg2013-04-112-55/+198
| | | | | | | | | | | | | | | | | | 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.
* Merge pull request #3216 from charris/2to3-apply-map-fixerCharles Harris2013-04-107-22/+24
|\ | | | | 2to3: Apply `map` fixer.
| * 2to3: Apply `map` fixer.Charles Harris2013-04-107-22/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python 3 `map` is an iterator while in Python 2 it returns a list. The simple fix applied by the fixer is to inclose all instances of map with `list(...)`. This is not needed in all cases, and even where appropriate list comprehensions may be preferred for their clarity. Consequently, this patch attempts to use list comprehensions where it makes sense. When the mapped function has two arguments there is another problem that can arise. In Python 3 map stops execution when the shortest argument list is exhausted, while in Python 2 it stops when the longest argument list is exhausted. Consequently the two argument case might need special care. However, we have been running Python3 converted versions of numpy since 1.5 without problems, so it is probably not something that affects us. Closes #3068
* | ENH: add `invert` parameter to numpy.in1d().Julien Phalip2013-04-082-7/+35
|/
* Merge pull request #3205 from charris/2to3-apply-dict-fixerCharles Harris2013-04-077-9/+9
|\ | | | | 2to3: apply `dict` fixer.
| * 2to3: apply `dict` fixer.Charles Harris2013-04-067-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-072-5/+2
|\ \ | |/ |/| MAINT: Cleanup some imports involving reduce.
| * MAINT: Cleanup some imports involving reduce.Charles Harris2013-04-062-5/+2
| | | | | | | | | | | | | | | | | | | | 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-0642-80/+80
|/ | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.