[Numpy-discussion] Changing np.ravel's return to be same array type as input array
Charles R Harris
charlesr.harris at gmail.com
Sun Dec 28 13:20:22 EST 2014
On Sat, Dec 27, 2014 at 10:56 PM, Garrett Reynolds <
garrettreynolds5 at gmail.com> wrote:
> I made a pull request to change np.ravel so that it would return the same
> array type (ndarray, matrix, masked array, etc.) as it took in.
> This would bring np.ravel in line with other functions. For example,
> np.sort, np.clip, np.cumsum, np.conjugate, np.partition, np.reshape,
> np.transpose, etc. all return the same array type as they take in. In
> addition, np.diag and np.diagonal were recently changed in PR #5358 to
> return the same array type they take in. Now, np.ravel may be the only
> outstanding function with the surprising behavior of always returning an
> The concern is that *this could break the code of np.matrix users*, so
> @jaimefrio suggested I post here to get some feedback.
> You can see more comments on the PR:
The changes to np.diag and np.diagonal did break some code, but I think is
is the right thing to do. Matrix is a bit of an oddity, in that it fools
with the number of dimensions, but I think consistency and preserving other
subtypes like units is more important. The change needs to be noted in the
1.10 release notes under compatibility, I haven't checked yet to see if
that is already done in the PR.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion