Skip to content

Commit

Permalink
Merge pull request #103 from JuliaGaussianProcesses/cleanup
Browse files Browse the repository at this point in the history
Add Aqua tests and clean up
  • Loading branch information
simsurace authored Mar 10, 2024
2 parents fccaf89 + 7ec0d36 commit 80a8f8f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GPLikelihoods"
uuid = "6031954c-0455-49d7-b3b9-3e1c99afaf40"
authors = ["JuliaGaussianProcesses Team"]
version = "0.4.6"
version = "0.4.7"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -23,6 +23,9 @@ FastGaussQuadrature = "0.4, 0.5"
Functors = "0.1, 0.2, 0.3, 0.4"
InverseFunctions = "0.1.2"
IrrationalConstants = "0.1, 0.2"
LinearAlgebra = "1"
Random = "1"
SpecialFunctions = "1, 2"
StatsFuns = "0.9.13, 1"
Test = "1"
julia = "1.6"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Codecov](https://codecov.io/gh/JuliaGaussianProcesses/GPLikelihoods.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGaussianProcesses/GPLikelihoods.jl)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

GPLikelihoods.jl provides a collection of likelihoods to be used as building
blocks for defining non-Gaussian problems. It is intended to be mainly
Expand Down
4 changes: 3 additions & 1 deletion src/expectations.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using FastGaussQuadrature: gausshermite
using FastGaussQuadrature: FastGaussQuadrature
using SpecialFunctions: loggamma
using ChainRulesCore: ChainRulesCore
using IrrationalConstants: sqrt2, invsqrtπ

gausshermite(n::Integer) = FastGaussQuadrature.gausshermite(n)

struct DefaultExpectationMethod end

struct AnalyticExpectation end
Expand Down
2 changes: 1 addition & 1 deletion src/likelihoods/bernoulli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ BernoulliLikelihood(l=logistic) = BernoulliLikelihood(link(l))

(l::BernoulliLikelihood)(f::Real) = Bernoulli(l.invlink(f))

(l::BernoulliLikelihood)(fs::AbstractVector{<:Real}) = Product(map(l, fs))
(l::BernoulliLikelihood)(fs::AbstractVector{<:Real}) = product_distribution(map(l, fs))
2 changes: 1 addition & 1 deletion src/likelihoods/categorical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ function (l::CategoricalLikelihood)(f::AbstractVector{<:Real})
return Categorical(l.invlink(f))
end

(l::CategoricalLikelihood)(fs::AbstractVector) = Product(map(l, fs))
(l::CategoricalLikelihood)(fs::AbstractVector) = product_distribution(map(l, fs))
2 changes: 1 addition & 1 deletion src/likelihoods/exponential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ExponentialLikelihood(l=exp) = ExponentialLikelihood(link(l))

(l::ExponentialLikelihood)(f::Real) = Exponential(l.invlink(f))

(l::ExponentialLikelihood)(fs::AbstractVector{<:Real}) = Product(map(l, fs))
(l::ExponentialLikelihood)(fs::AbstractVector{<:Real}) = product_distribution(map(l, fs))

function expected_loglikelihood(
::AnalyticExpectation,
Expand Down
2 changes: 1 addition & 1 deletion src/likelihoods/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GammaLikelihood(α::Real=1.0, l=exp) = GammaLikelihood(α, link(l))

(l::GammaLikelihood)(f::Real) = Gamma(l.α, l.invlink(f))

(l::GammaLikelihood)(fs::AbstractVector{<:Real}) = Product(map(l, fs))
(l::GammaLikelihood)(fs::AbstractVector{<:Real}) = product_distribution(map(l, fs))

function expected_loglikelihood(
::AnalyticExpectation,
Expand Down
4 changes: 3 additions & 1 deletion src/likelihoods/negativebinomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ end

@functor NegativeBinomialLikelihood

(l::NegativeBinomialLikelihood)(fs::AbstractVector{<:Real}) = Product(map(l, fs))
function (l::NegativeBinomialLikelihood)(fs::AbstractVector{<:Real})
return product_distribution(map(l, fs))
end

@doc raw"""
NBParamSuccess(successes)
Expand Down
2 changes: 1 addition & 1 deletion src/likelihoods/poisson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PoissonLikelihood(l=exp) = PoissonLikelihood(link(l))

(l::PoissonLikelihood)(f::Real) = Poisson(l.invlink(f))

(l::PoissonLikelihood)(fs::AbstractVector{<:Real}) = Product(map(l, fs))
(l::PoissonLikelihood)(fs::AbstractVector{<:Real}) = product_distribution(map(l, fs))

function expected_loglikelihood(
::AnalyticExpectation,
Expand Down
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -7,6 +8,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
Aqua = "0.8"
Distributions = "0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25"
Functors = "0.1, 0.2, 0.3, 0.4"
StatsFuns = "0.9, 1"
Expand Down
13 changes: 10 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using GPLikelihoods
using GPLikelihoods: GaussHermiteExpectation, MonteCarloExpectation
using GPLikelihoods.TestInterface: test_interface
using Test
using Random
using Functors

using Aqua
using Distributions
using Functors
using Random
using StatsFuns
using Test
using Zygote

@testset "GPLikelihoods.jl" begin
Expand All @@ -20,4 +22,9 @@ using Zygote
include("likelihoods/negativebinomial.jl")
end
include("expectations.jl")
@testset "Code quality (Aqua.jl)" begin
Aqua.test_all(GPLikelihoods; ambiguities=false)
# Ref https://github.com/JuliaTesting/Aqua.jl/issues/77
Aqua.test_ambiguities(GPLikelihoods; recursive=false)
end
end

2 comments on commit 80a8f8f

@simsurace
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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/102629

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.4.7 -m "<description of version>" 80a8f8f6b086758cf5778fbf35b0e11c21078f97
git push origin v0.4.7

Please sign in to comment.