BUG: gh-2790, fix column scaling in polynomial package least squares.

The columns should be scaled using their 2-norm, but in the complex case
that was being incorrectly computed as the square root of the sum of the
squared elements rather than as the square root of the  sum of their squared
real and imaginary parts.
TST: Add Test for column scaling in the polynomial package fits.

The test uses the complex set of sample points [1, 1j, -1, -1j] whose
squared sum is exactly zero. This would fail before the column scaling
was fixed.
MAINT: Use a better method to detect complex arrays.

Instead of

    if lhs.dtype.char in np.typecodes['Complex']:

use

    if issubclass(lhs.dtype.type, np.complexfloating):
DOC/FIX: fix example in ctypeslib module documentation

Fix some inconsistencies in the example. The library is loaded as '_lib' not
'lib' in the rest of the example. Also, the function is called 'foo_func' not
'foo'
Merge pull request #2960 from esc/doc/fix/ctypeslib

DOC/FIX: fix example in ctypeslib module documentation
Merge pull request #2947 from charris/fix-complex-polynomial-fit

Fix complex polynomial fit
DOC: update 1.7.0-notes.rst from release branch

There were some changes in the release branch that were not put into master.
After this commit, the file 1.7.0-notes.rst is synchronised with the release
branch.
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.
ENH: Use tp_basicsize, not NPY_SIZEOF_PYARRAYOBJECT, for memory allocation.

This change allows C-API level subtypes of PyArray_Type without forcing the
developer to rewrite the tp_alloc function and only change the amount of
memory allocated.
BUG: PyArray_LexSort allocates too much temporary memory.

PyArray_LexSort was allocating memory to hold actual PyArrayObject's
and PyArrayIterObject's, but only storing pointers to such objects
in the array.
Merge pull request #2976 from bfroehle/memory_waste

BUG: PyArray_LexSort allocates too much temporary memory.
Merge pull request #2975 from bfroehle/tp_alloc

ENH: Use tp_basicsize, not NPY_SIZEOF_PYARRAYOBJECT, for allocation
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