Skip to content

Commit

Permalink
Remove VectorizedStatistics dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jun 13, 2024
1 parent d343cc0 commit 155f781
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
1 change: 0 additions & 1 deletion src/Chron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
module Chron

using Reexport
@reexport using VectorizedStatistics
@reexport using NaNStatistics
@reexport using StatGeochemBase
@reexport using Isoplot
Expand Down
6 changes: 3 additions & 3 deletions src/Fitplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/Objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions test/testCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand All @@ -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,)
Expand All @@ -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))

Expand Down Expand Up @@ -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))
2 changes: 1 addition & 1 deletion test/testDist.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/testRadiocarbon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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
2 changes: 2 additions & 0 deletions test/testStratOnly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 155f781

Please sign in to comment.