-
Notifications
You must be signed in to change notification settings - Fork 34
make InterceptTerm
s generate Bool
s to avoid unnecessary promotion of other columns
#294
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 4 commits
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 |
---|---|---|
|
@@ -402,5 +402,35 @@ | |
f = apply_schema(@formula(0 ~ a&b&c), schema(t)) | ||
@test vec(modelcols(f.rhs, t)) == modelcols.(Ref(f.rhs), Tables.rowtable(t)) | ||
end | ||
|
||
@testset "#293 conversion of Float32s" begin | ||
d = (; y=rand(Float32, 4), x=rand(Float32, 4), z=[1:4; ]) | ||
f = @formula(y ~ 1 + x + log(x) * z) | ||
y, x = modelcols(apply_schema(f, schema(d)), d) | ||
@test eltype(y) == eltype(x) == Float32 | ||
|
||
f0 = @formula(y ~ 0 + x + log(x) * z) | ||
y, x = modelcols(apply_schema(f0, schema(d)), d) | ||
@test eltype(y) == eltype(x) == Float32 | ||
|
||
fint = @formula(y ~ 1 + z) | ||
y, x = modelcols(apply_schema(fint, schema(d)), d) | ||
@test eltype(x) == Int | ||
|
||
contr = DummyCoding(; base=4, levels=1:4) | ||
d = (; y=rand(Float32, 4), x=rand(Float32, 4), z=[1:4; ]) | ||
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. this isn't yet used below, right? 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. it is used but it's redundant with the definition above... 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. oh wait the contr part? yeah that's right. |
||
|
||
# currently this is the best way to construct contrasts with Float32s... | ||
dummy_cmat = Float32[1 0 0 | ||
0 1 0 | ||
0 0 1 | ||
0 0 0] | ||
contr = StatsModels.ContrastsCoding(dummy_cmat, [1:4;]) | ||
|
||
sch = schema(f, d, Dict(:z => contr)) | ||
y, x = modelcols(apply_schema(f, sch), d) | ||
@test size(x) == (4, 1 + 1 + 1 + 3 + 3) | ||
@test eltype(x) == eltype(y) == Float32 | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to generate
BitArray
s here? I guess it doesn't matter much, but it would save some memory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd kinda hoped to be able to just use a scalar but hcat doesn't work with that