8000 Closes issue #586. Updates handling of nan behaviour in numpy.lib.function_base.median. by empeeu · Pull Request #4287 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Closes issue #586. Updates handling of nan behaviour in numpy.lib.function_base.median. #4287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a9eff96
ENH: added proper handling of nans for numpy.lib.function_base.median…
empeeu Feb 13, 2014
54aff25
ENH: added unit test for previous commit which updates median's handling
empeeu Feb 13, 2014
10902b5
ENH: #586. Improved performance of nan handling in median function.
empeeu Feb 17, 2014
8c2f007
DOC: Updated doc string for nanmedian.
empeeu Feb 17, 2014
d8e3957
REV: Reverting nanmedian from this PR. Now deals exclusively with han…
empeeu Feb 18, 2014
aa615ad
numpy.i bugfix: fortran ordering check
jspreston Feb 20, 2014
89d4d1e
ENH: #586 Pulls in juliantaylor's specialization. New median with nan…
empeeu Feb 26, 2014
ea89757
BUG: restore api for file npy_PyFile_Dup and npy_PyFile_DupClose
juliantaylor Mar 5, 2014
0bf8fec
Merge pull request #4334 from jspreston/patch-1
charris Mar 5, 2014
683bc33
Merge pull request #4450 from juliantaylor/api-restore
charris Mar 5, 2014
4b2b77e
Revert "Merge pull request #4421 from meltingwax/meltingwax/4382"
Mar 6, 2014
a6f9b78
Merge pull request #4451 from meltingwax/meltingwax/revert-4421
charris Mar 6, 2014
bf2a953
TST: work around outdated travis boxes
juliantaylor Mar 6, 2014
ea75479
DOC: Fixed documentation on lstsq function on when it return an empty…
cimarronm Mar 7, 2014
b099017
Merge pull request #4457 from cimarronm/linalg_lstsq_docfix
seberg Mar 7, 2014
0007cd6
Merge pull request #4456 from juliantaylor/travis-updates
juliantaylor Mar 7, 2014
4da29a8
Merge pull request #4459 from Sankarshan-Mudkavi/fix-gh-1367
juliantaylor Mar 7, 2014
c35542c
ENH: added proper handling of nans for numpy.lib.function_base.median…
empeeu Feb 13, 2014
210f534
ENH: added unit test for previous commit which updates median's handling
empeeu Feb 13, 2014
22eeef0
ENH: #586. Improved performance of nan handling in median function.
empeeu Feb 17, 2014
2d8f3ed
DOC: Updated doc string for nanmedian.
empeeu Feb 17, 2014
52ccb4e
REV: Reverting nanmedian from this PR. Now deals exclusively with han…
empeeu Feb 18, 2014
cbca46c
ENH: #586 Pulls in juliantaylor's specialization. New median with nan…
empeeu Feb 26, 2014
d76ed36
Merge branch 'master' of github.com:empeeu/numpy
empeeu Mar 8, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: Updated doc string for nanmedian.
  • Loading branch information
empeeu committed Mar 8, 2014
commit 2d8f3ed32a8e47bd7c8b3843bd1aad8da77c4a1a
42 changes: 17 additions & 25 deletions numpy/lib/nanfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,10 +673,6 @@ def nanmedian(a, axis=None, overwrite_input=False):
axis : int, optional
Axis along which the medians are computed. The default (axis=None)
is to compute the median along a flattened version of the array.
out : ndarray, optional
Alternative output array in which to place the result. It must
have the same shape and buffer length as the expected output,
but the type (of the output) will be cast if necessary.
overwrite_input : bool, optional
If True, then allow use of memory of input array (a) for
calculations. The input array will be modified by the call to
Expand All @@ -689,15 +685,14 @@ def nanmedian(a, axis=None, overwrite_input=False):
Returns
-------
median : ndarray
A new array holding the result (unless `out` is specified, in
which case that array is returned instead). If the input contains
integers, or floats of smaller precision than 64, then the output
data-type is float64. Otherwise, the output data-type is the same
as that of the input.
A new array holding the result. If the input contains integers, or
floats of smaller precision than 64, then the output data-type is
float64. Otherwise, the output data-type is the same as that of the
input.

See Also
--------
mean, percentile
mean, median, percentile

Notes
-----
Expand All @@ -708,29 +703,26 @@ def nanmedian(a, axis=None, overwrite_input=False):

Examples
--------
>>> a = np.array([[10, 7, 4], [3, 2, 1]])
>>> a = np.array([[10.0, 7, 4], [3, 2, 1]])
>>> a[0, 1] = np.nan
>>> a
array([[10, 7, 4],
[ 3, 2, 1]])
array([[ 10., nan, 4.],
[ 3., 2., 1.]])
>>> np.median(a)
3.5
>>> np.median(a, axis=0)
array([ 6.5, 4.5, 2.5])
nan
>>> np.nanmedian(a)
3.0
>>> np.nanmedian(a, axis=0)
array([ 6.5, 2., 2.5])
>>> np.median(a, axis=1)
array([ 7., 2.])
>>> m = np.median(a, axis=0)
>>> out = np.zeros_like(m)
>>> np.median(a, axis=0, out=m)
array([ 6.5, 4.5, 2.5])
>>> m
array([ 6.5, 4.5, 2.5])
>>> b = a.copy()
>>> np.median(b, axis=1, overwrite_input=True)
>>> np.nanmedian(b, axis=1, overwrite_input=True)
array([ 7., 2.])
>>> assert not np.all(a==b)
>>> b = a.copy()
>>> np.median(b, axis=None, overwrite_input=True)
3.5
>>> np.nanmedian(b, axis=None, overwrite_input=True)
3.0
>>> assert not np.all(a==b)

"""
Expand Down
0