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

fix randomgrowth.jl #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

shashi
Copy link

@shashi shashi commented Sep 9, 2019

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.

@dlfivefifty
Copy link
Member

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

@shashi
Copy link
Author

shashi commented Sep 9, 2019

Ah that's much better.

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

Successfully merging this pull request may close these issues.

2 participants