Repository: scikit-image/scikit-image

Issue:
Docstring in util.pad returns <no docstring>
## Description

`util.pad()` returns an empty docstring; however, [the docstring is there](https://github.com/scikit-image/scikit-image/blob/v0.12.2/skimage/util/arraypad.py#L1117).
Any idea on what's happening? Thanks y'all!

## Way to reproduce
```python
In [1]: from skimage import util                                                                                                    

In [2]: util.pad?                                                                                                                   
Signature: util.pad(*args, **kwargs)
Docstring: <no docstring>
File:      ~/<__array_function__ internals>
Type:      function
```


## Version information
```python
# Paste the output of the following python commands
>>> from __future__ import print_function

>>> import sys; print(sys.version)
3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0]

>>> import platform; print(platform.platform())
Linux-5.3.0-20-generic-x86_64-with-debian-buster-sid

>>> import skimage; print("scikit-image version: {}".format(skimage.__version__))
scikit-image version: 0.16.2

>>> import numpy; print("numpy version: {}".format(numpy.__version__))
numpy version: 1.17.3
```


Discussion:
@alexdesiqueira your link points to the v0.12.2 tag for some reason! 😂 

If you look at the latest master, pad is a wrapper around `numpy.pad`. It looks like we are doing a poor job wrapping it:

https://github.com/scikit-image/scikit-image/blob/d289b45299f44d85d4299f3f7c3ef803bcee344e/skimage/util/__init__.py#L15-L18
> @alexdesiqueira your link points to the v0.12.2 tag for some reason! joy

:joy: go figure...
Maybe `copy_func` has something wrong? I'll check it out.

xref #4147

Resolving patch:
diff --git a/skimage/_shared/utils.py b/skimage/_shared/utils.py
--- a/skimage/_shared/utils.py
+++ b/skimage/_shared/utils.py
@@ -2,7 +2,6 @@
 import functools
 import sys
 import numpy as np
-import types
 import numbers
 
 from ..util import img_as_float
@@ -183,21 +182,6 @@ def check_nD(array, ndim, arg_name='image'):
         raise ValueError(msg_incorrect_dim % (arg_name, '-or-'.join([str(n) for n in ndim])))
 
 
-def copy_func(f, name=None):
-    """Create a copy of a function.
-
-    Parameters
-    ----------
-    f : function
-        Function to copy.
-    name : str, optional
-        Name of new function.
-
-    """
-    return types.FunctionType(f.__code__, f.__globals__, name or f.__name__,
-                              f.__defaults__, f.__closure__)
-
-
 def check_random_state(seed):
     """Turn seed into a `np.random.RandomState` instance.
 
diff --git a/skimage/util/__init__.py b/skimage/util/__init__.py
--- a/skimage/util/__init__.py
+++ b/skimage/util/__init__.py
@@ -1,3 +1,6 @@
+import functools
+import warnings
+import numpy as np
 from .dtype import (img_as_float32, img_as_float64, img_as_float,
                     img_as_int, img_as_uint, img_as_ubyte,
                     img_as_bool, dtype_limits)
@@ -12,10 +15,13 @@
 from ._invert import invert
 from ._montage import montage
 
-from .._shared.utils import copy_func
 
-from numpy import pad as numpy_pad
-pad = copy_func(numpy_pad, name='pad')
+@functools.wraps(np.pad)
+def pad(*args, **kwargs):
+    warnings.warn("skimage.util.pad is deprecated and will be removed in "
+                  "version 0.19. Please use numpy.pad instead.",
+                  FutureWarning, stacklevel=2)
+    return np.pad(*args, **kwargs)
 
 
 __all__ = ['img_as_float32',


Test patch:
diff --git a/skimage/_shared/tests/test_utils.py b/skimage/_shared/tests/test_utils.py
--- a/skimage/_shared/tests/test_utils.py
+++ b/skimage/_shared/tests/test_utils.py
@@ -1,4 +1,4 @@
-from skimage._shared.utils import (copy_func, check_nD)
+from skimage._shared.utils import check_nD
 import numpy.testing as npt
 import numpy as np
 from skimage._shared import testing
@@ -11,20 +11,5 @@ def test_check_nD():
         check_nD(x, 2)
 
 
-def test_copyfunc():
-    def foo(a):
-        return a
-
-    bar = copy_func(foo, name='bar')
-    other = copy_func(foo)
-
-    npt.assert_equal(bar.__name__, 'bar')
-    npt.assert_equal(other.__name__, 'foo')
-
-    other.__name__ = 'other'
-
-    npt.assert_equal(foo.__name__, 'foo')
-
-
 if __name__ == "__main__":
     npt.run_module_suite()
diff --git a/skimage/feature/tests/test_blob.py b/skimage/feature/tests/test_blob.py
--- a/skimage/feature/tests/test_blob.py
+++ b/skimage/feature/tests/test_blob.py
@@ -3,7 +3,6 @@
 from skimage.draw.draw3d import ellipsoid
 from skimage.feature import blob_dog, blob_log, blob_doh
 from skimage.feature.blob import _blob_overlap
-from skimage import util
 import math
 from numpy.testing import assert_almost_equal
 
@@ -49,7 +48,7 @@ def test_blob_dog():
     r = 10
     pad = 10
     im3 = ellipsoid(r, r, r)
-    im3 = util.pad(im3, pad, mode='constant')
+    im3 = np.pad(im3, pad, mode='constant')
 
     blobs = blob_dog(im3, min_sigma=3, max_sigma=10,
                           sigma_ratio=1.2, threshold=0.1)
@@ -65,7 +64,7 @@ def test_blob_dog():
     r = 10
     pad = 10
     im3 = ellipsoid(r / 2, r, r)
-    im3 = util.pad(im3, pad, mode='constant')
+    im3 = np.pad(im3, pad, mode='constant')
 
     blobs = blob_dog(
         im3,
@@ -197,7 +196,7 @@ def test_blob_log_3d():
     r = 6
     pad = 10
     im3 = ellipsoid(r, r, r)
-    im3 = util.pad(im3, pad, mode='constant')
+    im3 = np.pad(im3, pad, mode='constant')
 
     blobs = blob_log(im3, min_sigma=3, max_sigma=10)
     b = blobs[0]
@@ -214,7 +213,7 @@ def test_blob_log_3d_anisotropic():
     r = 6
     pad = 10
     im3 = ellipsoid(r / 2, r, r)
-    im3 = util.pad(im3, pad, mode='constant')
+    im3 = np.pad(im3, pad, mode='constant')
 
     blobs = blob_log(
         im3,
@@ -382,11 +381,11 @@ def test_blob_log_overlap_3d():
     r1, r2 = 7, 6
     pad1, pad2 = 11, 12
     blob1 = ellipsoid(r1, r1, r1)
-    blob1 = util.pad(blob1, pad1, mode='constant')
+    blob1 = np.pad(blob1, pad1, mode='constant')
     blob2 = ellipsoid(r2, r2, r2)
-    blob2 = util.pad(blob2, [(pad2, pad2), (pad2 - 9, pad2 + 9),
-                                           (pad2, pad2)],
-                            mode='constant')
+    blob2 = np.pad(blob2, [(pad2, pad2), (pad2 - 9, pad2 + 9),
+                           (pad2, pad2)],
+                   mode='constant')
     im3 = np.logical_or(blob1, blob2)
 
     blobs = blob_log(im3,  min_sigma=2, max_sigma=10, overlap=0.1)
@@ -422,11 +421,11 @@ def test_blob_log_overlap_3d_anisotropic():
     r1, r2 = 7, 6
     pad1, pad2 = 11, 12
     blob1 = ellipsoid(r1, r1, r1)
-    blob1 = util.pad(blob1, pad1, mode='constant')
+    blob1 = np.pad(blob1, pad1, mode='constant')
     blob2 = ellipsoid(r2, r2, r2)
-    blob2 = util.pad(blob2, [(pad2, pad2), (pad2 - 9, pad2 + 9),
-                             (pad2, pad2)],
-                     mode='constant')
+    blob2 = np.pad(blob2, [(pad2, pad2), (pad2 - 9, pad2 + 9),
+                           (pad2, pad2)],
+                   mode='constant')
     im3 = np.logical_or(blob1, blob2)
 
     blobs = blob_log(im3, min_sigma=[2, 2.01, 2.005],
@@ -439,6 +438,7 @@ def test_blob_log_overlap_3d_anisotropic():
     assert_almost_equal(overlap,
                         1./math.pi * (2 * math.acos(1./2) - math.sqrt(3)/2.))
 
+
 def test_no_blob():
     im = np.zeros((10, 10))
     blobs = blob_log(im,  min_sigma=2, max_sigma=5, num_sigma=4)
diff --git a/skimage/util/tests/test_arraypad.py b/skimage/util/tests/test_arraypad.py
--- a/skimage/util/tests/test_arraypad.py
+++ b/skimage/util/tests/test_arraypad.py
@@ -1,6 +1,7 @@
 from distutils.version import LooseVersion
 
 import numpy as np
+import pytest
 # note: skimage.util.pad is just numpy.pad
 from skimage.util import pad
 
@@ -9,6 +10,11 @@
                                      TestCase)
 
 
+def test_deprecation():
+    with pytest.warns(FutureWarning):
+        pad(np.ones((5, 5)), 2, mode='constant')
+
+
 class TestConditionalShortcuts(TestCase):
     def test_zero_padding_shortcuts(self):
         test = np.arange(120).reshape(4, 5, 6)
@@ -25,7 +31,7 @@ def test_zero_padding_shortcuts(self):
                  'wrap',
                  ]
         for mode in modes:
-            assert_array_equal(test, pad(test, pad_amt, mode=mode))
+            assert_array_equal(test, np.pad(test, pad_amt, mode=mode))
 
     def test_shallow_statistic_range(self):
         test = np.arange(120).reshape(4, 5, 6)
@@ -36,8 +42,8 @@ def test_shallow_statistic_range(self):
                  'minimum',
                  ]
         for mode in modes:
-            assert_array_equal(pad(test, pad_amt, mode='edge'),
-                               pad(test, pad_amt, mode=mode, stat_length=1))
+            assert_array_equal(np.pad(test, pad_amt, mode='edge'),
+                               np.pad(test, pad_amt, mode=mode, stat_length=1))
 
     def test_clip_statistic_range(self):
         test = np.arange(30).reshape(5, 6)
@@ -48,14 +54,14 @@ def test_clip_statistic_range(self):
                  'minimum',
                  ]
         for mode in modes:
-            assert_array_equal(pad(test, pad_amt, mode=mode),
-                               pad(test, pad_amt, mode=mode, stat_length=30))
+            assert_array_equal(np.pad(test, pad_amt, mode=mode),
+                               np.pad(test, pad_amt, mode=mode, stat_length=30))
 
 
 class TestStatistic(TestCase):
     def test_check_mean_stat_length(self):
         a = np.arange(100).astype('f')
-        a = pad(a, ((25, 20), ), 'mean', stat_length=((2, 3), ))
+        a = np.pad(a, ((25, 20), ), 'mean', stat_length=((2, 3), ))
         b = np.array(
             [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
              0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
@@ -79,7 +85,7 @@ def test_check_mean_stat_length(self):
 
     def test_check_maximum_1(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'maximum')
+        a = np.pad(a, (25, 20), 'maximum')
         b = np.array(
             [99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
              99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
@@ -103,7 +109,7 @@ def test_check_maximum_1(self):
 
     def test_check_maximum_2(self):
         a = np.arange(100) + 1
-        a = pad(a, (25, 20), 'maximum')
+        a = np.pad(a, (25, 20), 'maximum')
         b = np.array(
             [100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
              100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
@@ -127,7 +133,7 @@ def test_check_maximum_2(self):
 
     def test_check_maximum_stat_length(self):
         a = np.arange(100) + 1
-        a = pad(a, (25, 20), 'maximum', stat_length=10)
+        a = np.pad(a, (25, 20), 'maximum', stat_length=10)
         b = np.array(
             [10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
              10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
@@ -151,7 +157,7 @@ def test_check_maximum_stat_length(self):
 
     def test_check_minimum_1(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'minimum')
+        a = np.pad(a, (25, 20), 'minimum')
         b = np.array(
             [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
              0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -175,7 +181,7 @@ def test_check_minimum_1(self):
 
     def test_check_minimum_2(self):
         a = np.arange(100) + 2
-        a = pad(a, (25, 20), 'minimum')
+        a = np.pad(a, (25, 20), 'minimum')
         b = np.array(
             [2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
              2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -199,7 +205,7 @@ def test_check_minimum_2(self):
 
     def test_check_minimum_stat_length(self):
         a = np.arange(100) + 1
-        a = pad(a, (25, 20), 'minimum', stat_length=10)
+        a = np.pad(a, (25, 20), 'minimum', stat_length=10)
         b = np.array(
             [ 1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
               1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
@@ -223,7 +229,7 @@ def test_check_minimum_stat_length(self):
 
     def test_check_median(self):
         a = np.arange(100).astype('f')
-        a = pad(a, (25, 20), 'median')
+        a = np.pad(a, (25, 20), 'median')
         b = np.array(
             [49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5,
              49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5,
@@ -247,7 +253,7 @@ def test_check_median(self):
 
     def test_check_median_01(self):
         a = np.array([[3, 1, 4], [4, 5, 9], [9, 8, 2]])
-        a = pad(a, 1, 'median')
+        a = np.pad(a, 1, 'median')
         b = np.array(
             [[4, 4, 5, 4, 4],
 
@@ -261,7 +267,7 @@ def test_check_median_01(self):
 
     def test_check_median_02(self):
         a = np.array([[3, 1, 4], [4, 5, 9], [9, 8, 2]])
-        a = pad(a.T, 1, 'median').T
+        a = np.pad(a.T, 1, 'median').T
         b = np.array(
             [[5, 4, 5, 4, 5],
 
@@ -277,7 +283,7 @@ def test_check_median_stat_length(self):
         a = np.arange(100).astype('f')
         a[1] = 2.
         a[97] = 96.
-        a = pad(a, (25, 20), 'median', stat_length=(3, 5))
+        a = np.pad(a, (25, 20), 'median', stat_length=(3, 5))
         b = np.array(
             [ 2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,
               2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,  2.,
@@ -301,7 +307,7 @@ def test_check_median_stat_length(self):
 
     def test_check_mean_shape_one(self):
         a = [[4, 5, 6]]
-        a = pad(a, (5, 7), 'mean', stat_length=2)
+        a = np.pad(a, (5, 7), 'mean', stat_length=2)
         b = np.array(
             [[4, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6],
              [4, 4, 4, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6],
@@ -323,7 +329,7 @@ def test_check_mean_shape_one(self):
 
     def test_check_mean_2(self):
         a = np.arange(100).astype('f')
-        a = pad(a, (25, 20), 'mean')
+        a = np.pad(a, (25, 20), 'mean')
         b = np.array(
             [49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5,
              49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5, 49.5,
@@ -349,7 +355,7 @@ def test_check_mean_2(self):
 class TestConstant(TestCase):
     def test_check_constant(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'constant', constant_values=(10, 20))
+        a = np.pad(a, (25, 20), 'constant', constant_values=(10, 20))
         b = np.array(
             [10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
              10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
@@ -373,7 +379,7 @@ def test_check_constant(self):
 
     def test_check_constant_zeros(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'constant')
+        a = np.pad(a, (25, 20), 'constant')
         b = np.array(
             [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
               0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
@@ -399,7 +405,7 @@ def test_check_constant_float(self):
         # If input array is int, but constant_values are float, the dtype of
         # the array to be padded is kept
         arr = np.arange(30).reshape(5, 6)
-        test = pad(arr, (1, 2), mode='constant',
+        test = np.pad(arr, (1, 2), mode='constant',
                    constant_values=1.1)
         expected = np.array(
             [[ 1,  1,  1,  1,  1,  1,  1,  1,  1],
@@ -420,7 +426,7 @@ def test_check_constant_float2(self):
         # the array to be padded is kept - here retaining the float constants
         arr = np.arange(30).reshape(5, 6)
         arr_float = arr.astype(np.float64)
-        test = pad(arr_float, ((1, 2), (1, 2)), mode='constant',
+        test = np.pad(arr_float, ((1, 2), (1, 2)), mode='constant',
                    constant_values=1.1)
         expected = np.array(
             [[  1.1,   1.1,   1.1,   1.1,   1.1,   1.1,   1.1,   1.1,   1.1],
@@ -438,7 +444,7 @@ def test_check_constant_float2(self):
 
     def test_check_constant_float3(self):
         a = np.arange(100, dtype=float)
-        a = pad(a, (25, 20), 'constant', constant_values=(-1.1, -1.2))
+        a = np.pad(a, (25, 20), 'constant', constant_values=(-1.1, -1.2))
         b = np.array(
             [-1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1,
              -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1, -1.1,
@@ -462,7 +468,7 @@ def test_check_constant_float3(self):
 
     def test_check_constant_odd_pad_amount(self):
         arr = np.arange(30).reshape(5, 6)
-        test = pad(arr, ((1,), (2,)), mode='constant',
+        test = np.pad(arr, ((1,), (2,)), mode='constant',
                    constant_values=3)
         expected = np.array(
             [[ 3,  3,  3,  3,  3,  3,  3,  3,  3,  3],
@@ -481,7 +487,7 @@ def test_check_constant_odd_pad_amount(self):
 class TestLinearRamp(TestCase):
     def test_check_simple(self):
         a = np.arange(100).astype('f')
-        a = pad(a, (25, 20), 'linear_ramp', end_values=(4, 5))
+        a = np.pad(a, (25, 20), 'linear_ramp', end_values=(4, 5))
         b = np.array(
             [4.00, 3.84, 3.68, 3.52, 3.36, 3.20, 3.04, 2.88, 2.72, 2.56,
              2.40, 2.24, 2.08, 1.92, 1.76, 1.60, 1.44, 1.28, 1.12, 0.96,
@@ -505,7 +511,7 @@ def test_check_simple(self):
 
     def test_check_2d(self):
         arr = np.arange(20).reshape(4, 5).astype(np.float64)
-        test = pad(arr, (2, 2), mode='linear_ramp', end_values=(0, 0))
+        test = np.pad(arr, (2, 2), mode='linear_ramp', end_values=(0, 0))
         expected = np.array(
             [[0.,   0.,   0.,   0.,   0.,   0.,   0.,    0.,   0.],
              [0.,   0.,   0.,  0.5,   1.,  1.5,   2.,    1.,   0.],
@@ -521,7 +527,7 @@ def test_check_2d(self):
 class TestReflect(TestCase):
     def test_check_simple(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'reflect')
+        a = np.pad(a, (25, 20), 'reflect')
         b = np.array(
             [25, 24, 23, 22, 21, 20, 19, 18, 17, 16,
              15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
@@ -545,7 +551,7 @@ def test_check_simple(self):
 
     def test_check_odd_method(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'reflect', reflect_type='odd')
+        a = np.pad(a, (25, 20), 'reflect', reflect_type='odd')
         b = np.array(
             [-25, -24, -23, -22, -21, -20, -19, -18, -17, -16,
              -15, -14, -13, -12, -11, -10, -9, -8, -7, -6,
@@ -569,7 +575,7 @@ def test_check_odd_method(self):
 
     def test_check_large_pad(self):
         a = [[4, 5, 6], [6, 7, 8]]
-        a = pad(a, (5, 7), 'reflect')
+        a = np.pad(a, (5, 7), 'reflect')
         b = np.array(
             [[7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7],
              [5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5],
@@ -592,7 +598,7 @@ def test_check_large_pad(self):
 
     def test_check_shape(self):
         a = [[4, 5, 6]]
-        a = pad(a, (5, 7), 'reflect')
+        a = np.pad(a, (5, 7), 'reflect')
         b = np.array(
             [[5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5],
              [5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5, 6, 5, 4, 5],
@@ -613,17 +619,17 @@ def test_check_shape(self):
         assert_array_equal(a, b)
 
     def test_check_01(self):
-        a = pad([1, 2, 3], 2, 'reflect')
+        a = np.pad([1, 2, 3], 2, 'reflect')
         b = np.array([3, 2, 1, 2, 3, 2, 1])
         assert_array_equal(a, b)
 
     def test_check_02(self):
-        a = pad([1, 2, 3], 3, 'reflect')
+        a = np.pad([1, 2, 3], 3, 'reflect')
         b = np.array([2, 3, 2, 1, 2, 3, 2, 1, 2])
         assert_array_equal(a, b)
 
     def test_check_03(self):
-        a = pad([1, 2, 3], 4, 'reflect')
+        a = np.pad([1, 2, 3], 4, 'reflect')
         b = np.array([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3])
         assert_array_equal(a, b)
 
@@ -631,7 +637,7 @@ def test_check_03(self):
 class TestSymmetric(TestCase):
     def test_check_simple(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'symmetric')
+        a = np.pad(a, (25, 20), 'symmetric')
         b = np.array(
             [24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
              14, 13, 12, 11, 10, 9, 8, 7, 6, 5,
@@ -655,7 +661,7 @@ def test_check_simple(self):
 
     def test_check_odd_method(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'symmetric', reflect_type='odd')
+        a = np.pad(a, (25, 20), 'symmetric', reflect_type='odd')
         b = np.array(
             [-24, -23, -22, -21, -20, -19, -18, -17, -16, -15,
              -14, -13, -12, -11, -10, -9, -8, -7, -6, -5,
@@ -679,7 +685,7 @@ def test_check_odd_method(self):
 
     def test_check_large_pad(self):
         a = [[4, 5, 6], [6, 7, 8]]
-        a = pad(a, (5, 7), 'symmetric')
+        a = np.pad(a, (5, 7), 'symmetric')
         b = np.array(
             [[5, 6, 6, 5, 4, 4, 5, 6, 6, 5, 4, 4, 5, 6, 6],
              [5, 6, 6, 5, 4, 4, 5, 6, 6, 5, 4, 4, 5, 6, 6],
@@ -703,7 +709,7 @@ def test_check_large_pad(self):
 
     def test_check_large_pad_odd(self):
         a = [[4, 5, 6], [6, 7, 8]]
-        a = pad(a, (5, 7), 'symmetric', reflect_type='odd')
+        a = np.pad(a, (5, 7), 'symmetric', reflect_type='odd')
         b = np.array(
             [[-3, -2, -2, -1,  0,  0,  1,  2,  2,  3,  4,  4,  5,  6,  6],
              [-3, -2, -2, -1,  0,  0,  1,  2,  2,  3,  4,  4,  5,  6,  6],
@@ -726,7 +732,7 @@ def test_check_large_pad_odd(self):
 
     def test_check_shape(self):
         a = [[4, 5, 6]]
-        a = pad(a, (5, 7), 'symmetric')
+        a = np.pad(a, (5, 7), 'symmetric')
         b = np.array(
             [[5, 6, 6, 5, 4, 4, 5, 6, 6, 5, 4, 4, 5, 6, 6],
              [5, 6, 6, 5, 4, 4, 5, 6, 6, 5, 4, 4, 5, 6, 6],
@@ -747,17 +753,17 @@ def test_check_shape(self):
         assert_array_equal(a, b)
 
     def test_check_01(self):
-        a = pad([1, 2, 3], 2, 'symmetric')
+        a = np.pad([1, 2, 3], 2, 'symmetric')
         b = np.array([2, 1, 1, 2, 3, 3, 2])
         assert_array_equal(a, b)
 
     def test_check_02(self):
-        a = pad([1, 2, 3], 3, 'symmetric')
+        a = np.pad([1, 2, 3], 3, 'symmetric')
         b = np.array([3, 2, 1, 1, 2, 3, 3, 2, 1])
         assert_array_equal(a, b)
 
     def test_check_03(self):
-        a = pad([1, 2, 3], 6, 'symmetric')
+        a = np.pad([1, 2, 3], 6, 'symmetric')
         b = np.array([1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3])
         assert_array_equal(a, b)
 
@@ -765,7 +771,7 @@ def test_check_03(self):
 class TestWrap(TestCase):
     def test_check_simple(self):
         a = np.arange(100)
-        a = pad(a, (25, 20), 'wrap')
+        a = np.pad(a, (25, 20), 'wrap')
         b = np.array(
             [75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
              85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
@@ -790,7 +796,7 @@ def test_check_simple(self):
     def test_check_large_pad(self):
         a = np.arange(12)
         a = np.reshape(a, (3, 4))
-        a = pad(a, (10, 12), 'wrap')
+        a = np.pad(a, (10, 12), 'wrap')
         b = np.array(
             [[10, 11, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 10, 11, 8, 9, 10,
               11, 8, 9, 10, 11, 8, 9, 10, 11],
@@ -848,12 +854,12 @@ def test_check_large_pad(self):
         assert_array_equal(a, b)
 
     def test_check_01(self):
-        a = pad([1, 2, 3], 3, 'wrap')
+        a = np.pad([1, 2, 3], 3, 'wrap')
         b = np.array([1, 2, 3, 1, 2, 3, 1, 2, 3])
         assert_array_equal(a, b)
 
     def test_check_02(self):
-        a = pad([1, 2, 3], 4, 'wrap')
+        a = np.pad([1, 2, 3], 4, 'wrap')
         b = np.array([3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1])
         assert_array_equal(a, b)
 
@@ -862,7 +868,7 @@ class TestStatLen(TestCase):
     def test_check_simple(self):
         a = np.arange(30)
         a = np.reshape(a, (6, 5))
-        a = pad(a, ((2, 3), (3, 2)), mode='mean', stat_length=(3,))
+        a = np.pad(a, ((2, 3), (3, 2)), mode='mean', stat_length=(3,))
         b = np.array(
             [[6, 6, 6, 5, 6, 7, 8, 9, 8, 8],
              [6, 6, 6, 5, 6, 7, 8, 9, 8, 8],
@@ -885,7 +891,7 @@ class TestEdge(TestCase):
     def test_check_simple(self):
         a = np.arange(12)
         a = np.reshape(a, (4, 3))
-        a = pad(a, ((2, 3), (3, 2)), 'edge')
+        a = np.pad(a, ((2, 3), (3, 2)), 'edge')
         b = np.array(
             [[0, 0, 0, 0, 1, 2, 2, 2],
              [0, 0, 0, 0, 1, 2, 2, 2],
@@ -907,7 +913,7 @@ def test_zero_pad_width(self):
         arr = np.arange(30)
         arr = np.reshape(arr, (6, 5))
         for pad_width in (0, (0, 0), ((0, 0), (0, 0))):
-            assert_array_equal(arr, pad(arr, pad_width, mode='constant'))
+            assert_array_equal(arr, np.pad(arr, pad_width, mode='constant'))
 
 
 class TestLegacyVectorFunction(TestCase):
@@ -918,7 +924,7 @@ def _padwithtens(vector, pad_width, iaxis, kwargs):
             return vector
 
         a = np.arange(6).reshape(2, 3)
-        a = pad(a, 2, _padwithtens)
+        a = np.pad(a, 2, _padwithtens)
         b = np.array(
             [[10, 10, 10, 10, 10, 10, 10],
              [10, 10, 10, 10, 10, 10, 10],
@@ -936,7 +942,7 @@ class TestNdarrayPadWidth(TestCase):
     def test_check_simple(self):
         a = np.arange(12)
         a = np.reshape(a, (4, 3))
-        a = pad(a, np.array(((2, 3), (3, 2))), 'edge')
+        a = np.pad(a, np.array(((2, 3), (3, 2))), 'edge')
         b = np.array(
             [[0,  0,  0,    0,  1,  2,    2,  2],
              [0,  0,  0,    0,  1,  2,    2,  2],
@@ -959,21 +965,21 @@ def test_check_simple(self):
         arr = np.reshape(arr, (6, 5))
         kwargs = dict(mode='mean', stat_length=(3, ))
         with testing.raises(ValueError):
-            pad(arr, ((2, 3), (3, 2), (4, 5)), **kwargs)
+            np.pad(arr, ((2, 3), (3, 2), (4, 5)), **kwargs)
 
     def test_check_negative_stat_length(self):
         arr = np.arange(30)
         arr = np.reshape(arr, (6, 5))
         kwargs = dict(mode='mean', stat_length=(-3, ))
         with testing.raises(ValueError):
-            pad(arr, ((2, 3), (3, 2)), **kwargs)
+            np.pad(arr, ((2, 3), (3, 2)), **kwargs)
 
     def test_check_negative_pad_width(self):
         arr = np.arange(30)
         arr = np.reshape(arr, (6, 5))
         kwargs = dict(mode='mean', stat_length=(3, ))
         with testing.raises(ValueError):
-            pad(arr, ((-2, 3), (3, 2)), **kwargs)
+            np.pad(arr, ((-2, 3), (3, 2)), **kwargs)
 
 
 class ValueError2(TestCase):
@@ -982,31 +988,31 @@ def test_check_negative_pad_amount(self):
         arr = np.reshape(arr, (6, 5))
         kwargs = dict(mode='mean', stat_length=(3, ))
         with testing.raises(ValueError):
-            pad(arr, ((-2, 3), (3, 2)), **kwargs)
+            np.pad(arr, ((-2, 3), (3, 2)), **kwargs)
 
 
 class ValueError3(TestCase):
     def test_check_kwarg_not_allowed(self):
         arr = np.arange(30).reshape(5, 6)
         with testing.raises(ValueError):
-            pad(arr, 4, mode='mean', reflect_type='odd')
+            np.pad(arr, 4, mode='mean', reflect_type='odd')
 
     @testing.skipif(LooseVersion(np.__version__) >= LooseVersion('1.17'),
                     reason='Error removed in NumPy 1.17')
     def test_mode_not_set(self):
         arr = np.arange(30).reshape(5, 6)
         with testing.raises(TypeError):
-            pad(arr, 4)
+            np.pad(arr, 4)
 
     def test_malformed_pad_amount(self):
         arr = np.arange(30).reshape(5, 6)
         with testing.raises(ValueError):
-            pad(arr, (4, 5, 6, 7), mode='constant')
+            np.pad(arr, (4, 5, 6, 7), mode='constant')
 
     def test_malformed_pad_amount2(self):
         arr = np.arange(30).reshape(5, 6)
         with testing.raises(ValueError):
-            pad(arr, ((3, 4, 5), (0, 1, 2)), mode='constant')
+            np.pad(arr, ((3, 4, 5), (0, 1, 2)), mode='constant')
 
     def test_pad_too_many_axes(self):
         arr = np.arange(30).reshape(5, 6)
@@ -1014,41 +1020,41 @@ def test_pad_too_many_axes(self):
         # Attempt to pad using a 3D array equivalent
         bad_shape = (((3,), (4,), (5,)), ((0,), (1,), (2,)))
         with testing.raises(ValueError):
-            pad(arr, bad_shape, mode='constant')
+            np.pad(arr, bad_shape, mode='constant')
 
 
 class TypeError1(TestCase):
     def test_float(self):
         arr = np.arange(30)
         with testing.raises(TypeError):
-            pad(arr, ((-2.1, 3), (3, 2)))
+            np.pad(arr, ((-2.1, 3), (3, 2)))
         with testing.raises(TypeError):
-            pad(arr, np.array(((-2.1, 3), (3, 2))))
+            np.pad(arr, np.array(((-2.1, 3), (3, 2))))
 
     def test_str(self):
         arr = np.arange(30)
         with testing.raises(TypeError):
-            pad(arr, 'foo')
+            np.pad(arr, 'foo')
         with testing.raises(TypeError):
-            pad(arr, np.array('foo'))
+            np.pad(arr, np.array('foo'))
 
     def test_object(self):
         class FooBar(object):
             pass
         arr = np.arange(30)
         with testing.raises(TypeError):
-            pad(arr, FooBar())
+            np.pad(arr, FooBar())
 
     def test_complex(self):
         arr = np.arange(30)
         with testing.raises(TypeError):
-            pad(arr, complex(1, -1))
+            np.pad(arr, complex(1, -1))
         with testing.raises(TypeError):
-            pad(arr, np.array(complex(1, -1)))
+            np.pad(arr, np.array(complex(1, -1)))
 
     def test_check_wrong_pad_amount(self):
         arr = np.arange(30)
         arr = np.reshape(arr, (6, 5))
         kwargs = dict(mode='mean', stat_length=(3, ))
         with testing.raises(TypeError):
-            pad(arr, ((2, 3, 4), (3, 2)), **kwargs)
+            np.pad(arr, ((2, 3, 4), (3, 2)), **kwargs)