Skip to content

Instantly share code, notes, and snippets.

@delta2323
Last active December 2, 2016 04:14
Show Gist options
  • Save delta2323/9e54c3b11c9d3ba63bbfef50df7c2a0a to your computer and use it in GitHub Desktop.
Save delta2323/9e54c3b11c9d3ba63bbfef50df7c2a0a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
In [2]: import numpy as xp
In [3]: xp.__version__
Out[3]: '1.10.4'
In [4]: array = xp.ones([4, 5, 6, 7])
In [5]: pad_width = [[1, 2], [3, 4], [5, 6], [7, 8]]
In [6]: constant_values = [[9, 10], [11, 12], [13, 14], [15, 16]]
In [7]: a = xp.pad(array, pad_width, mode='constant',
constant_values=constant_values)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-998b17be8f71> in <module>()
1 a = xp.pad(array, pad_width, mode='constant',
----> 2 constant_values=constant_values)
/Users/oonokenta/.pyenv/versions/2.7.10/envs/pyenv-2.7.10/lib/python2.7/site-packages/numpy/lib/arraypad.pyc in pad(array, pad_width, mode, **kwargs)
1355 if i in ['end_values', 'constant_values']:
1356 kwargs[i] = _normalize_shape(narray, kwargs[i],
-> 1357 cast_to_int=False)
1358 elif mode is None:
1359 raise ValueError('Keyword "mode" must be a function or one of %s.' %
/Users/oonokenta/.pyenv/versions/2.7.10/envs/pyenv-2.7.10/lib/python2.7/site-packages/numpy/lib/arraypad.pyc in _normalize_shape(ndarray, shape, cast_to_int)
1067
1068 # Convert list of lists to tuple of tuples
-> 1069 return tuple(tuple(axis) for axis in arr.tolist())
1070
1071
AttributeError: 'list' object has no attribute 'tolist'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment