STY: slight PEP8 fixups for numpy/compat.

Rebased for backport to 1.9.x if needed. Also opened #4933 for a bug found in the process.