-
Notifications
You must be signed in to change notification settings - Fork 34
Overload == and isequal for checking equality of Terms and Schemas #174
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
base: master
Are you sure you want to change the base?
Changes from all commits
0a6d78d
1ca55c0
e6f8b87
2f03a7c
ef367d7
993829b
ee16796
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,47 @@ | ||
@testset "schemas" begin | ||
|
||
using StatsModels: schema, apply_schema, FullRank | ||
|
||
f = @formula(y ~ 1 + a + b + c + b&c) | ||
df = (y = rand(9), a = 1:9, b = rand(9), c = repeat(["d","e","f"], 3)) | ||
f = @formula(y ~ 1 + a + log(b) + c + b & c) | ||
y = rand(9) | ||
b = rand(9) | ||
|
||
df = (y = y, a = 1:9, b = b, c = repeat(["d", "e", "f"], 3)) | ||
f = apply_schema(f, schema(f, df)) | ||
@test f == apply_schema(f, schema(f, df)) | ||
|
||
df2 = (y = y, a = 1:9, b = b, c = [df.c; df.c]) | ||
df3 = (y = y, a = 1:9, b = b, c = repeat(["a", "b", "c"], 3)) | ||
df4 = (y = [df.y; df.y], a = [1:9; 1:9], b = [b; b], c = [df.c; df.c]) | ||
df5 = (z = y, a = 1:9, b = b, c = repeat(["d", "e", "f"], 3)) | ||
df6 = (y = y, a = 2:10, b = b, c = repeat(["a", "b", "c"], 3)) | ||
df7 = (w = y, d = 1:9, x = b, z = repeat(["d", "e", "f"], 3)) | ||
df8 = (y = y, a = 1:9, c = repeat(["d", "e", "f"], 3)) | ||
|
||
sch = schema(df, Dict(:c => DummyCoding(base="e"))) | ||
sch2 = schema(df, Dict(:c => EffectsCoding(base="e"))) | ||
|
||
@test schema(df) == schema(df2) | ||
@test apply_schema(f, schema(df)) == apply_schema(f, schema(df2)) | ||
@test schema(df) != schema(df3) | ||
@test schema(df) != schema(df4) | ||
@test schema(df) != schema(df5) | ||
@test schema(df) != schema(df6) | ||
@test schema(df) != schema(df7) | ||
@test schema(df) != schema(df8) | ||
@test schema(df8) != schema(df) | ||
@test apply_schema(f, schema(df)) == apply_schema(f, schema(df5)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First I was confused because |
||
@test sch != sch2 | ||
|
||
@test isequal(schema(df), schema(df2)) | ||
kleinschmidt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@test isequal(apply_schema(f, schema(df)), apply_schema(f, schema(df2))) | ||
@test !isequal(schema(df), schema(df3)) | ||
@test !isequal(schema(df), schema(df4)) | ||
@test !isequal(schema(df), schema(df5)) | ||
@test !isequal(schema(df), schema(df6)) | ||
@test !isequal(schema(df), schema(df7)) | ||
@test !isequal(schema(df), schema(df8)) | ||
@test !isequal(schema(df8), schema(df)) | ||
@test isequal(apply_schema(f, schema(df)), apply_schema(f, schema(df5))) | ||
@test !isequal(sch, sch2) | ||
|
||
end |
Uh oh!
There was an error while loading. Please reload this page.