Skip to content
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

setindex! for SparseMatrixCSC errors in corner cases #39

Open
bkamins opened this issue Mar 24, 2019 · 2 comments
Open

setindex! for SparseMatrixCSC errors in corner cases #39

bkamins opened this issue Mar 24, 2019 · 2 comments

Comments

@bkamins
Copy link

bkamins commented Mar 24, 2019

It seems that the TODO mentioned in

https://github.com/JuliaLang/julia/blob/master/stdlib/SparseArrays/src/sparsematrix.jl#L2701

causes an error reported in https://stackoverflow.com/questions/55326817/mapping-a-function-to-an-array-of-sparse-matrices-in-julia.

This issue is similar to JuliaLang/julia#29034 but seems to be a separate case (not 100% sure, as I do not know this part of sources very well).

A MWE is something like:

julia> mapslices(x -> "a", sprand(3, 3, 0.5), dims=2)
ERROR: MethodError: no method matching zero(::Type{String})
@andreasnoack
Copy link
Member

Are you sure this is about https://github.com/JuliaLang/julia/blob/master/stdlib/SparseArrays/src/sparsematrix.jl#L2701? Isnøt the issue just that SparseMatrixCSC doesn't really work for element types without a zero defined.

@bkamins
Copy link
Author

bkamins commented Mar 29, 2019

I think I am sure (i.e. the bug is that we try to create a sparse matrix while we should create a dense matrix and there would be no problem).

Here is another example that should in theory produce the same result, but one fails because zero is not defined for the processed type (as you note):

julia> mapslices(findmax, sprand(3,3,0.5), dims=2)
ERROR: MethodError: no method matching zero(::Type{Tuple{Float64,Int64}})

julia> findmax(sprand(3,3,0.5), dims=2)
(
  [1, 1]  =  0.467715
  [2, 1]  =  0.0989516
  [3, 1]  =  0.593281, CartesianIndex{2}[CartesianIndex(1, 2); CartesianIndex(2, 2); CartesianIndex(3, 3)])

But as I have said above - I did not dig too deeply into the source code.

@KristofferC KristofferC transferred this issue from JuliaLang/julia Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants