Skip to content

Commit

Permalink
Merge pull request #50 from mcabbott/linear
Browse files Browse the repository at this point in the history
Fix linear indexing
  • Loading branch information
mcabbott authored Feb 20, 2021
2 parents 77cca56 + 62fd77f commit fac28cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ for (get_or_view, key_get, maybe_copy) in [
KeyedArray(data, new_keys)
end

# drop all, for A[:] and A[A .> 0] with ndims>=2
# drop all, for A[:] or A[A .> 0] or A[1:2], with ndims>=2
@inline $key_get(keys::Tuple{Any, Any, Vararg{Any}}, inds::Tuple{Base.LogicalIndex}) = ()
@inline $key_get(keys::Tuple{Any, Any, Vararg{Any}}, inds::Tuple{Base.Slice}) = ()
@inline $key_get(keys::Tuple{Any, Any, Vararg{Any}}, inds::Tuple{AbstractVector{<:Integer}}) = ()

# drop one, for integer index
@inline $key_get(keys::Tuple, inds::Tuple{Integer, Vararg{Any}}) =
Expand Down
3 changes: 2 additions & 1 deletion test/_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ using Test, AxisKeys
@test (R[2,:] .= 1:4) isa SubArray # dotview
@test R[2,:] == KeyedArray(1:4, (10:10:40,))

@test R[:] == vec(R.data)
@test R[1:end] == R[:] == vec(R.data)
@test R[1:end] isa Vector # issue #48
@test R[1:2, 1, 1] == R.data[1:2, 1, 1]
@test axiskeys(R[:, [0.9,0.1,0.9,0.1] .> 0.5],2) == [10,30]
@test ndims(R[R .> 0.5]) == 1
Expand Down

2 comments on commit fac28cb

@mcabbott
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/30481

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.12 -m "<description of version>" fac28cbcd97fda791163a489f70c8dd83bbcee75
git push origin v0.1.12

Please sign in to comment.