Skip to content

MAINT: Simplify dimension-juggling in np.pad#11011

Merged
charris merged 2 commits intonumpy:masterfrom
eric-wieser:pad-singleton
May 13, 2018
Merged

MAINT: Simplify dimension-juggling in np.pad#11011
charris merged 2 commits intonumpy:masterfrom
eric-wieser:pad-singleton

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

This file is pretty repetitive - this picks off some of the low-hanging fruit.

… losing the dimension in the first place.

`arr[:,:,0,:,:].reshape(arr.shape[:2] + (1,) + arr.shape[3:])` is much more readable as `arr[:,:,0:1,:,:]` (and easier for subclasses to handle)
This is safe, because the arguments are always base-class ndarrays, so `keepdims` is guaranteed to be supported
@charris
Copy link
Copy Markdown
Member

charris commented May 13, 2018

Cannot claim to have verified all the changes, but they look to be a repetitive rewrite of some common boiler plate making better use of indexing, so I'm going to rely on the tests. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants