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

sparse constructor misbehaving on master #12397

Closed
gragusa opened this issue Jul 31, 2015 · 5 comments
Closed

sparse constructor misbehaving on master #12397

gragusa opened this issue Jul 31, 2015 · 5 comments
Labels
sparse Sparse arrays

Comments

@gragusa
Copy link
Contributor

gragusa commented Jul 31, 2015

In v.0.3.10

julia> sparse([], [], [1], 0, 0, vcat)
0x0 sparse matrix with 0 Int64 entries:

In 0.4.0-dev+6402

julia> sparse([], [], [1], 0, 0, vcat)
ERROR: MethodError: `sparse` has no method matching sparse(::Array{Any,1}, ::Array{Any,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::Function)
Closest candidates are:
  sparse(::Any, ::Any, ::AbstractArray{T,1}, ::Any, ::Any)
  sparse(::Any, ::Any, ::Number, ::Any, ::Any, ::Union{Base.Func{N},Function})
  sparse(::Any, ::Any, ::AbstractArray{Bool,1}, ::Any, ::Any)
  ...
@gragusa gragusa changed the title sparse sparse constructor misbehaving on master Jul 31, 2015
@IainNZ IainNZ added the sparse Sparse arrays label Jul 31, 2015
@jiahao
Copy link
Member

jiahao commented Jul 31, 2015

This is yet another manifestation of [] being None[] on 0.3 and Any[] on 0.4, similar to #12271

@gragusa
Copy link
Contributor Author

gragusa commented Jul 31, 2015

Yes, indeed:

On 0.4.0-dev+6402

julia> sparse(Int[], Int[], [1], 0, 0, vcat)
0x0 sparse matrix with 0 Int64 entries:```

@jakebolewski
Copy link
Member

This is because Vector{None} <: Vector{Integer}. The <: Integer requirement will likely be relaxed in v0.5.

See also #12567

@Sacha0
Copy link
Member

Sacha0 commented Jun 27, 2016

What should happen here?

That sparse([], [], [1], 0, 0, vcat) returns a MethodError seems appropriate, Any not being a subtype of Integer. Additionally, were the Any[]s passed in promoted to T[] where T<:Integer, shouldn't that call still fail as sparse's first three arguments (I,J,V) must have equal length when they are vectors? Best!

@tkelman
Copy link
Contributor

tkelman commented Jun 29, 2016

Yeah I think 0.3's sparse may have been a bit too permissive. Closing, don't think there's a bug here any more.

@tkelman tkelman closed this as completed Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

6 participants