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

Ensure TestFakes can return a KeyedArray #85

Merged
merged 1 commit into from
Apr 22, 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.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
Copy link
Member Author

Choose a reason for hiding this comment

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

I've already started this #84

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