summaryrefslogtreecommitdiff
path: root/numpy
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | | | | | | | | DEP,MAINT: Remove deprecated functions from npy_3kcompat.hCharles Harris2015-06-211-45/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These functions npy_PyFile_Dup and npy_PyFile_DupClose do not work correctly in Python 3. Deprecation messages have been raised in npy_PyFile_Dup since 1.9 and it is probably best to smoke out any remaining uses by simply removing the function.
* | | | | | | | | | | Merge pull request #5989 from argriffing/polynomial-improvementsCharles Harris2015-06-192-3/+1
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | MAINT: improve laguerre and legendre efficiency
| * | | | | | | | | | | MAINT: improve laguerre and legendre efficiencyalex2015-06-192-3/+1
| | | | | | | | | | | |
* | | | | | | | | | | | Merge pull request #5988 from argriffing/eigvalsh-ordering-updateCharles Harris2015-06-192-8/+4
|\ \ \ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / / / |/| | | | | | | | | | | MAINT: notice that eigvalsh returns a sorted array
| * | | | | | | | | | | MAINT: notice that eigvalsh returns a sorted arrayalex2015-06-192-8/+4
| | |_|_|_|_|_|_|_|/ / | |/| | | | | | | | |
* | | | | | | | | | | Merge pull request #5985 from ajdawson/lgauss-symargriffing2015-06-191-1/+1
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | ENH: Take advantage of symmetry in leggauss.
| * | | | | | | | | | | ENH: Take advantage of symmetry in leggauss.Andrew Dawson2015-06-191-1/+1
| |/ / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The calculation of points and weights for Gauss-Legendre quadrature can take advantage of the symmetry of the companion matrix when computing its eigenvalues in order to speed up the computation.
* | | | | | | | | | | Merge pull request #5987 from argriffing/eighvalsh-docsCharles Harris2015-06-191-1/+1
|\ \ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | DOC: update eigvalsh docstring example
| * | | | | | | | | | | DOC: update eigvalsh docstring examplealex2015-06-191-1/+1
| |/ / / / / / / / / /
* | | | | | | | | | | Merge pull request #5943 from ahaldane/record_finalizeCharles Harris2015-06-195-64/+115
|\ \ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / / |/| | | | | | | | | | BUG: automatically convert recarray dtype to np.record
| * | | | | | | | | | BUG: automatically convert recarray dtype to np.recordAllan Haldane2015-06-195-64/+115
| |/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Viewing an ndarray as a np.recarray now automatically converts the dtype to np.record. This commit also fixes assignment to MaskedArray's dtype attribute, fixes the repr of recarrays with non-structured dtype, and removes recarray.view so that viewing a recarray as a non-structured dtype no longer converts to ndarray type. Fixes #3581
* | | | | | | | | | MAINT: Rename npy_cache_pyfunc to npy_cache_import.Charles Harris2015-06-186-10/+10
|/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function will be new in NumPy 1.10, so get this done before branching that version. The old name was a bit too specific for a function that could also be used to cache other attributes than just functions.
* | | | | | | | | Merge pull request #5980 from seberg/large-flat-concatCharles Harris2015-06-182-4/+18
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | BUG: Large concatenates with axis=None causing segfault.
| * | | | | | | | | BUG: Large concatenates with axis=None causing segfault.Sebastian Berg2015-06-182-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was due to sizes assuming a MAX_ARGS, just remove usage and call PyArray_SIZE each time. Closes gh-5979
* | | | | | | | | | BUG Ensure masked object arrays can always return single items.Marten van Kerkwijk2015-06-172-0/+18
| |/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For a masked array holding objects that themselves are arrays, when selecting a single item, it is treated as if it were a slice of the array and an attempt is made to set its mask. This was always a bug, but it become visible with a recent change to `MaskedArray.__getitem__` (gh-4586) where it is attempted to change the shape of the mask. With this PR, this case gets special treatment in that the object is made into a Masked Array with a full set mask. (A previous attempt to do the perhaps more logical think and just return `masked` caused quite a few errors in astropy.io.votable; it seemed it was not worth breaking backwards compatibility that much). Test case that now works but used to fail: ``` mx1 = MaskedArray([1.], mask=[True]) mx2 = MaskedArray([1., 2.]) mx = MaskedArray([mx1, mx2], mask=[False, True]) mx[0] ```
* | | | | | | | | Merge pull request #3907 from mhvk/ma/allow-subclass-in-ufuncCharles Harris2015-06-173-104/+147
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | BUG allow subclasses in MaskedArray ufuncs -- for non-ndarray _data
| * | | | | | | | | BUG Allow subclasses in MaskedArray ufuncs -- for non-ndarray _dataMarten van Kerkwijk2015-06-163-104/+147
| | | | | | | | | |
* | | | | | | | | | ENH: simplify field indexing of structured arraysAllan Haldane2015-06-176-126/+165
|/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit simplifies the code in array_subscript and array_assign_subscript related to field access. This fixes #4806, and also removes a potential segfaults, eg if the array is indexed using an sequence-like object that raises an exception in getitem. Also fixes #5631, related to creation of structured dtypes with no fields (an unusual and probably useless edge case). Also moves all imports in _internal.py to the top. Fixes #4806. Fixes #5631.
* | | | | | | | | Auto merge of #5967 - wimglenn:bugfix/empty_string_array, r=sebergHomu2015-06-162-2/+52
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG: fix inconsistency with np.array(['']) being truthy ``` a = np.array([0]) b = np.array([None]) c = np.array(['']) d = np.array([' ']) ``` Why should we have this inconsistency: ``` >>> bool(a) False >>> bool(b) False >>> bool(c) True >>> bool(d) False ```
| * | | | | | | | | whoops dont need that bit anymorewim glenn2015-06-151-4/+0
| | | | | | | | | |
| * | | | | | | | | the code changes to make those new tests passwim glenn2015-06-151-6/+10
| | | | | | | | | |
| * | | | | | | | | tests for removing explicit size checkwim glenn2015-06-151-1/+34
| | | | | | | | | |
| * | | | | | | | | grrr python 3.2wim glenn2015-06-151-2/+2
| | | | | | | | | |
| * | | | | | | | | BUG: fix inconsistency with np.array(['']) being truthywim glenn2015-06-152-0/+17
| | | | | | | | | |
* | | | | | | | | | Merge pull request #4617 from mhvk/ma/no-direct-ndarray-methodsCharles Harris2015-06-151-40/+26
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | ENH: allow subclass overrides by removing explicit ndarray methods
| * | | | | | | | | | ENH: allow subclass overrides by removing explicit ndarray methodsMarten van Kerkwijk2015-06-101-40/+26
| | | | | | | | | | |
* | | | | | | | | | | Merge pull request #5968 from larsmans/c-fixesCharles Harris2015-06-158-211/+233
|\ \ \ \ \ \ \ \ \ \ \ | |_|_|/ / / / / / / / |/| | | / / / / / / / | | |_|/ / / / / / / | |/| | | | | | | | FIX sprintf bug + get rid of a lot of warnings
| * | | | | | | | | MAINT: build_utils: get rid of more sprintf callsLars Buitinck2015-06-151-7/+5
| | | | | | | | | |
| * | | | | | | | | MAINT: change {arg,}sort functions' type to PyArray_{Arg,}SortFuncLars Buitinck2015-06-155-198/+216
| | | | | | | | | |
| * | | | | | | | | BUG: erroneous use of sprintfLars Buitinck2015-06-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Output argument was a char ** instead of a char *. Also changed to use snprintf for safety; if the error message is ever changed, the magic number 174 (!?) is likely to go stale, causing buffer overruns.
| * | | | | | | | | MAINT: Py3 changes PySlice_GetIndices' first argument's type to PyObject*Lars Buitinck2015-06-141-4/+10
| | | | | | | | | |
* | | | | | | | | | TST: Test einsum for small boolean matrices.Charles Harris2015-06-141-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See #5946. The input/output pointers were being incorrectly incremented.
* | | | | | | | | | Merge pull request #5946 from seberg/einsum-bool-fixCharles Harris2015-06-141-20/+11
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | BUG: einsums bool_sum_of_products_contig incorrect for small arrays
| * | | | | | | | | | BUG: einsums bool_sum_of_products_contig incorrect for small arraysSebastian Berg2015-06-061-20/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The small array (and end of loop) special case incorrectly stepped through array and left pointers bogus.
* | | | | | | | | | | TST: Add test for segfault in richcompare of void type ==, !=.Charles Harris2015-06-141-0/+13
| |_|_|/ / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed by #5964, but might as well keep the test from #5960.
* | | | | | | | | | TST: Test __array_priority__ for different class combinations.Charles Harris2015-06-131-2/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This checks the four classes with different __array_priority__ values against each other for the operators __add__, __radd__ __sub__, __rsub__ __mul__, __rmul__ __pow__, __rpow__ __div__, __rdiv__ __mod__, __rmod__ __truediv__, __rtruediv__ __floordiv__, __rfloordiv__ __and__, __rand__ __xor__, __rxor__ __or__, __ror__ __lshift__, __rlshift__ __rshift__, __rrshift__ __eq__ __ne__ __gt__ __ge__ __lt__ __le__ The classes are ndarray, two subclasses of ndarray, and a class unrelated to ndarray. The combinations checked are ndarray -- ndarray subclass ndarray -- unrelated class ndarray subclass -- ndarray subclass ndarray subclass -- unrelated class
* | | | | | | | | | TST: Test that NotImplemented is not longer returnedCharles Harris2015-06-131-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following functions now raise a TypeError instead of returning NotImplemented: np.power, np.add, np.subtract, np.multiply, np.divide, np.bitwise_and, np.bitwise_or, np.bitwise_xor, np.floor_divide, np.fmax, np.fmin, np.fmod, np.hypot, np.logaddexp, np.logaddexp2, np.logical_and, np.logical_or, np.logical_xor, np.maximum, np.minimum, np.mod Functions that remain to be fixed: np.greater, np.greater_equal, np.less, np.less_equal, np.not_equal
* | | | | | | | | | STY: Minor style cleanups in tests and C code.Charles Harris2015-06-132-18/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also added back some extended error messages that were in original PR #5864.
* | | | | | | | | | BUG: Fix test_void_dtype_equality_failures for Python 3.Charles Harris2015-06-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The NotArray test class needs to define a `__ne__` method, otherwise the inherited Python 3 method will call `__eq__`, resulting in two rather than one DeprecationWarning.
* | | | | | | | | | MAINT: make the deprecation warnings a little more distinctiveNathaniel J. Smith2015-06-131-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is probably a good change in any case, and in particular might help with debugging whatever bizarro thing is going wrong on Travis.
* | | | | | | | | | MAINT: Remove NotImplemented handling from ufuncs (almost)Nathaniel J. Smith2015-06-135-95/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was redundant/broken anyway. See gh-5844 for discussion. See the massive comment added to ufunc_object.c:get_ufunc_arguments for a discussion of the deprecation strategy here -- it turns out that array_richcompare is such a disaster zone that we can't quite wholly eliminate NotImplemented quite yet. But this removes most NotImplementeds, and lays the groundwork for eliminating the rest in a release or two.
* | | | | | | | | | MAINT: add __array_priority__ special case to masked array binary opsNathaniel J. Smith2015-06-133-9/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ndarray special methods like __add__ have a special case where if the right argument is not an ndarray or subclass, and it has higher __array_priority__ than the left argument, then we return NotImplemented and let the right argument handle the operation. ufuncs have traditionally had a similar but different special case, where if it's a 2 input - 1 output ufunc, and the right argument is not an ndarray (exactly, subclasses don't count), and when converted to an ndarray ends up as an object array (presumably b/c it doesn't have a meaningful coercion route, though who knows), and it has a higher __array_priority__ than the left argument AND it has a __r<operation>__ attribute, then they return NotImplemented. In practice this latter special case is not used by regular ndarrays, b/c anytime it would need to be triggered, the former special case triggers first and the ufunc is never called. However, numpy.ma did not have the former special case, and was thus relying on the ufunc special case. This commit adds the special case to the numpy.ma special methods directly, so that they no longer depend on the quirky ufunc behaviour. It also cleans up the relevant test to things that actually should be true in general, instead of just testing some implementation details.
* | | | | | | | | | MAINT: move the special case for void comparison before the regular caseNathaniel J. Smith2015-06-134-31/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ndarray richcompare function has special case code for handling void dtypes (esp. structured dtypes), since there are no ufuncs for this. Previously, we would attempt to call the relevant ufunc (e.g. np.equal), and then when this failed (as signaled by the ufunc returning NotImplemented), we would fall back on the special case code. This commit moves the special case code to before the regular code, so that it no longer requires ufuncs to return NotImplemented. Technically, it is possible to define ufunc loops for void dtypes using PyUFunc_RegisterLoopForDescr, so technically I think this commit changes behaviour: if someone had registered a ufunc loop for one of these operations, then previously it might have been found and pre-empted the special case fallback code; now, we use the special-case code without even checking for any ufunc. But the only possible use of this functionality would have been if someone wanted to redefine what == or != meant for a particular structured dtype -- like, they decided that equality for 2-tuples of float32's should be different from the obvious thing. This does not seem like an important capability to preserve. There were also several cases here where on error, an array comparison would return a scalar instead of raising. This is supposedly deprecated, but there were call paths that did this that had no deprecation warning. I added those warnings.
* | | | | | | | | | MAINT: move the special case for string comparison before the regular caseNathaniel J. Smith2015-06-131-18/+19
| |/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ndarray richcompare function has a special case for handling string dtypes (which currently cannot be handled by ufuncs). Traditionally this was handled by the ufuncs returning NotImplemented, and then falling through to a special case. By moving the special case to the top of the richcompare function, it becomes unnecessary for the ufuncs to return NotImplemented in this case.
* | | | | | | | | Merge pull request #5963 from charris/rubustify-tuple-loop-searchseberg2015-06-132-20/+23
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | Rubustify tuple loop search
| * | | | | | | | | TST: Test that true_divide works for float inputs and dtype=np.float.Charles Harris2015-06-121-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was failing due to the check for matching loops not searching through all available loops, rather ending with int8 inputs and float output, which in turn would fail casting.
| * | | | | | | | | BUG: Make type_tuple_type_resolver more robust.Charles Harris2015-06-121-20/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a loop match fails on account of casting, continue searching the loops until success or all loops have been examined. The failure to do this was causing true_divide to fail with float inputs and dtype=float because the first loop found was (int8, int8, float64), leading to a casting error as float cannot be safely cast to int8. Versions of numpy previous to 1.10 will still fail silently if this is backported as the casting rules were less strict, so that would also need fixing. Closes #3484.
* | | | | | | | | | DOC: Fix typo in documentationamir2015-06-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ci skip]
* | | | | | | | | | Merge pull request #5947 from ahaldane/voidscalar_getsetfieldCharles Harris2015-06-113-75/+107
|\ \ \ \ \ \ \ \ \ \ | |_|_|/ / / / / / / |/| | | | | | | | | BUG: make void-scalar getfield/setfield use ndarray methods
| * | | | | | | | | BUG: make void-scalar getfield/setfield use ndarray methodsAllan Haldane2015-06-103-75/+107
| | |/ / / / / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit modifies voidtype_get/setfield to call ndarray's get/setfield, which does proper safety checks (for object arrays) and broadcasts properly. This solves bugs related to void-scalar assignment. Also changed the calling convention of voidtype_getfield. Previously it accepted a (dtype, offset, title) tuple and dropped title. Now it expects only (dtype, offset), just like ndarray's getfield. Fixes #3126. Fixes #3561.