{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/18271","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/18271/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18271/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/18271/events","html_url":"https://github.com/JuliaLang/julia/issues/18271","id":173658092,"number":18271,"title":"BoundsError when indexing an array with 2d bit array","user":{"login":"mmagnuski","id":8452354,"avatar_url":"https://avatars.githubusercontent.com/u/8452354?v=3","gravatar_id":"","url":"https://api.github.com/users/mmagnuski","html_url":"https://github.com/mmagnuski","followers_url":"https://api.github.com/users/mmagnuski/followers","following_url":"https://api.github.com/users/mmagnuski/following{/other_user}","gists_url":"https://api.github.com/users/mmagnuski/gists{/gist_id}","starred_url":"https://api.github.com/users/mmagnuski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmagnuski/subscriptions","organizations_url":"https://api.github.com/users/mmagnuski/orgs","repos_url":"https://api.github.com/users/mmagnuski/repos","events_url":"https://api.github.com/users/mmagnuski/events{/privacy}","received_events_url":"https://api.github.com/users/mmagnuski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-08-28T17:43:06Z","updated_at":"2016-09-09T15:31:21Z","closed_at":null,"body":"The code below:\r\n```julia\r\nA = rand((5, 5))\r\nb = mean(A, 1) .> 0.5\r\nA[:, b]\r\n```\r\nproduces the following error on julia-0.5.0-rc3:\r\n```\r\nERROR: BoundsError: attempt to access 5×5 Array{Float64,2} at index [Colon(),Bool[true true false true false]]\r\n in throw_boundserror(::Array{Float64,2}, ::Tuple{Colon,BitArray{2}}) at .\\abstractarray.jl:355\r\n in checkbounds at .\\abstractarray.jl:284 [inlined]\r\n in _getindex at .\\multidimensional.jl:264 [inlined]\r\n in getindex(::Array{Float64,2}, ::Colon, ::BitArray{2}) at .\\abstractarray.jl:752\r\n```\r\n\r\nThis used to work on julia 0.4 - is the change intended? \r\nDoing `A[:, vec(b)]` works of course."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/245948241","html_url":"https://github.com/JuliaLang/julia/issues/18271#issuecomment-245948241","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18271","id":245948241,"user":{"login":"mbauman","id":154641,"avatar_url":"https://avatars.githubusercontent.com/u/154641?v=3","gravatar_id":"","url":"https://api.github.com/users/mbauman","html_url":"https://github.com/mbauman","followers_url":"https://api.github.com/users/mbauman/followers","following_url":"https://api.github.com/users/mbauman/following{/other_user}","gists_url":"https://api.github.com/users/mbauman/gists{/gist_id}","starred_url":"https://api.github.com/users/mbauman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbauman/subscriptions","organizations_url":"https://api.github.com/users/mbauman/orgs","repos_url":"https://api.github.com/users/mbauman/repos","events_url":"https://api.github.com/users/mbauman/events{/privacy}","received_events_url":"https://api.github.com/users/mbauman/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T15:31:21Z","updated_at":"2016-09-09T15:31:21Z","body":"Thanks for reporting it, @mmagnuski! It's not something I intended to break.\r\n\r\nAdding support for things like `A[A[:, :, 1] .> 0, 1]` is definitely something I'd like to see, but unfortunately I think it's at odds with ignoring the singleton dimensions.  On the plus side, it's really easy to implement since we now support vectors of `CartesianIndex`s:\r\n\r\n```jl\r\nfunction findcartesian{N}(B::AbstractArray{Bool,N})\r\n    idxs = Vector{CartesianIndex{N}}()\r\n    for i in CartesianRange(size(B))\r\n        B[i] && push!(idxs, i)\r\n    end\r\n    idxs\r\nend\r\n\r\njulia> A = rand(-5:5, 4, 3, 2)\r\n4×3×2 Array{Int64,3}:\r\n[:, :, 1] =\r\n  4   1   0\r\n  0  -2   5\r\n  0  -1   3\r\n -1  -3  -3\r\n\r\n[:, :, 2] =\r\n  5  -2   4\r\n -3  -4  -4\r\n -2  -3   5\r\n -5  -2   0\r\n\r\njulia> A[findcartesian(A[:,:,1] .> 0), 1] += 10;\r\n       A\r\n4×3×2 Array{Int64,3}:\r\n[:, :, 1] =\r\n 14  11   0\r\n  0  -2  15\r\n  0  -1  13\r\n -1  -3  -3\r\n\r\n[:, :, 2] =\r\n  5  -2   4\r\n -3  -4  -4\r\n -2  -3   5\r\n -5  -2   0\r\n```"}}
{"actor":{"display_login":"mbauman"}}