GitHub PullRequestReviewCommentEvent at 2014-05-02 12:16:02
Repository: numpy
Actor: juliantaylor
Payload: {"comment":{"url":"https://api.github.com/repos/numpy/numpy/pulls/comments/12226711","id":12226711,"diff_hunk":"@@ -601,6 +603,194 @@ def nanmean(a, axis=None, dtype=None, out=None, keepdims=False):\n     return avg\n \n \n+def _nanmedian1d(arr1d, overwrite_input=False): # This only works on 1d arrays\n+    \"\"\"Private function for rank 1 arrays. Compute the median ignoring NaNs.\n+\n+    Parameters\n+    ----------\n+    arr1d : ndarray\n+        Input array, of rank 1.\n+    overwrite_input : bool, optional\n+       If True, then allow use of memory of input array (a) for\n+       calculations. The input array will be modified by the call to\n+       median. This will save memory when you do not need to preserve\n+       the contents of the input array. Treat the input as undefined,\n+       but it will probably be fully or partially sorted. Default is\n+       False. Note that, if `overwrite_input` is True and the input\n+       is not already an ndarray, an error will be raised.\n+       \n+    Results\n+    -------\n+    m : float\n+        The median.\n+    \"\"\"\n+    c = np.isnan(arr1d)\n+    s = np.where(c)[0]\n+    if s.size == arr1d.size:\n+        warnings.warn(\"All-NaN slice encountered\", RuntimeWarning)\n+        return np.nan\n+    elif s.size == 0:\n+        return np.median(arr1d, overwrite_input=overwrite_input)\n+    else:\n+        if overwrite_input: \n+            x = arr1d\n+        else: \n+            x = arr1d.copy() \n+        # select non-nans at end of array\n+        enonan = arr1d[-s.size:][~c[-s.size:]]\n+        # fill nans in beginning of array with non-nans of end\n+        x[s[:enonan.size]] = enonan\n+        # slice nans away\n+        return np.median(x[:-s.size], overwrite_input=True)\n+\n+\n+def _nanmedian(a, axis=None, out=None, overwrite_input=False):\n+    \"\"\"\n+    Private function that doesn't support extended axis or keepdims.\n+    These methods are extended to this function using _ureduce\n+\n+    Compute the median along the specified axis, while ignoring NaNs.\n+\n+    Returns the median of the array elements.\n+\n+    Parameters","path":"numpy/lib/nanfunctions.py","position":71,"original_position":71,"commit_id":"6b8494044c259c69986da0738862716c1f1a1300","original_commit_id":"6b8494044c259c69986da0738862716c1f1a1300","user":{"login":"juliantaylor","id":542663,"avatar_url":"https://avatars.githubusercontent.com/u/542663?","gravatar_id":"bfe1a4e8db228cb9b7c023c8928ac0e2","url":"https://api.github.com/users/juliantaylor","html_url":"https://github.com/juliantaylor","followers_url":"https://api.github.com/users/juliantaylor/followers","following_url":"https://api.github.com/users/juliantaylor/following{/other_user}","gists_url":"https://api.github.com/users/juliantaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/juliantaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juliantaylor/subscriptions","organizations_url":"https://api.github.com/users/juliantaylor/orgs","repos_url":"https://api.github.com/users/juliantaylor/repos","events_url":"https://api.github.com/users/juliantaylor/events{/privacy}","received_events_url":"https://api.github.com/users/juliantaylor/received_events","type":"User","site_admin":false},"body":"same here","created_at":"2014-05-02T12:16:02Z","updated_at":"2014-05-02T12:16:02Z","html_url":"https://github.com/numpy/numpy/pull/4307#discussion_r12226711","pull_request_url":"https://api.github.com/repos/numpy/numpy/pulls/4307","_links":{"self":{"href":"https://api.github.com/repos/numpy/numpy/pulls/comments/12226711"},"html":{"href":"https://github.com/numpy/numpy/pull/4307#discussion_r12226711"},"pull_request":{"href":"https://api.github.com/repos/numpy/numpy/pulls/4307"}}}}