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

Refactor tests to test types and transform functionality separately #84

Merged
merged 13 commits into from
Jun 28, 2021

Conversation

glennmoy
Copy link
Member

@glennmoy glennmoy commented Apr 20, 2021

Note: I wrote the individual testsets for each data type before going around and removing them from each transform. In some cases this removed all the code so I left behind some unit tests specific to the transform.

In a follow up PR or commit I'd like to refactor the transform tests, but that is out of scope for this PR.

@glennmoy glennmoy changed the base branch from main to gm/transformable April 20, 2021 13:46
Base automatically changed from gm/transformable to main April 20, 2021 15:02
@glennmoy glennmoy force-pushed the gm/refactor_tests branch from c50301e to a8c8616 Compare April 20, 2021 19:54
@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #84 (135e533) into main (5da6ca5) will decrease coverage by 0.00%.
The diff coverage is n/a.

❗ Current head 135e533 differs from pull request most recent head 00376b7. Consider uploading reports for the commit 00376b7 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main      #84      +/-   ##
==========================================
- Coverage   99.25%   99.25%   -0.01%     
==========================================
  Files          12       12              
  Lines         135      134       -1     
==========================================
- Hits          134      133       -1     
  Misses          1        1              
Impacted Files Coverage Δ
src/test_utils.jl 100.00% <0.00%> (ø)
src/one_hot_encoding.jl 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5da6ca5...00376b7. Read the comment docs.

@glennmoy glennmoy force-pushed the gm/refactor_tests branch 3 times, most recently from c56a1a1 to 0d2e038 Compare June 18, 2021 17:19
@glennmoy glennmoy requested a review from bencottier June 18, 2021 22:15
@glennmoy glennmoy changed the title WIP: refactor tests Refactor tests to test types and transform functionality separately Jun 21, 2021
@glennmoy
Copy link
Member Author

Not sure why tests are failing considering #93 (which is branched from this) are passing ...

Copy link
Contributor

@bencottier bencottier left a comment

Choose a reason for hiding this comment

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

LGTM. Nice job. -1000+ lines 🤤

test/types/tables.jl Outdated Show resolved Hide resolved
test/types/tables.jl Show resolved Hide resolved
test/types/vector.jl Outdated Show resolved Hide resolved

@testset "ManyToOne" begin
T = FakeManyToOneTransform()
@test FeatureTransforms.apply(x, T; dims=1) == ones(3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does a ManyToOne transform work without dims as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

nope, _preformat expects it not to be Colon()

julia> T = FakeManyToOneTransform()
FakeManyToOneTransform()

julia> A  = ones(4, 3);

julia> T(A)
ERROR: MethodError: no method matching length(::Colon)

test/types/cube.jl Outdated Show resolved Hide resolved

@testset "OneToOne" begin
T = FakeOneToOneTransform()
@test FeatureTransforms.apply(x, T) == ones(2, 3)
Copy link
Contributor

Choose a reason for hiding this comment

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

These transforms don't preserve type?

Copy link
Member Author

Choose a reason for hiding this comment

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

it does in general, and reminder that

julia> KA = KeyedArray(ones(3, 5), features=[:a, :b, :c], time=1:5);

julia> KA == ones(3, 5)

but as usual AxisArrays breaks the mould, and any operation on them doesn't return an AxisArray anyway

julia> A
2-dimensional AxisArray{Int64,2,...} with axes:
    :foo, ["a", "b"]
    :bar, [:x, :y, :z]
And data, a 2×3 Matrix{Int64}:
 1  2  3
 4  5  6

julia> A .^ 3
2×3 Matrix{Int64}:
  1    8   27
 64  125  216

julia> A .+ 1
2×3 Matrix{Int64}:
 2  3  4
 5  6  7

another reason to drop it

test/types/xarray.jl Show resolved Hide resolved

end

if ArrayType == KeyedArray
Copy link
Contributor

Choose a reason for hiding this comment

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

I forget, are there issues with AxisArray here? Or are you just not bothering?

Copy link
Member Author

Choose a reason for hiding this comment

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

The dims syntax for AxisArrays expects an Axis type not a Symbol so it's incompatible with our interface unless we call axisdim(A, Axis{:foo}) or something to extract the dimension index.

Something we could do maybe to support this without depending on AxisArrays is:

if hasfield(A, axes)
    dims = only(findall(a -> a == dims || typeof(a) <: dims, A.axes))
end

but I'd prefer to implement that at a later time if we actually need it (and I'd almost prefer to drop AxisArrays than do that).

@glennmoy glennmoy force-pushed the gm/refactor_tests branch from 0d2e038 to 00376b7 Compare June 28, 2021 18:03
@glennmoy
Copy link
Member Author

I'm gonna force merge this even though tests aren't passing - I'm not sure what's going on but they are passing over in #93 so they should at least be fixed with those.

@glennmoy glennmoy merged commit 1b023b1 into main Jun 28, 2021
@glennmoy glennmoy deleted the gm/refactor_tests branch June 28, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants