-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
np.asarray - unexpected behaviour #14221
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
Another example that raises the same error.
I suspect the error is because when you have a list of arrays which have the same first dimension of the shape, then the Similarly error also occurs for multi-dimensional arrays. I can take a look at this if nobody else is working on it. |
Feel free too, but I'll warn you that this has almost certainly come up before, and is rather tricky to fix. |
😱I'll take a look and see if I can figure out something |
I also have unexpected behavior with csr matrices:
versions:
|
I'm driving into this. Do you know what should be the expected behavior? Should it return an array of arrays? Or should it reshape and return a single np arrays. |
The sparse matrix thing is a different issue.
The consistent thing for this particular issue would be to not get the Of course such behavior is probably still not what the user intended ...... if we'd want to change it, that should probably raise an exception. I don't really know, it's tricky. |
FYI: The somewhat surprising automatic conversion of the |
@rgommers Thanks. I agree on your point on consistency. But I also agree that it is probably not the intended behavior and making it consistent might hide the problem. Yeap. The sparse matrix should be a separate issue. Let me move that over. @WarrenWeckesser Thanks for pointing that out. This is a really tricky issue. |
@zaraasghar, your issue is completely unrelated, and looks like a user error. I'd recommend asking on stack overflow. |
All of the examples now correctly throw an error. |
Uh oh!
There was an error while loading. Please reload this page.
When I try to do np.asarray of a list of arrays, it results in different behaviour depending on the dimensions of the arrays. When the list of arrays is of dimensions like (n,n) and (n,) it results in error.
Reproducing code example:
Error message:
Numpy/Python version information:
('1.16.3', '2.7.12 (default, Nov 12 2018, 14:36:49) \n[GCC 5.4.0 20160609]')
The text was updated successfully, but these errors were encountered: