summaryrefslogtreecommitdiff
path: root/numpy/lib/function_base.py
Commit message (Collapse)AuthorAgeFilesLines
...
* | DOC : do not abuse enumeration for return typesThomas A Caswell2014-12-121-4/+4
|/ | | | | change '{ndarray, float}' -> 'ndarray or float' as {} are for when the value is an enumeration
* Merge pull request #5214 from mkowoods/np.averageJulian Taylor2014-10-271-3/+2
|\ | | | | | | Update to average calculation
| * BUG: upcast weights to average result type to avoid inaccuraciesMalik Woods2014-10-271-3/+2
| | | | | | | | closes gh-5202
* | Merge pull request #5203 from njsmith/masterCharles Harris2014-10-211-1/+2
|\ \ | | | | | | BUG: copy inherited masks in MaskedArray.__array_finalize__
| * | BUG: copy inherited masks in MaskedArray.__array_finalize__Nathaniel J. Smith2014-10-211-1/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, operations which created a new masked array from an old masked array -- e.g., np.empty_like -- would tend to result in the new and old arrays sharing the same .mask attribute. This leads to horrible brokenness in which writes to one array affect the other. In particular this was responsible for part of the brokenness that @jenshnielsen reported in gh-5184 in which np.gradient on masked arrays would modify the original array's mask. This fixes the worst part of the issues addressed in gh-3404, though there's still an argument that we ought to deprecate the mask-copying behaviour entirely so that empty_like returns an array with an empty mask. That can wait until we find someone who cares though. I also applied a small speedup to np.gradient (avoiding one copy); previously this inefficiency was masking (heh) some of the problems with masked arrays, so removing it is both an optimization and makes it easier to test that things are working now.
* | Merge branch 'master' of https://github.com/numpy/numpy into interp_with_periodsaullogiovani2014-10-171-19/+30
|\ \
| * | BUG: Fixes #5184 gradient calculation behavior at boundariesDavid M Fobes2014-10-161-19/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Previous expected behavior was that the gradient is computed using central differences in the interior and first differences at the boundaries. * gradient was updated in v1.9.0 so that second-order accurate calculations are done at the boundaries, but this breaks expected behavior with old code, so `edge_order` keyword (Default: 1) is added to specify whether first or second order calculations at the boundaries should be used. * Since the second argument is *varargs, in order to maintain compatibility with old code and compatibility with python 2.6 & 2.7, **kwargs is used, and all kwargs that are not `edge_order` raise an error, listing the offending kwargs. * Tests and documentation updated to reflect this change. * Added `.. versionadded:: 1.9.1` to the new optional kwarg `edge_order` documentation, and specified supported `edge_order` kwarg values. * Clarified documentation for `varargs`. * Made indentation in docstring consistent with other docstring styles. * Examples corrected
* | | ENH: added parameter to use periodic x-coordinatessaullogiovani2014-10-021-8/+55
|/ /
* | DOC: update numpy.extract docstringGregory R. Lee2014-09-151-1/+3
| |
* | fix typoGabriel-p2014-09-071-1/+1
| |
* | Merge pull request #5022 from seberg/structured-insertCharles Harris2014-08-301-1/+3
|\ \ | | | | | | BUG: Fix np.insert for inserting a single item into a structured array
| * | BUG: Fix np.insert for inserting a single item into a structured arraySebastian Berg2014-08-301-1/+3
| | | | | | | | | | | | | | | Note that there are some object array special cases because of allowing multiple inserts. `np.array(..., dtype=object)` is not always clear.
* | | Merge pull request #4989 from juliantaylor/percentile-fixCharles Harris2014-08-241-1/+1
|\ \ \ | |/ / | | | BUG: don't overwrite input percentile arrays
| * | BUG: don't overwrite input percentile arraysJulian Taylor2014-08-241-1/+1
| |/
* | Merge pull request #4929 from juliantaylor/charris-pep8-numpy-libCharles Harris2014-07-311-19/+22
|\ \ | |/ | | Charris pep8 numpy lib
| * STY: Make files in numpy/lib PEP8 compliant.Charles Harris2014-07-311-5/+7
| | | | | | | | The rules enforced are the same as those used for scipy.
| * MAINT: Fixes for problems in numpy/lib revealed by pyflakes.Charles Harris2014-07-311-14/+15
| | | | | | | | | | | | Some of those problems look like potential coding errors. In those cases a Fixme comment was made and the offending code, usually an unused variable, was commented out.
* | BUG: handle rounding issue with histogram edges on float32 dataJulian Taylor2014-06-231-2/+7
|/ | | | | | | | | | | | Following inequality causes wrong counting at the edges and can be avoided by making the edge array of the same type as the input data. In [1]: np.around(np.float64(6010.36962890625), 5) Out[1]: 6010.3696300000001 In [2]: np.around(np.float32(6010.36962890625), 5) Out[2]: 6010.3701 Closes gh-4799
* BUG: Fixed piecewise function for 0d inputJuan Luis Cano Rodríguez2014-06-081-20/+12
| | | | | | | | | | When `x` has more than one element the condlist `[True, False]` is being made equivalent to `[[True, False]]`, which is correct. However, when `x` is zero dimensional the expected condlist is `[[True], [False]]`: this commit addresses the issue. Besides, the documentation stated that there could be undefined values but actually these are 0 by default: using `nan` would be desirable, but for the moment the docs were corrected. Closes #331.
* DOC: Fix indentation and add missing blank lines for meshgrid doc.Charles Harris2014-06-021-4/+7
|
* DOC: add versionadded tags to meshgrid argumentsJulian Taylor2014-06-021-0/+3
| | | | [ci skip]
* MAINT: Removed code emulating keepdims in covDavid Freese2014-05-301-4/+2
|
* BUG: Don't let meshgrid ignore unknown kwargs. Fixes #4755.Michael McNeil Forbes2014-05-301-3/+7
|
* 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.