-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
toarray on sparse matrices can't handle dtype=bool (Trac #1533) #2058
Comments
trac user agrothberg wrote on 2013-03-05 I am seeing the same issue with:
and then
why does the type show up at numpy.bool_ rather than numpy.bool? |
trac user cowlicks wrote on 2013-04-17 If you instantiate a
So the ndarray is passed through
Where the This is odd behavior, why is the dtype being changed? Is there a reason a |
Indeed this can be closed. In [1]: import numpy as np
In [2]: from scipy.sparse import *
In [3]: X = np.ones(10, dtype=bool)
In [4]: csr_matrix(X).toarray()
Out[4]:
array([[ True, True, True, True, True, True, True, True, True,
True]], dtype=bool) |
I see there's a unit test in c6ea8cc, thanks! |
Original ticket http://projects.scipy.org/scipy/ticket/1533 on 2011-10-08 by trac user larsmans, assigned to @wnbell.
It seems
toarray
on sparse matrices doesn't work if they were constructed with an explicitdtype=bool
.The following works:
But now the
dtype
has changed. I guess the space requirements are the same, but it prints1
instead ofTrue
. So,Ok, that works too, but I want to print the elements...
The problem seems to be somewhere in the
coo_matrix
code; the same happens with all other sparse matrix types, except forlil_matrix
:The text was updated successfully, but these errors were encountered: