BUG: Fix dtypes in sorting functions to npy_intp

Some of the iteration variables were int, causing sorts to fail for large
arrays. Fixes github issue 427.
BUG: Fix reporting of memory error inside sorting

PyDataMem_NEW was not checked for error and the occurance of
errors not returned correctly in new_sort. Also for PyArray_LexSort
and new_argsort it should now raise MemoryError correctly.
This is done by setting PyErr_NoMemory() when no error is already
present, as the low level sorting can only fail for this reason.
BUG: Make nansum work with booleans.

This broke when function_base._nannop tried to fill a boolean array with
integer zeros, raising a 'safe_casting' error. It looks like nanargmax and
nanargmin would also break, and were probably incorrect for booleans in any
case. The fix is not to use fill values for boolean and integer dtypes.
Previously that was only done for the integer dtypes.
Merge pull request #2979 from charris/fix-nansum

BUG: Make nansum work with booleans.
Merge pull request #2974 from seberg/issue-427

Fix some large array sorts and memory error handling
DOC: update bento docs (close #2993).
Update numpy/lib/function_base.py

fix percentile docstring
Merge pull request #2996 from andreas-h/patch-1

Update numpy/lib/function_base.py
BUG: Fix regression of bad error/random behavior in item method

Appearently .item() for arrays with size != 1 correctly returned an error
in 1.6., but failed to raise the error (due to missing return) in 1.7.
Merge pull request #3006 from seberg/fix-empty-item

BUG: Fix regression of bad error/random behavior in item method
Added 'subok' keyword documentation to zeros_like and ones_like
functions.
Merge pull request #3009 from daveydave400/fix_zeros_like_doc

Added 'subok' keyword documentation to zeros_like and ones_like functions.
BUG: Incref items in np.take on error as they are decrefed later

When take fails during copying due to out of bound indices, then the already
copied items will be decref'd on array destruction. To avoid that, as well
as possible overlapping or already initialized object arrays, decref and
incref during the copy operation itself. Note that all basic types but
object use their own fasttake, so this does not change anything for them.
TST: Add test for np.take refcounting

Also make the testcase for take a class.
BUG: non-empty takes on empty axes failed for clip/wrap logic

These did no checking for this special case. And thus, wrap would go
into infinite loops trying to adjust the index, and clip would (probably)
segfault. This raises IndexError explicitely beforehand.
Merge pull request #3002 from seberg/issue-3001

BUG: Incref items in np.take on error as they are decrefed later