-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Error using linear indexing #188
Comments
This one works julia> k[:].=a[:]
12-element SubArray{Float64,1,ArrayFire.AFArray{Float64,1},Tuple{Base.Slice{Base.OneTo{Int64}}},false}:
0.748611
0.262307
0.685377
0.985436
0.514791
0.273166
0.376666
0.860165
0.0209705
0.912038
0.262203
0.561497 |
In general mixing |
Error indexing by array: julia> k.>0.5
AFArray: 3×4 Array{Bool,2}:
true true false true
false false true false
false false false false
julia> k[k.>0.5]
ERROR: AssertionError: length(idx1) == length(size(a)) - 1
Stacktrace:
[1] getindex(::ArrayFire.AFArray{Float64,2}, ::ArrayFire.AFArray{Bool,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:73 |
duplicate: indexing is broken - #181 |
But the following gives error julia> k[:]
ERROR: AssertionError: length(idx1) == length(size(a)) - 1
Stacktrace:
[1] getindex(::ArrayFire.AFArray{Float64,2}, ::Colon) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:73
|
It's strange, assignment works but print doesn't: julia> k[find(k.>0.5)]
ERROR: AssertionError: length(idx1) == length(size(a)) - 1
Stacktrace:
[1] getindex(::ArrayFire.AFArray{Float64,2}, ::ArrayFire.AFArray{Int64,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:73
julia> k[find(k.>0.5)] = 0
0 |
No, it works for 1D array in #181 but not 2D: julia> k[find(k.>0.5)] = 0
0
julia> k
AFArray: 3×4 Array{Float64,2}:
0.790436 0.522505 0.333179 0.632241
0.751422 0.841604 0.715114 0.928544
0.884082 0.39492 0.654672 0.21895
|
Some more tests: julia> k[]
ERROR: ArrayFire Error (202) : Invalid input argument
In function af_err af_index_gen(void**, af_array, dim_t, const af_index_t*)
In file src/api/c/index.cpp:160
Invalid argument at index 2
Expected: (ndims>0)
Stacktrace:
[1] _error(::UInt32) at /home/phuoc/.julia/v0.6/ArrayFire/src/util.jl:85
[2] index_gen(::ArrayFire.AFArray{Float64,2}, ::Int64, ::Ptr{ArrayFire.af_index_t}) at /home/phuoc/.julia/v0.6/ArrayFire/src/wrap.jl:721
[3] getindex(::ArrayFire.AFArray{Float64,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:110
julia> k[1,:].>0.5
AFArray: 1×4 Array{Bool,2}:
true true false true
julia> k[:,k[1,:].>0.5]
AFArray: 3×3 Array{Float64,2}:
0.574376 0.984427 0.514344
0.460361 0.514912 0.416142
0.386582 0.525051 0.862911
julia> k[:,k[1,:].>0.5]=0
ERROR: ArrayFire Error (203) : Invalid input size
In function af_err af_assign_gen(void**, af_array, dim_t, const af_index_t*, af_array)
In file src/api/c/assign.cpp:311
Size mismatch between input and output
Stacktrace:
[1] _error(::UInt32) at /home/phuoc/.julia/v0.6/ArrayFire/src/util.jl:85
[2] assign_gen(::ArrayFire.AFArray{Float64,2}, ::Int64, ::Ptr{ArrayFire.af_index_t}, ::ArrayFire.AFArray{Float64,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:51
[3] setindex!(::ArrayFire.AFArray{Float64,2}, ::ArrayFire.AFArray{Float64,2}, ::Colon, ::ArrayFire.AFArray{Bool,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:120
[4] setindex!(::ArrayFire.AFArray{Float64,2}, ::Int64, ::Colon, ::ArrayFire.AFArray{Bool,2}) at /home/phuoc/.julia/v0.6/ArrayFire/src/indexing.jl:132
julia> k[:,k[1,:].>0.5].=0
ERROR: BoundsError: attempt to access 3×4 ArrayFire.AFArray{Float64,2} at index [Base.Slice(Base.OneTo(3)), Base.LogicalIndex(AFArray: Bool[true true false true])]
Stacktrace:
[1] throw_boundserror(::ArrayFire.AFArray{Float64,2}, ::Tuple{Base.Slice{Base.OneTo{Int64}},Base.LogicalIndex{CartesianIndex{2},ArrayFire.AFArray{Bool,2}}}) at ./abstractarray.jl:433
[2] checkbounds(::ArrayFire.AFArray{Float64,2}, ::Base.Slice{Base.OneTo{Int64}}, ::Base.LogicalIndex{CartesianIndex{2},ArrayFire.AFArray{Bool,2}}) at ./abstractarray.jl:362
[3] view(::ArrayFire.AFArray{Float64,2}, ::Colon, ::Vararg{Any,N} where N) at ./subarray.jl:113
[4] dotview(::ArrayFire.AFArray{Float64,2}, ::Colon, ::Vararg{Any,N} where N) at ./broadcast.jl:537
julia> pointer(k)
ERROR: conversion to pointer not defined for ArrayFire.AFArray{Float64,2}
Stacktrace:
[1] pointer(::ArrayFire.AFArray{Float64,2}) at ./abstractarray.jl:863
|
fixed in 92de2d9 |
Is it really fixed? I just tried it on the master.
|
Make sure you got the latest master from https://github.com/JuliaComputing/ArrayFire.jl , should work just fine even without
|
Oh, sorry. I was accidentally using your fork on the machine I used today. |
The text was updated successfully, but these errors were encountered: