We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 76a3a3d + c9ad669 commit 1439262Copy full SHA for 1439262
src/core.jl
@@ -62,6 +62,7 @@ Base.unsafe_getindex(A::Axis, i...) = Base.unsafe_getindex(A, i...)
62
Base.eltype{_,T}(::Type{Axis{_,T}}) = eltype(T)
63
Base.size(A::Axis) = size(A.val)
64
Base.length(A::Axis) = length(A.val)
65
+@compat (A::Axis{name}){name}(i) = Axis{name}(i)
66
67
@doc """
68
An AxisArray is an AbstractArray that wraps another AbstractArray and
test/indexing.jl
@@ -55,6 +55,8 @@ B = AxisArray(reshape(1:15, 5,3), .1:.1:0.5, [:a, :b, :c])
55
@test B[Axis{:row}(Interval(0.15, 0.3))] == B[2:3,:]
56
57
A = AxisArray(reshape(1:256, 4,4,4,4), Axis{:d1}(.1:.1:.4), Axis{:d2}(1//10:1//10:4//10), Axis{:d3}(["1","2","3","4"]), Axis{:d4}([:a, :b, :c, :d]))
58
+ax1 = axes(A)[1]
59
+@test A[Axis{:d1}(2)] == A[ax1(2)]
60
@test A.data[1:2,:,:,:] == A[Axis{:d1}(Interval(.1,.2))] == A[Interval(.1,.2),:,:,:] == A[Interval(.1,.2),:,:,:,1] == A[Interval(.1,.2)]
61
@test A.data[:,1:2,:,:] == A[Axis{:d2}(Interval(1//10,2//10))] == A[:,Interval(1//10,2//10),:,:] == A[:,Interval(1//10,2//10),:,:,1] == A[:,Interval(1//10,2//10)]
@test A.data[:,:,1:2,:] == A[Axis{:d3}(["1","2"])] == A[:,:,["1","2"],:] == A[:,:,["1","2"],:,1] == A[:,:,["1","2"]]
0 commit comments