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

Fix failing XArray tests #97

Merged
merged 5 commits into from
Jul 1, 2021
Merged
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: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FeatureTransforms"
uuid = "8fd68953-04b8-4117-ac19-158bf6de9782"
authors = ["Invenia Technical Computing Corporation"]
version = "0.3.6"
version = "0.3.7"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
5 changes: 3 additions & 2 deletions src/apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ the usual [`Transform`](@ref) being invoked.
function apply_append(A::AbstractArray, t; append_dim, kwargs...)::AbstractArray
result = apply(A, t; kwargs...)
result = _postformat(cardinality(t), result, A, append_dim)
return cat(A, result; dims=append_dim)
# Conver result to Array to avoid clashing axis/key names in concatenated result
return cat(A, Array(result); dims=append_dim)
end

"""
Expand Down Expand Up @@ -153,5 +154,5 @@ _postformat(::Cardinality, result, A, append_dim) = result
function _postformat(::ManyToOne, result, A, append_dim)
new_size = collect(size(A))
setindex!(new_size, 1, dim(A, append_dim))
return reshape(result, new_size...)
return copy(reshape(result, new_size...)) # return a copy to remove the reshape type
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AxisArrays
using AxisKeys
using Base: ReshapedArray
using DataFrames: DataFrame
using Dates
using Documenter: doctest
Expand Down
9 changes: 7 additions & 2 deletions test/types/matrix.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@testset "matrix" begin
# Want to test that certain subtypes of arrays are compatible
_make_matrix(::Type{Matrix}) = [1 2 3; 4 5 6]
_make_matrix(::Type{SubArray}) = view([1 2 3; 4 5 6], :, :)
_make_matrix(::Type{ReshapedArray}) = reshape([1 2 3; 4 5 6], 2, 3)

x = [1 2 3; 4 5 6]
@testset "$MatrixType" for MatrixType in (Matrix, SubArray, ReshapedArray)

x = _make_matrix(MatrixType)

@test is_transformable(x)

Expand Down
4 changes: 2 additions & 2 deletions test/types/xarray.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@testset "$ArrayType" for ArrayType in (AxisArray, KeyedArray)
@testset "$ArrayType" for ArrayType in (AxisArray, KeyedArray, NamedDimsArray)

x = ArrayType([1 2 3; 4 5 6], foo=["a", "b"], bar=[:x, :y, :z])

Expand Down Expand Up @@ -114,7 +114,7 @@

end

if ArrayType == KeyedArray
if ArrayType != AxisArray
@testset "indexing with dims" begin

T = FakeOneToOneTransform()
Expand Down