Skip to content

Commit

Permalink
Ensure TestFakes can return a KeyedArray (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Moynihan authored Apr 22, 2021
1 parent 5da6ca5 commit 43a2cc7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
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.4"
version = "0.3.5"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
10 changes: 5 additions & 5 deletions src/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ for C in (:OneToOne, :OneToMany, :ManyToOne, :ManyToMany)
end

function FeatureTransforms._apply(A, ::FakeOneToOneTransform; kwargs...)
return ones(size(A))
return replace(one, A)
end

function FeatureTransforms._apply(A, ::FakeOneToManyTransform; kwargs...)
return hcat(ones(size(A)), ones(size(A)))
return hcat(replace(one, A), replace(one, A))
end

function FeatureTransforms._apply(A, ::FakeManyToOneTransform; dims, kwargs...)
return ones(size(first(A)))
function FeatureTransforms._apply(A, ::FakeManyToOneTransform; kwargs...)
return replace(one, first(A))
end

function FeatureTransforms._apply(A, ::FakeManyToManyTransform; kwargs...)
return hcat(ones(size(A)), ones(size(A)))
return hcat(replace(one, A), replace(one, A))
end

"""
Expand Down
28 changes: 28 additions & 0 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ using FeatureTransforms.TestUtils

M = reshape(1:9, 3, 3)
@test FeatureTransforms.apply(M, t) == ones(3, 3)

# TODO: remove when refactoring tests
M = KeyedArray(M; a=["a", "b", "c"], b=[:x, :y, :z])
expected = KeyedArray(ones(3, 3); a=["a", "b", "c"], b=[:x, :y, :z])
result = FeatureTransforms.apply(M, t)
@test result == expected
@test result isa KeyedArray
end

@testset "FakeOneToManyTransform" begin
Expand All @@ -22,6 +29,13 @@ using FeatureTransforms.TestUtils

M = reshape(1:9, 3, 3)
@test FeatureTransforms.apply(M, t) == ones(3, 6)

# TODO: remove when refactoring tests
M = KeyedArray(M; a=["a", "b", "c"], b=[:x, :y, :z])
expected = KeyedArray(ones(3, 6); a=["a", "b", "c"], b=[:x, :y, :z, :x, :y, :z])
result = FeatureTransforms.apply(M, t)
@test result == expected
@test result isa KeyedArray
end

@testset "FakeManyToOneTransform" begin
Expand All @@ -33,6 +47,13 @@ using FeatureTransforms.TestUtils

M = reshape(1:9, 3, 3)
@test FeatureTransforms.apply(M, t; dims=1) == ones(3)

# TODO: remove when refactoring tests
M = KeyedArray(M; a=["a", "b", "c"], b=[:x, :y, :z])
expected = KeyedArray(ones(3); a=["a", "b", "c"])
result = FeatureTransforms.apply(M, t; dims=:b)
@test result == expected
@test result isa KeyedArray
end

@testset "FakeManyToManyTransform" begin
Expand All @@ -44,6 +65,13 @@ using FeatureTransforms.TestUtils

M = reshape(1:9, 3, 3)
@test FeatureTransforms.apply(M, t) == ones(3, 6)

# TODO: remove when refactoring tests
M = KeyedArray(M; a=["a", "b", "c"], b=[:x, :y, :z])
expected = KeyedArray(ones(3, 6); a=["a", "b", "c"], b=[:x, :y, :z, :x, :y, :z])
result = FeatureTransforms.apply(M, t)
@test result == expected
@test result isa KeyedArray
end


Expand Down

2 comments on commit 43a2cc7

@glennmoy
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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/35029

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.3.5 -m "<description of version>" 43a2cc74cb880d05e277b4267008c61a4ae165cb
git push origin v0.3.5

Please sign in to comment.