RandomMatrices.jl
RandomMatrices.jl copied to clipboard
fix randomgrowth.jl
This is a julia bug?
julia> G = rand(100,100);
julia> G[G .== 0.5] = 1
ERROR: MethodError: no method matching setindex_shape_check(::Int64, ::Int64)
Closest candidates are:
setindex_shape_check(::AbstractArray{#s72,1} where #s72, ::Integer) at indices.jl:218
setindex_shape_check(::AbstractArray{#s72,1} where #s72, ::Integer, ::Integer) at indices.jl:221
setindex_shape_check(::AbstractArray{#s72,2} where #s72, ::Integer, ::Integer) at indices.jl:225
...
Stacktrace:
[1] macro expansion at ./multidimensional.jl:694 [inlined]
[2] _unsafe_setindex!(::IndexLinear, ::Array{Float64,2}, ::Int64, ::Base.LogicalIndex{Int64,BitArray{2}}) at ./multidimensional.jl:689
[3] _setindex! at ./multidimensional.jl:684 [inlined]
[4] setindex!(::Array{Float64,2}, ::Int64, ::BitArray{2}) at ./abstractarray.jl:1020
[5] top-level scope at none:0
this patch includes a workaround.
Great, though you can also do:
julia> G = rand(100,100);
julia> G[G .== 0.5] .= 1
0-element view(::Array{Float64,1}, Int64[]) with eltype Float64
Ah that's much better.