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

more small tests #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/combine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ ABdata[3:6,3:6,:,2] = Bdata
A1 = AxisArray(A1data, Axis{:X}(1:2), Axis{:Y}(1:2))
A2 = AxisArray(reshape(A2data, size(A2data)..., 1), Axis{:X}(1:2), Axis{:Y}(1:2), Axis{:Z}([:foo]))

@test_throws ArgumentError collapse(Val{1}, A1, AxisArray(A1data, Axis{:L}(1:4), Axis{:M}(1:5)))

@test @inferred(collapse(Val{2}, A1, A2)) == AxisArray(cat(3, A1data, A2data), Axis{:X}(1:2), Axis{:Y}(1:2), Axis{:collapsed}(AxisArrays.CategoricalVector([(1,), (2, :foo)])))
@test @inferred(collapse(Val{2}, A1)) == AxisArray(reshape(A1, 2, 2, 1), Axis{:X}(1:2), Axis{:Y}(1:2), Axis{:collapsed}(AxisArrays.CategoricalVector([(1,)])))
@test @inferred(collapse(Val{2}, A1)) == AxisArray(reshape(A1.data, size(A1)..., 1), axes(A1)..., Axis{:collapsed}(AxisArrays.CategoricalVector([(1,)])))
Expand Down
6 changes: 5 additions & 1 deletion test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ odd_inds = collect(1:2:length(A))
@test axes(A[vec(trues(A))]) == axes(A[all_inds])
@test @inferred(A[vec(isodd.(A))]) == A[1:2:length(A)] == A[odd_inds]
@test axes(A[vec(isodd.(A))]) == axes(A[odd_inds])

# setindex! for logical indices
AA = copy(A)
AA[vec(isodd.(A))] = 0.
@test AA[odd_inds] == zeros(odd_inds)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this method of zeros is deprecated

@test AA[2:2:length(AA)] == A[2:2:length(AA)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are you testing here? Did you mean to do:

AA[odd_inds] == A[2:2:length(AA)]

or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I'm checking that the even indexed items weren't modified.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh wow, sorry, I totally misread the second line!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries haha I absolutely cannot throw stones in this regard!


B = AxisArray(reshape(1:15, 5,3), .1:.1:0.5, [:a, :b, :c])

Expand Down
1 change: 1 addition & 0 deletions test/sortedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ A = AxisArray(reshape(1:16, 8, 2), v, [:a, :b])
# test StepRange indexing
@test v[1:2:8] == [1.0; 10.0; 12.0; 14.0]

@test AxisArrays.checkaxis(v) == nothing
# Test SortedVector with a hierarchical index (indexed using Tuples)
srand(1234)
data = reshape(1.:40., 20, 2)
Expand Down