-
Notifications
You must be signed in to change notification settings - Fork 47
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
Creating CSR array with duplicates fails #136
Comments
After more investigation and reading the docstring more carefully, maybe it's not a bug for Currently, the result is indeed not consistent for this input, where Maybe there is a difference in convention with scipy. Anyway, replacing let indptr = vec![0, 5, 9]; in the above example, I now get,
which seems to happen in here. At the same time, if one has such data, the question is how one is expected to handle it. I could do it manually, but I would need to first sort the indices, and currently that would mean manually copy-pasting this code from sprs, as there is no stand alone API entry for it. |
Hello and thanks for this report. It was indeed a design choice that the basic constructor for I'm however a bit curious about your input data. As I understand it, the last value in your |
Sounds like a reasonable thing to do, and now I do wonder about the performance cost of always doing this duplicate summing in scipy, even when it's not necessary.
Even a util function something like
All values in |
Also, I would be happy to contribute this feature in general. |
Yes I also think this is the way to go. If you want to contribute this feature, please do. May I suggest that
I really think the last value has been ignored by scipy. If you look at the sum of the |
yes, my
Sure, will do. |
Currently,
CsMat::new
appears to fail on input that has duplicate values (i.e. when in a CSR matrix multiple indices for a row are the same). They are summed by default, if I read the following comment correctly,An example from #135,
this produces,
using the code from that PR.
In this case, the initial
len(indices)
is indeed 9 but it becomes 8 after the duplicates are summed.FWIW
scipy.sparse.csr_matrix
in Python (see docs and implementation ) handles this case as follows,I can contribute this example as a test if necessary.
The text was updated successfully, but these errors were encountered: