numpy/numpy — pull request #5361 by JDWarner (2014-12-10 00:43:46+00:00)
Title: ENH: Improve arg handling & enhance test suite for `np.pad`

This PR supersedes #4113, including changes from @ahojnnes and further improvements. Briefly, this consists of major increases to test coverage and enhancing the ability to properly accept and interpret floats or ndarrays as either `pad_width`, `constant_values`, or `end_values`.

Specifically:
* Argument handling is improved.
* All elements of `pad_width` are now checked to ensure they are integers, otherwise an informative error is raised
* The complicated logic in the previous hidden function `_normalize_shape` has been replaced.
* New version operates internally on NumPy arrays instead of attempting to do type and shape checking on nested iterables.
* Overall structure easier to follow, IMO, and comments added for maintainability.
* Import of `numbers` and `long` from `np.compat` no longer required!
* Test suite greatly improved.
* Coverage is 100% save one branch miss
* `mode='symmetric'` was somehow not covered at all previously (!)
* Various shortcuts for speed or edge cases in logic pathways are now all covered
* Removed a few nonfunctional lines from the final `'reflect'` loop - artifacts *someone* forgot to take out after developing this thing...
* PEP8 fixes
* A few docstring clarifications in hidden functions.

The concern raised by @charris in #4113 has been addressed, and tests added to ensure this behavior is maintained. The dtype of the array *to be padded* is maintained.