Skip to content

Commit

Permalink
Preserve Float type for Periodic Kernel (#560)
Browse files Browse the repository at this point in the history
* 0.5d -> d/2 change for kappa function of periodic kernel

* test added

* strip trailing whitespace

* Update test/basekernels/periodic.jl

Co-authored-by: David Widmann <[email protected]>

---------

Co-authored-by: David Widmann <[email protected]>
Co-authored-by: Will Tebbutt <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7389f31 commit ab866b9
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "KernelFunctions"
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
version = "0.10.63"
version = "0.10.64"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
2 changes: 1 addition & 1 deletion src/basekernels/periodic.jl
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ PeriodicKernel(T::DataType, dims::Int=1) = PeriodicKernel(; r=ones(T, dims))

metric::PeriodicKernel) = Sinus.r)

kappa(::PeriodicKernel, d::Real) = exp(-0.5d)
kappa(::PeriodicKernel, d::Real) = exp(-d / 2)

function Base.show(io::IO, κ::PeriodicKernel)
return print(io, "Periodic Kernel, length(r) = $(length.r))")
1 change: 1 addition & 0 deletions test/basekernels/periodic.jl
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
@test k(v1, v2) exp(-0.5 * sum(abs2, sinpi.(v1 - v2) ./ r))
@test k(v1, v2) == k(v2, v1)
@test PeriodicKernel(3)(v1, v2) == PeriodicKernel(; r=ones(3))(v1, v2)
@test PeriodicKernel(; r=Float32.(r))(Float32.(v1), Float32.(v2)) isa Float32
@test repr(k) == "Periodic Kernel, length(r) = $(length(r))"

# Standardised tests.

2 comments on commit ab866b9

@willtebbutt
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/111490

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.64 -m "<description of version>" ab866b919104db952ead4a18d07cf40b7ffc27a6
git push origin v0.10.64

Please sign in to comment.