-
Notifications
You must be signed in to change notification settings - Fork 370
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
handle A ~ B - 1
and add tests
#1086
Conversation
@@ -40,6 +40,9 @@ type Terms | |||
intercept::Bool # is there an intercept column in the model matrix? | |||
end | |||
|
|||
import Base.== | |||
==(t1::Terms, t2::Terms) = all( getfield(t1, f)==getfield(t2, ) for f in fieldnames(t1)) |
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.
We don't seem to import
functions in this file.
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.
It's not strictly necessary, just a convenience for testing Terms
. I could move it to the test file?
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 just meant that you should write Base.:(==)(...) = ...
. Though I just noticed f
seems to be missing in getfield(t2, )
?
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.
That would explain the test failures :) I tried it without the import
first but didn't realize that Base.:(==)
was the right way to refer to ==
in that context, thanks.
a3 = dospecials(excp) | ||
if a1 == :- | ||
a2, a3 = excp.args[2:3] | ||
a3 == 1 || error("invalid expression $ex; subtraction only supported or -1") |
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.
or -> for
t = Terms(y ~ -1 + x1 + x2) | ||
@test t.intercept == false | ||
@test t.terms == [:x1, :x2] | ||
@test t == Terms(y ~ -1 + x1 + x2) == Terms(y ~ x1 - 1 + x2) == Terms(y ~ x1 + x2 -1) |
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.
Maybe also test for the error case?
Fixes #574.