From 155f78107606d418199afe103a69adedf594b408 Mon Sep 17 00:00:00 2001 From: "C. Brenhin Keller" Date: Thu, 13 Jun 2024 17:46:43 -0400 Subject: [PATCH] Remove VectorizedStatistics dependency --- Project.toml | 2 -- src/Chron.jl | 1 - src/Fitplot.jl | 6 +++--- src/Objects.jl | 10 +++++----- test/testCoupled.jl | 5 +++++ test/testDist.jl | 2 +- test/testRadiocarbon.jl | 4 ++++ test/testStratOnly.jl | 2 ++ 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Project.toml b/Project.toml index ec87949..5923e42 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,6 @@ ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" Reexport = "189a3867-3050-52da-a836-e630ba90ab69" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" StatGeochemBase = "61e559cd-58b4-4257-8528-26bb26ff2b9a" -VectorizedStatistics = "3b853605-1c98-4422-8364-4bd93ee0529e" [compat] DelimitedFiles = "1" @@ -29,5 +28,4 @@ ProgressMeter = "1" Reexport = "0.2, 1.0" SpecialFunctions = "0.10, 1, 2" StatGeochemBase = "0.5.9" -VectorizedStatistics = "0.5" julia = "1" diff --git a/src/Chron.jl b/src/Chron.jl index 06b1bcd..e47ccfb 100644 --- a/src/Chron.jl +++ b/src/Chron.jl @@ -21,7 +21,6 @@ module Chron using Reexport - @reexport using VectorizedStatistics @reexport using NaNStatistics @reexport using StatGeochemBase @reexport using Isoplot diff --git a/src/Fitplot.jl b/src/Fitplot.jl index da6af16..25ca482 100644 --- a/src/Fitplot.jl +++ b/src/Fitplot.jl @@ -219,7 +219,7 @@ smpl.Age_Distribution[i] = tmindist Age_Summary[i] = "$terupt" - l, u = vminimum(tmindist), vmaximum(tmindist) + l, u = nanminimum(tmindist), nanmaximum(tmindist) if isfinite(u-l) # Fit custom many-parametric distribution function to histogram binedges = range(l, u, length=101) @@ -231,8 +231,8 @@ # Initial guess for parameters p = ones(5) - p[2] = vmean(tmindist) - p[3] = vstd(tmindist) + p[2] = nanmean(tmindist) + p[3] = nanstd(tmindist) # Fit nonlinear model fobj = curve_fit(bilinear_exponential,bincenters,N,p) diff --git a/src/Objects.jl b/src/Objects.jl index 8980318..ceade79 100644 --- a/src/Objects.jl +++ b/src/Objects.jl @@ -115,11 +115,11 @@ agedistₜ = copy(agedist) StratAgeModel( heights, # Model heights - vmean(agedistₜ,dim=2), # Mean age - vstd(agedistₜ,dim=2), # Standard deviation - vmedian!(agedistₜ,dim=2), # Median age - vpercentile!(agedistₜ,2.5,dim=2), # 2.5th percentile - vpercentile!(agedistₜ,97.5,dim=2) # 97.5th percentile + nanmean(agedistₜ,dim=2), # Mean age + nanstd(agedistₜ,dim=2), # Standard deviation + nanmedian!(agedistₜ,dim=2), # Median age + nanpctile!(agedistₜ,2.5,dim=2), # 2.5th percentile + nanpctile!(agedistₜ,97.5,dim=2) # 97.5th percentile ) end diff --git a/test/testCoupled.jl b/test/testCoupled.jl index f7b60c7..34f6e9c 100644 --- a/test/testCoupled.jl +++ b/test/testCoupled.jl @@ -49,6 +49,7 @@ println("StratMetropolisDist:") @test mdl.Age_975CI ≈ [66.1, 66.09, 66.09, 66.08, 66.08, 66.07, 66.06, 66.05, 66.03, 66.01, 65.97, 65.97, 65.96, 65.96, 65.95] atol=0.15 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(lldist) == (config.nsteps,) @test !isnan(mean(lldist)) @@ -69,6 +70,7 @@ println("StratMetropolisDist with systematic uncertainties:") @test mdl.Age_975CI ≈ [66.1, 66.09, 66.09, 66.08, 66.08, 66.07, 66.06, 66.05, 66.03, 66.01, 65.97, 65.97, 65.96, 65.96, 65.95] atol=0.15 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(lldist) == (config.nsteps,) @test !isnan(mean(lldist)) @@ -92,6 +94,7 @@ println("StratMetropolisDist with hiata:") @test mdl.Age_975CI ≈ [66.11, 66.1, 66.1, 66.1, 66.1, 66.08, 66.08, 66.08, 66.08, 65.98, 65.96, 65.96, 65.96, 65.96, 65.95] atol=0.15 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(hiatusdist) == (nHiatuses, config.nsteps) @test mean(hiatusdist, dims=2) ≈ [0.064; 0.061;;] atol=0.3 @test size(lldist) == (config.nsteps,) @@ -115,6 +118,7 @@ println("StratMetropolisDist with fitted Gaussians:") @test mdl.Age_975CI ≈ [66.09, 66.09, 66.08, 66.08, 66.08, 66.07, 66.06, 66.05, 66.04, 66.02, 66.0, 65.99, 65.98, 65.97, 65.96] atol=0.15 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(lldist) == (config.nsteps,) @test !isnan(mean(lldist)) @@ -164,5 +168,6 @@ println("StratMetropolisDist, Pb-loss-aware:") @test mdl.Age_975CI ≈ [752.51, 752.47, 752.43, 752.37, 752.29, 752.2, 752.08, 751.85, 750.99] atol=0.7 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(lldist) == (config.nsteps,) @test !isnan(mean(lldist)) diff --git a/test/testDist.jl b/test/testDist.jl index 0754a63..cbaa81d 100644 --- a/test/testDist.jl +++ b/test/testDist.jl @@ -1,7 +1,7 @@ ## --- Test simple metropolis_min and metropolis_minmax functions mu, sigma = collect(100:0.1:101), 0.01*ones(11); - dist = MeltsVolcanicZirconDistribution ./ vmean(MeltsVolcanicZirconDistribution) + dist = MeltsVolcanicZirconDistribution ./ nanmean(MeltsVolcanicZirconDistribution) @test Chron.Isoplot.dist_ll(dist, mu, sigma, 100,101) ≈ -3.6933357793356576 tmindist = metropolis_min(2*10^5, dist, mu, sigma, burnin=10^5) diff --git a/test/testRadiocarbon.jl b/test/testRadiocarbon.jl index f9004f0..678abff 100644 --- a/test/testRadiocarbon.jl +++ b/test/testRadiocarbon.jl @@ -64,6 +64,7 @@ config.sieve = round(Int,npoints_approx) # Record one out of every nsieve steps @test mdl.Age_975CI ≈ [8405.0, 8386.1, 8347.1, 8163.5, 8151.0, 8123.9, 8029.5, 8016.3, 8003.0, 7985.9, 7958.2, 7916.3] atol=35 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test -Inf < mean(lldist) < 0 @@ -85,6 +86,7 @@ hiatus.Duration_sigma = [ 30.5, 20.0 ] @test mdl.Age_975CI ≈ [8408.06, 8394.94, 8231.34, 8159.62, 8147.76, 8123.97, 8054.25, 8039.57, 8025.91, 7918.86, 7907.9, 7889.46] atol=35 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(hiatusdist) == (nHiatuses, config.nsteps) @test mean(hiatusdist, dims=2) ≈ [108.4; 189.0;;] atol=20 @test -Inf < mean(lldist) < 0 @@ -136,6 +138,7 @@ config.sieve = round(Int,npoints_approx) # Record one out of every nsieve steps @test mdl.Age_975CI ≈ [8401.5, 8382.0, 8342.7, 8167.4, 8156.2, 8128.5, 8019.7, 8011.7, 8002.5, 7986.2, 7957.2, 7916.2] atol=40 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test -Inf < mean(lldist) < 0 @@ -157,6 +160,7 @@ hiatus.Duration_sigma = [ 30.5, 20.0 ] @test mdl.Age_975CI ≈ [8405.89, 8391.62, 8225.61, 8163.41, 8151.31, 8123.92, 8030.35, 8023.65, 8016.86, 7916.1, 7905.95, 7886.48] atol=40 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(hiatusdist) == (nHiatuses, config.nsteps) @test mean(hiatusdist, dims=2) ≈ [110.5; 187.3;;] atol=20 @test -Inf < mean(lldist) < 0 \ No newline at end of file diff --git a/test/testStratOnly.jl b/test/testStratOnly.jl index 18ae8d9..3aadd67 100644 --- a/test/testStratOnly.jl +++ b/test/testStratOnly.jl @@ -30,6 +30,7 @@ config.sieve = round(Int,npoints_approx) # Record one out of every nsieve steps @test mdl.Age_975CI ≈ [761.17, 757.98, 752.64, 733.57, 731.21, 728.07, 722.24, 720.59, 718.6, 716.11, 712.48, 704.28] atol=3 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test -Inf < mean(lldist) < 0 @test NamedTuple(mdl) isa NamedTuple @@ -52,6 +53,7 @@ hiatus.Duration_sigma = [ 3.1, 2.0 ] @test mdl.Age_975CI ≈ [761.77, 759.23, 741.37, 732.59, 730.64, 728.05, 723.52, 722.34, 720.9, 709.03, 706.78, 703.46] atol=3 # Test that all age-depth models are in stratigraphic order @test all([issorted(x, rev=true) for x in eachcol(agedist)]) +@test all(!isnan, agedist) @test size(hiatusdist) == (nHiatuses, config.nsteps) @test mean(hiatusdist, dims=2) ≈ [10.580012942504894; 18.96167245288326;;] atol=2 @test -Inf < mean(lldist) < 0 \ No newline at end of file