Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ on:
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: ${{ matrix.group }} - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
group:
- Basic
- JET
version:
- '1.6'
- '1'
Expand All @@ -20,7 +23,7 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand All @@ -37,6 +40,8 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
Expand All @@ -45,7 +50,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: '1'
Expand Down
2 changes: 2 additions & 0 deletions src/univariate/continuous/logitnormal.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: think of type piracy
# this is not in Distributions (which owns LogitNormal) because of dependency on optimize
mean(d::LogitNormal{T}; kwargs...) where {T} = T(estimateMean(d, kwargs...))

function mode(d::LogitNormal{T}) where {T}
Expand Down
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
71 changes: 22 additions & 49 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,53 +1,26 @@
using DistributionFits
using Test
using Random: Random
using LoggingExtras

#using Aqua; Aqua.test_all(DistributionFits) # ambiguities from other packages
#using JET; JET.report_package(DistributionFits) #
#invalid possible error due to quantile may accept/return an Array (we pass a scalar)
#only report problems in this module:
#using JET; JET.report_package(DistributionFits; target_modules=(@__MODULE__,)) #

@testset "optimize error" begin
@test_throws Exception DistributionFits.optimize(x -> x * x, -1, 1)
end
# Optim package for interactive testing
i_loadlibs = () -> begin
push!(LOAD_PATH, expanduser("~/julia/scimltools/")) # access local package repo
push!(LOAD_PATH, expanduser("~/julia/18_tools/scimltools/")) # access local package repo
tmpf = () -> begin
push!(LOAD_PATH, expanduser("~/julia/devtools/")) # access local pack
push!(LOAD_PATH, joinpath(pwd(), "test/")) # access local pack
end
using Optim: Optim, optimize

DistributionFitsOptimExt = isdefined(Base, :get_extension) ?
Base.get_extension(DistributionFits, :DistributionFitsOptimExt) :
DistributionFits.DistributionFitsOptimExt

@testset "optimize set in __init__ after using Optim" begin
# set in __init__
@test DistributionFits.df_optimizer isa DistributionFitsOptimExt.OptimOptimizer
using Test, SafeTestsets
const GROUP = get(ENV, "GROUP", "All") # defined in in CI.yml
@show GROUP

@time begin
if GROUP == "All" || GROUP == "Basic"
#@safetestset "Tests" include("test/test_optim.jl")
@time @safetestset "test_optim" include("test_optim.jl")
#@safetestset "Tests" include("test/fitstats.jl")
@time @safetestset "fitstats" include("fitstats.jl")
#@safetestset "Tests" include("test/univariate/test_univariate.jl")
@time @safetestset "test_univariate" include("univariate/test_univariate.jl")
end
if GROUP == "All" || GROUP == "JET"
#@safetestset "Tests" include("test/test_JET.jl")
@time @safetestset "test_JET" include("test_JET.jl")
#@safetestset "Tests" include("test/test_aqua.jl")
@time @safetestset "test_Aqua" include("test_aqua.jl")
end
end

#include("test/testutils.jl")
include("testutils.jl")

#include("test/fitstats.jl")
include("fitstats.jl")

#include("test/univariate/test_univariate.jl")
include("univariate/test_univariate.jl")

# test coverage of set_optimize (already called in init)

# print method ambiguities
println("Potentially stale exports: ")
display(Test.detect_ambiguities(DistributionFits))
println()

using JET: JET
@testset "JET" begin
@static if VERSION ≥ v"1.9.2"
JET.test_package(DistributionFits; target_modules=(@__MODULE__,)) #
end
end;

11 changes: 11 additions & 0 deletions test/test_JET.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using DistributionFits
using Test
using JET: JET

@testset "JET" begin
@static if VERSION ≥ v"1.9.2"
JET.test_package(DistributionFits; target_modules = (@__MODULE__,))
end
end;
# JET.report_package(DistributionFits) # to debug the errors
# JET.report_package(DistributionFits; target_modules=(@__MODULE__,)) # to debug the errors
23 changes: 23 additions & 0 deletions test/test_aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using DistributionFits
using Test
using Aqua

@testset "DistributionFits.jl" begin
@testset "Code quality (Aqua.jl)" begin
Aqua.test_all(
DistributionFits;
#unbound_args = false, # does not recognize NamedTuple{K, NTuple{N,E}}
stale_deps = (ignore = [:Requires],),
ambiguities = false, # ambiguities in StatsBase
piracies = false
)
end;
@testset "ambiguities package" begin
Aqua.test_ambiguities(DistributionFits;)
end;
@testset "pircacy" begin
Aqua.test_piracies(DistributionFits;
treat_as_own = [LogitNormal] # TODO
)
end;
end
21 changes: 21 additions & 0 deletions test/test_optim.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using DistributionFits
using Test

# before loading Optim
@testset "optimize error" begin
@test_throws Exception DistributionFits.optimize(x -> x * x, -1, 1)
end

# after loading Optim
using Optim: Optim, optimize

DistributionFitsOptimExt = isdefined(Base, :get_extension) ?
Base.get_extension(DistributionFits, :DistributionFitsOptimExt) :
DistributionFits.DistributionFitsOptimExt

@testset "optimize set in __init__ after using Optim" begin
# set in __init__
@test DistributionFits.df_optimizer isa DistributionFitsOptimExt.OptimOptimizer
end


13 changes: 12 additions & 1 deletion test/univariate/test_univariate.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
using DistributionFits
using Test
using Random: Random
using LoggingExtras
using Optim

pkgdir = dirname(dirname(pathof(DistributionFits)))
testdir = joinpath(pkgdir, "test")
include(joinpath(testdir,"testutils.jl"))

function test_univariate_fits(d, D = typeof(d))
@testset "fit moments" begin
if !occursin("fit(::Type{D}",
Expand Down Expand Up @@ -110,6 +120,7 @@ function test_univariate_fits(d, D = typeof(d))
end
end


const tests = [
"weibull",
"normal",
Expand All @@ -124,6 +135,6 @@ const tests = [
for t in tests
@testset "Test $t" begin
Random.seed!(345679)
include("continuous/$t.jl")
include(joinpath(testdir,"univariate","continuous","$t.jl"))
end
end