summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4358 from seberg/fast-selectCharles Harris2014-03-241-26/+64
|\ | | | | ENH: Speed improvements and deprecations for np.select
| * ENH: Speed improvements and deprecations for np.selectSebastian Berg2014-03-231-26/+64
| | | | | | | | | | | | | | | | | | The idea for this (and some of the code) originally comes from Graeme B Bell (gh-3537). Choose is not as fast and pretty limited, so an iterative copyto is used instead. Closes gh-3259, gh-3537, gh-3551, and gh-3254
* | MAINT: revert back to separate median implementationJulian Taylor2014-03-131-66/+112
| | | | | | | | | | | | Merging median and percentile make would break astropy and quantities as we don't call mean anymore. These packages rely on overriding mean to add their own median behavior.
* | ENH: add extended axis and keepdims support to median and percentileJulian Taylor2014-03-131-52/+113
| |
* | remove assert in _get_ufunc_and_otypes, add a test in test_function_base.pyLeoMao2014-03-121-3/+3
| |
* | when initialize a vectorize object, always set self._ufunc to None first. ↵LeoMao2014-03-111-2/+1
|/ | | | fix #3285
* Merge pull request #4372 from charris/fix-gh-2423Charles Harris2014-03-011-88/+95
|\ | | | | DOC: Fix documentation of normed keyword in histogram2d and histogramdd.
| * DOC: Fix documentation of normed in histogram2d and histogramdd.Charles Harris2014-02-261-88/+95
| | | | | | | | | | | | | | | | | | | | The documentation misrepresented what happened, leaving out division by the total number of sample points. Also run spellcheck over function_base.py and twodim_base.py and break some long lines. Closes #2423.
* | Merge pull request #4284 from robquant/histogramdd_rightmost_binedgeJulian Taylor2014-03-011-3/+3
|\ \ | | | | | | Closes issue #4266, fixes histogramdd treatment of events at rightmost binedge
| * | Fix histogramdd treatment of events at rightmost binedgeRobert Franke2014-02-121-3/+3
| |/ | | | | | | Fixes Github issue #4266
* | BUG: accept non arrays in cor and corrcoeffJulian Taylor2014-02-271-0/+2
|/ | | | closes gh-4295
* ENH: Allow meshgrid to work for 1D and 0D cases.rhewett2013-12-181-11/+11
|
* Correct typo in interp() docstring.Christopher Dembia2013-12-061-1/+1
| | | The docstring for interp() contained the grammatically-incorrect text "defaults is". I corrected this to "default is".
* BUG: Fix np.insert with negative axis.Sebastian Berg2013-12-021-1/+1
| | | | | | | | In some cases a negative axis argument to np.insert would result in wrong behaviour due to np.rollaxis, add modulo operation to avoid this (an error is still raised due to arr.shape[axis]). Closes gh-3494
* ENH: improve add_newdocs performanceJulian Taylor2013-11-191-5/+4
| | | | | replace slow exec with a direct __import__. improves `import numpy` speed by about 10%.
* BUG: cov/corrcoef complex input and empty arraysJoseph Martinot-Lagarde2013-10-161-22/+24
| | | | | | | | | | | | | | | | | This preserves the complex (and higher precision float or object) type of the input array, so that the complex covariance and correlation coefficients can be calculated. It also fixes the the behaviour of empty arrays. These will now either result in a 0x0 result, or a NxN result filled with NaNs. A warning is now issued when ddof is too large and the factor set to 0 so that in this case the result is always NaN or infinity/negative infinity and never a negative number. Closes gh-597 and gh-2680 Closes gh-3882 (original pull request)
* BUG: ensure percentile has same output structure as in 1.8Julian Taylor2013-10-041-21/+48
| | | | | | percentile returned scalars and lists of arrays in 1.8 adapt new percentile to return scalar and arrays with q dimension first for compatibility.
* BUG: preserve ndarray subclasses in medianJulian Taylor2013-10-021-1/+1
| | | | closes gh-3846
* STY: error and warning formatting on 'function_base.py'Yaron de Leeuw2013-09-241-18/+25
|
* STY: Error and warning newline standardization in function_base.pyYaron de Leeuw2013-09-241-130/+158
| | | | | Continueing the pep8 effort, adds newline afer each `Error(` and tries to wrap correctly.
* STY: make function_base.py pep8 compatibleYaron de Leeuw2013-09-221-175/+204
| | | | | | This makes function_base.py almost pep8 compatible. ALSO, removes the Set import which is unneeded since python 2.4, and organises the import statements.
* TST: note on overwrite_input parameter in percentileJonathan Helmus2013-09-161-2/+3
| | | | | | | * added note that `overwrite_input` has not effect when `a` is not an array in the percentile function. * added unit test to verify that no error is raised when `a` is not an array and `overwrite_input` is True.
* MAINT: changed 'closest' interpolation to 'nearest'Jonathan Helmus2013-09-161-4/+4
|
* DOC: changes to scoreatpercentile docstring, doc test now passesJonathan Helmus2013-09-131-18/+20
|
* MAINT: cleaning up percentile function.Jonathan Helmus2013-09-131-13/+11
|
* ENH: percentile function with additional parameters and vecorizationJonathan Helmus2013-09-131-66/+90
| | | | | | | The percentile function was enhanced by adding limit and interpolation parameters to give it similar functionality to SciPy's stats.scoreatpercentile function. In addition the function was vecorized along q and rewritten to use the partition method for better performance.
* ENH: Improve accuracy of numpy.gradient at edgesdanieljfarrell2013-09-071-23/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * numpy.gradient has been enhanced to use a second order accurate one-sided finite difference stencil at boundary elements of the array. Second order accurate central difference are still used for the interior elements. The result is a fully second order accurate approximation of the gradient over the full domain. * The one-sided stencil uses 3 elements each with a different weight. A forward difference is used for the first element, dy/dx ~ -(3.0*y[0] - 4.0*y[1] + y[2]) / (2.0*dx) and backwards difference is used for the last element, dy/dx ~ (3.0*y[-1] - 4.0*y[-2] + y[-3]) / (2.0*dx) * Because the datetime64 datatype cannot be multiplied a view is taken of datetime64 arrays and cast to int64. The gradient algorithm is then applied to the view rather than the input array. * Previously no dimension checks were performed on the input array. Now if the array size along the differentiation axis is less than 2, a ValueError is raised which explains that more elements are needed. If the size is exactly two the function falls back to using a 2 point stencil (the old behaviour). If the size is 3 and above then the higher accuracy methods are used. * A new test has been added which validates the higher accuracy. Old tests have been updated to pass. Note, this should be expected because the boundary elements now return different (more accurate) values.
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-26/+26
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* BUG: fix np.median so it accepts array_like input. Clean up median tests.Ralf Gommers2013-08-171-0/+1
|
* MAINT: Separate nan functions into their own module.Charles Harris2013-08-121-334/+8
| | | | | | | | | | | | | | New files lib/nanfunctions.py and lib/tests/test_nanfunctions.py are added and both the previous and new nan functions and tests are moved into them. The existing nan functions moved from lib/function_base are: nansum, nanmin, nanmax, nanargmin, nanargmax The added nan functions moved from core/numeric are: nanmean, nanvar, nanstd
* ENH: implement median in terms of partitionJulian Taylor2013-08-121-12/+32
| | | | | | Partitioning is sufficient to obtain the median and is much faster. In the case of overwrite_input=True the resulting array will not be fully sorted anymore.
* BUG: Make np.insert check for out of bounds axis arguments.Félix Hartmann2013-08-021-1/+6
| | | | Also add test for IndexError exception when axis is out of bounds.
* BUG: Fix bug in np.insert when axis=-1Félix Hartmann2013-08-021-1/+1
|
* Link cumsum and diff to one another as theyre roughly the inverse of each otherNils Werner2013-07-241-1/+1
|
* 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
|
* MAINT: Apply 2to3 idioms fixer.Charles Harris2013-05-021-2/+1
| | | | | | | | | | | | | | | | | | | 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-271-1/+2
|\ | | | | BUG: np.insert must copy index array
| * BUG: np.insert must copy index arraySebastian Berg2013-04-271-1/+2
| | | | | | | | Otherwise it would do in-place changes to it. Fixes gh-3279.
* | 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-0/+1
|/ | | | | | | | | | | | | | | | | | | 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.
* 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-111-9/+23
|
* 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-111-53/+147
| | | | | | | | | | | | | | | | | | 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.
* 2to3: Apply `print` fixer.Charles Harris2013-04-061-1/+1
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* Merge pull request #460 from endolith/regex_formattingCharles Harris2013-04-031-1/+1
|\ | | | | DOC: Formatting fixes using regex
| * DOC: Used regex to find colons missing spaces which render wrong online, ↵endolith2013-03-191-1/+1
| | | | | | | | also other spacing or formatting mistakes
* | 2to3: Use absolute imports.Charles Harris2013-03-281-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-271-2/+2
|/ | | | | | | | | | | | | | | 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
* 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-011-0/+2
| | | | | | | | 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.