Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Add shape manipulation methods to ndarray #23

Merged
merged 2 commits into from
Nov 13, 2018
Merged

Add shape manipulation methods to ndarray #23

merged 2 commits into from
Nov 13, 2018

Conversation

sproshev
Copy link
Contributor

All returned ndarrays should be like ndarray[T]

@overload
def reshape(self,
__dim1: int,
__dim2: int,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is valid to include only one dimension in reshape:

In [6]: np.zeros((2, 2)).reshape(-1)
Out[6]: array([0., 0., 0., 0.])

Zero entries seems to raise currently, but I suspect this is a bug -- it's probably safer just to make the overloaded signature *shape here

In [7]: np.zeros((1, 1)).reshape()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-aca69783c5f4> in <module>()
----> 1 np.zeros((1, 1)).reshape()

(It's probably best to do the same for resize and transpose, too)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@shoyer shoyer merged commit 2cb3005 into numpy:master Nov 13, 2018
@shoyer
Copy link
Member

shoyer commented Nov 13, 2018

thanks!

@sproshev sproshev deleted the sproshev/shape-manipulation branch November 13, 2018 21:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants