numpy 1.9b1 bug in pad function?

In [1]: import numpy as np In [2]: a = np.arange(4) In [3]: np.pad(a,2) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-3-f56fe53684b8> in <module>() ----> 1 np.pad(a,2)
/usr/lib64/python3.3/site-packages/numpy/lib/arraypad.py in pad(array, pad_width, mode, **kwargs) 1331 elif mode is None: 1332 raise ValueError('Keyword "mode" must be a function or one of %s.' % -> 1333 (list(allowedkwargs.keys()),)) 1334 else: 1335 # Drop back to old, slower np.apply_along_axis mode for user-supplied
ValueError: Keyword "mode" must be a function or one of ['edge', 'constant', 'wrap', 'reflect', 'median', 'maximum', 'minimum', 'symmetric', 'linear_ramp', 'mean'].
In [4]: np.__version__ Out[4]: '1.9.0b1'
The documentation specify that the mode parameter is optional
I am getting the same for both python 2.7 and 3.3 OS: Gentoo linux
Nadav

Hi Nadav
On Sat, Jun 14, 2014 at 8:11 AM, Nadav Horesh nadavh@visionsense.com wrote:
In [4]: np.__version__ Out[4]: '1.9.0b1'
The documentation specify that the mode parameter is optional
I don't see the optional specification in the docstring. Perhaps because mode=None in the signature?
The reason is that then, if you do not specify the signature (as in your case), you get the following helpful message:
ValueError: Keyword "mode" must be a function or one of ['reflect', 'linear_ramp', 'edge', 'constant', 'minimum', 'wrap', 'symmetric', 'median', 'maximum', 'mean'].
Instead of
pad() takes exactly 3 arguments (2 given)
Regards Stéfan

This is most likely a documentation error since:
In [7]: np.pad(a) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-7-7a0346d77134> in <module>() ----> 1 np.pad(a)
TypeError: pad() missing 1 required positional argument: 'pad_width'
Nadav ________________________________________ From: numpy-discussion-bounces@scipy.org numpy-discussion-bounces@scipy.org on behalf of Stéfan van der Walt stefan@sun.ac.za Sent: 14 June 2014 13:39 To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] numpy 1.9b1 bug in pad function?
Hi Nadav
On Sat, Jun 14, 2014 at 8:11 AM, Nadav Horesh nadavh@visionsense.com wrote:
In [4]: np.__version__ Out[4]: '1.9.0b1'
The documentation specify that the mode parameter is optional
I don't see the optional specification in the docstring. Perhaps because mode=None in the signature?
The reason is that then, if you do not specify the signature (as in your case), you get the following helpful message:
ValueError: Keyword "mode" must be a function or one of ['reflect', 'linear_ramp', 'edge', 'constant', 'minimum', 'wrap', 'symmetric', 'median', 'maximum', 'mean'].
Instead of
pad() takes exactly 3 arguments (2 given)
Regards Stéfan _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On 2014-06-14 14:40:29, Nadav Horesh nadavh@visionsense.com wrote:
This is most likely a documentation error since:
In [7]: np.pad(a)
TypeError Traceback (most recent call last) <ipython-input-7-7a0346d77134> in <module>() ----> 1 np.pad(a)
TypeError: pad() missing 1 required positional argument: 'pad_width'
That is because the signature is
pad(array, pad_width, mode=None, ...)
But mode *does* need to be specified. I see why this can be confusing, though, so perhaps we should simply make mode a positional argument too.
Stéfan

On 2014-06-14 14:40:29, Nadav Horesh nadavh@visionsense.com wrote:
TypeError: pad() missing 1 required positional argument: 'pad_width'
I've added a PR here for further discussion:
https://github.com/numpy/numpy/pull/4808
Stéfan
participants (3)
-
Nadav Horesh
-
Stefan van der Walt
-
Stéfan van der Walt