8000 pad in arraypad.py changed behavior in an undocumented fashion · Issue #7353 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

pad in arraypad.py changed behavior in an undocumented fashion #7353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chiffa opened this issue Feb 27, 2016 · 3 comments
Closed

pad in arraypad.py changed behavior in an undocumented fashion #7353

chiffa opened this issue Feb 27, 2016 · 3 comments

Comments

@chiffa
Copy link
Contributor
chiffa commented Feb 27, 2016

Previously this command worked:

a = [[1, 2], [3, 4]]
np.lib.pad(a, ((3, 2), (2, 3)), 'constant',
                 constant_values=((np.nan, np.nan), (np.nan, np.nan)))

However in the 1.10.4 it now returns the following stack trace:

Traceback (most recent call last):
  File "C:/Users/Andrei/PycharmProjects/Pharmacosensitivity_growth_assays/src/post_processing.py", line 477, in <module>
    all_cell_lines_arr, means_accumulator, errs_accumulator, names_accumulator = stack_data_in_range_of_interest(concs_effective_range)
  File "C:/Users/Andrei/PycharmProjects/Pharmacosensitivity_growth_assays/src/post_processing.py", line 129, in stack_data_in_range_of_interest
    mode='constant', constant_values=((np.nan, np.nan), (np.nan, np.nan)))
  File "C:\Anaconda\lib\site-packages\numpy\lib\arraypad.py", line 1358, in pad
    cast_to_int=False)
  File "C:\Anaconda\lib\site-packages\numpy\lib\arraypad.py", line 1070, in _normalize_shape
    return tuple(tuple(axis) for axis in arr.tolist())
AttributeError: 'tuple' object has no attribute 'tolist'

This is now the way of implementing the padding:

a = [[1, 2], [3, 4]]
nan_pad = np.array(((np.nan, np.nan), (np.nan, np.nan)))

np.lib.pad(a, ((3, 2), (2, 3)), 'constant',
                 constant_values=nan_pad)

Could you please add relevant documentation to the pad function in the arraypad.py?

An additional issue is that it looks like np.nan gets converted to -2147483648 which seems to be overflowing 32-bit signed integer. It does not affect my code that much, but this is an issue you might need to be aware of.

@njsmith
Copy link
Member
njsmith commented Feb 27, 2016

This comment is relevant to this bug: #7354 (comment)

chiffa added a commit to chiffa/numpy that referenced this issue Feb 27, 2016
chiffa added a commit to chiffa/numpy that referenced this issue Feb 27, 2016
chiffa added a commit to chiffa/numpy that referenced this issue Feb 28, 2016
This test exposes padding bug described in the issue numpy#7353
chiffa added a commit to chiffa/numpy that referenced this issue Feb 28, 2016
Constant padding on 4 sides of a 2d array expected a numpy ndarray, and not a ndarray like (tuple, list, ...)
Detailed description is in the issue  numpy#7353
njsmith added a commit that referenced this issue Feb 28, 2016
BUG: pull request related to the issue #7353
jaimefrio pushed a commit to jaimefrio/numpy that referenced this issue Mar 22, 2016
This test exposes padding bug described in the issue numpy#7353
jaimefrio pushed a commit to jaimefrio/numpy that referenced this issue Mar 22, 2016
Constant padding on 4 sides of a 2d array expected a numpy ndarray, and not a ndarray like (tuple, list, ...)
Detailed description is in the issue  numpy#7353
charris pushed a commit to charris/numpy that referenced this issue Apr 18, 2016
This test exposes padding bug described in the issue numpy#7353
charris pushed a commit to charris/numpy that referenced this issue Apr 18, 2016
Constant padding on 4 sides of a 2d array expected a numpy ndarray, and not a ndarray like (tuple, list, ...)
Detailed description is in the issue  numpy#7353
@jakirkham
Copy link
Contributor

Retested with NumPy 1.14.3 and this appears to be fixed.

@charris
Copy link
Member
charris commented Jun 8, 2018

@jakirkham Thanks for the heads up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
0