-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Graceful handling of a numpy matrix #1558
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
Comments
Wouldn't doing an np.squeeze() on the result of ravel() do the trick? Not |
That handles masked arrays well, but it still retains the shape |
From the other thread, we need to make sure the docs are clear that mpl does not support |
The correct way to fix this is probably to figure out each call site of This helper function should probably(?) then be used in most places where either |
Instead of only whitelisting masked arrays, it should blacklist matrix. Otherwise, you needlessly preclude other |
On 2016/10/11 9:17 AM, Ryan May wrote:
Right. The matrix subclass is an anomaly that causes more problems than |
Agreed, just blacklisting matrix and matrix subclasses seems better. |
If you give
quiver
numpy matrices, it will crash. It raises aValueError
for areshape
, which can be hard to realize was caused by the matrices (potentially to great frustration for the user).The source of the problem boils down to
ravel()
fornp.matrix
creating a row matrix of shape(1, N)
, instead of an ndarray with shape(N,)
.I naively tried fixing it (pull request: #1546) by throwing in a call to
np.asarray
, but it was rightly closed because it would break support for masked arrays. It was also pointed out that it was likely to be a problem beyond justquiver
.As I see it, the issue is either resolved by adding support for
numpy.matrix
, or better information to the users of the source of the error.The text was updated successfully, but these errors were encountered: