-
Notifications
You must be signed in to change notification settings - Fork 32
PointMassFormConstraint exception for DirichletCollection + test #529
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: main
Are you sure you want to change the base?
Changes from all 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 | ||
---|---|---|---|---|
|
@@ -125,4 +125,12 @@ | |||
@test mean(result.posteriors[:θ]) ≈ p atol = 1e-1 | ||||
end | ||||
end | ||||
|
||||
Distributions.mode(d::DirichletCollection) = error("`mode` should not be called on DirichletCollection.") | ||||
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. You should not add new methods inside the tests
Suggested change
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. The reason for that is that tests are not being executed when using the package, tests are only executed by developers and not users. Thus if you attempt to add a new functionality inside tests the users will not actually get this functionality because they don't run tests |
||||
|
||||
@testset "`DirichletCollection` exception (mode is not defined)" begin | ||||
constraint = PointMassFormConstraint() | ||||
d = DirichletCollection(ones(3, 3)) | ||||
opt = constrain_form(constraint, d) | ||||
Comment on lines
+131
to
+134
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. Can you add a 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. Or if you want to test that this operation actually throws an error use 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. @ThijsJenneskens you can read about the differences here https://docs.julialang.org/en/v1/stdlib/Test/ |
||||
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.
I'm a bit confused, so why do we need this method if we test for exception such that the mode is not defined? The method above calls the
mode
but this one calls themean
?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 need this method because the mode is not defined for the Dirichlet Collection. I added the test such that, if a future change does end up calling the mode on a Dirichlet Collection random variable somehow, it's clear what goes wrong.