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

test utils revamp #159

Merged
merged 41 commits into from
Sep 25, 2020
Merged

test utils revamp #159

merged 41 commits into from
Sep 25, 2020

Conversation

willtebbutt
Copy link
Member

@willtebbutt willtebbutt commented Aug 30, 2020

Introduces and applies a large number of consistency tests.

The advantage of running these tests is that we can be fairly sure that new kernels are at least self-consistent, and fully implement our interface.

The advantage of producing a new TestUtils module is that if someone implements a new kernel outside of KernelFunctions, they can straightforwardly test that the kernel obeys our interface.

This can't be merged until the following PRs are merged:

Copy link
Member

@sharanry sharanry left a comment

Choose a reason for hiding this comment

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

I was going through this to understand the new testing strategy. Looks great! But, have a few doubts. :)

src/test_utils.jl Outdated Show resolved Hide resolved
src/test_utils.jl Show resolved Hide resolved
src/test_utils.jl Outdated Show resolved Hide resolved
src/test_utils.jl Outdated Show resolved Hide resolved
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
theogf
theogf previously approved these changes Sep 8, 2020
@willtebbutt willtebbutt changed the title WIP: test utils revamp test utils revamp Sep 21, 2020
@willtebbutt
Copy link
Member Author

Moved some tests back to test/test_utils.jl because they introduce additional deps, and I would like to avoid this.

@willtebbutt
Copy link
Member Author

willtebbutt commented Sep 21, 2020

@theogf could you comment on the GammaRationalQuadraticKernel implementation? It appears to suffer from the same issues that the GammaExponentialKernel had prior to #158 , and was recently mentioned in #170 .

What are your thoughts on how it should be modified? Currently the test produce covariance matrices with negative eigenvalues, so something needs to be modified. Would you mind taking a look?

I believe that it becomes correct if we just use the Euclidean metric, rather than SqEuclidean.

@willtebbutt
Copy link
Member Author

@theogf what are your thoughts on this? Note that I've rejected your previous review because I've made changes to RationalQuadratic that need another round of review 🙂

src/test_utils.jl Outdated Show resolved Hide resolved
src/test_utils.jl Outdated Show resolved Hide resolved
Copy link
Member

@theogf theogf left a comment

Choose a reason for hiding this comment

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

I just put a few comments (sorry for the single comments, I messed up).

You really did an amazing titan job! That looks really good!

Also should we have tests on test_utils itself? Making sure that it goes wrong for a wrongly defined kernel?

src/test_utils.jl Outdated Show resolved Hide resolved
src/transform/lineartransform.jl Show resolved Hide resolved
atol=__ATOL,
)
# TODO: uncomment the tests of ternary kerneldiagmatrix.

Copy link
Member

Choose a reason for hiding this comment

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

This might be too much but maybe adding some printing for each of the test would give some nice feedback to the user and avoid stalling in Travis?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I'm reluctant to do this in this PR. The user has plenty of feedback when the tests fail in the way that the test sets are printed, and I personally prefer to minimise output during the running of tests.

test/basekernels/fbm.jl Show resolved Hide resolved
test/basekernels/gabor.jl Show resolved Hide resolved
test/kernels/kernelsum.jl Outdated Show resolved Hide resolved
willtebbutt and others added 5 commits September 24, 2020 12:53
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
Co-authored-by: Théo Galy-Fajou <theo.galyfajou@gmail.com>
@willtebbutt
Copy link
Member Author

For some reason I can't reply to this directly:

Has this issue been solved? That would be great to avoid the allocation

No, unfortunately not. Would you be open to me opening a separate issue about it and pressing ahead with getting this PR merged?

@willtebbutt
Copy link
Member Author

Also should we have tests on test_utils itself? Making sure that it goes wrong for a wrongly defined kernel?

Hmmm maybe. As with the above, I wonder whether we could postpone this to a future PR where we introduce some proper test fakes or something? This is already quite large :S

@willtebbutt
Copy link
Member Author

Hmmm maybe. As with the above, I wonder whether we could postpone this to a future PR where we introduce some proper test fakes or something? This is already quite large :S

@theogf thoughts on this? (Sorry for being pushy -- just keen to get this merged so that I can press ahead with my Stheno.jl / TemporalGPs.jl integration plan)

@theogf
Copy link
Member

theogf commented Sep 25, 2020

Sorry yeah sure, we can do this later! Let's just keep an issue open for this

@willtebbutt
Copy link
Member Author

Sorry yeah sure, we can do this later! Let's just keep an issue open for this

Great. I'll open an issue about those two things. Then we're good to go?

This was referenced Sep 25, 2020
@willtebbutt
Copy link
Member Author

If someone is happy to approve, I'll get this merged after a patch bump.

src/basekernels/rationalquad.jl Outdated Show resolved Hide resolved
@@ -1,48 +1,62 @@
"""
RationalQuadraticKernel(; α = 2.0)
RationalQuadraticKernel(; α=2.0)
Copy link
Member

Choose a reason for hiding this comment

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

Is it common to use α = 2? Something like α = 1 seems simpler, and is actually used as the default value by e.g. scikit-learn.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm good question. I really hadn't thought too much about this and wasn't overly fussed. I worry that 1 will yield a kernel with very long-range correlations (I'm just thinking about what a students-t with dof 1 looks like -- I think they coincide in this case).

I can't say that I'm overly fussed overall, so happy to change to 1 from 2 if you would prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong opinion on this, so do whatever you think is more reasonable. Just noticed this when I compared it with the parameter choices in scikit-learn, and was wondering why we use 2 here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'm going to leave as-is for the sake of this PR. More than happy for this to be changed in a subsequent PR though.

@check_args(GammaRationalQuadraticKernel, α, α > one(Tα), "α > 1")
@check_args(GammaRationalQuadraticKernel, γ, γ >= one(Tγ), "γ >= 1")
function GammaRationalQuadraticKernel(
;alpha::Tα=2.0, gamma::Tγ=2.0, α::Tα=alpha, γ::Tγ=gamma,
Copy link
Member

Choose a reason for hiding this comment

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

I guess

Suggested change
;alpha::Tα=2.0, gamma::Tγ=2.0, α::Tα=alpha, γ::Tγ=gamma,
;alpha::Tα=2.0, gamma::Tγ=2, α::Tα=alpha, γ::Tγ=gamma,

would be more performant in the default case? The question here is also if we should use alpha = 1 as
default value.

Copy link
Member

Choose a reason for hiding this comment

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

Although probably, since we divide gamma by 2 anyway in the computation it doesn't matter.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm I wonder whether this is what you want. Generally speaking, if you're using this kernel you probably don't want the Integer parameter value, otherwise you would be using the RationalQuadraticKernel. My opinion is that making this parameter a float by default probably does make sense as a consequence of this.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense.

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.

None yet

4 participants