Skip to content

Commit

Permalink
Reorganize custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jul 4, 2024
1 parent 8b185b3 commit 2978a8e
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/Objects.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## --- Custom objects for holding Chron age data
## --- Types to hold age constraints for age-depth modelling, before or after eruption age modelling

# Define a type of struct object to hold data about geochron samples from
# a region or stratigraphic section of interest
Expand Down Expand Up @@ -74,31 +74,8 @@
)
end

# A set of types to allow dispatch to different age sidedness methods
abstract type Sidedness end
struct CDFSidedness{T<:Real} <: Sidedness
s::Vector{T}
end
struct FastSidedness{T<:Real} <: Sidedness
s::Vector{T}
end
Base.getindex(A::Sidedness, args...) = getindex(A.s, args...)
Base.setindex!(A::Sidedness, args...) = setindex!(A.s, args...)
Base.eachindex(A::Sidedness) = eachindex(A.s)
Base.size(A::Sidedness, args...) = size(A.s, args...)
Base.length(A::Sidedness) = length(A.s)
Base.ndims(A::Sidedness) = ndims(A.s)
Base.ndims(::Type{<:Sidedness}) = 1
Base.copyto!(A::Sidedness, args...) = copyto!(A.s, args...)
## --- `HiatusData` type to hold data about hiatuses

# One-sigma systematic uncertainty
mutable struct SystematicUncertainty
UPb::Float64
ArAr::Float64
end
SystematicUncertainty() = SystematicUncertainty(NaN, NaN)

# A type of object to hold data about hiatuses
mutable struct HiatusData
Height::Vector{Float64}
Height_sigma::Vector{Float64}
Expand All @@ -119,18 +96,17 @@
)
end

# A type of object to specify the configuration of the stratigraphic model
## --- Types type to specify the configuration of and hold results from the stratigraphic age-depth model

mutable struct StratAgeModelConfiguration
resolution::Float64
burnin::Int
nsteps::Int
sieve::Int
bounding::Float64
end
StratAgeModelConfiguration() = StratAgeModelConfiguration(NaN, 0, 0, 0, NaN)

function StratAgeModelConfiguration()
StratAgeModelConfiguration(NaN, 0, 0, 0, NaN)
end
const NewStratAgeModelConfiguration = StratAgeModelConfiguration
export NewStratAgeModelConfiguration

Expand All @@ -156,4 +132,30 @@
)
end

Base.NamedTuple(mdl::StratAgeModel) = NamedTuple{fieldnames(typeof(mdl))}(ntuple(i->getfield(mdl, i), nfields(mdl)))
Base.NamedTuple(mdl::StratAgeModel) = NamedTuple{fieldnames(typeof(mdl))}(ntuple(i->getfield(mdl, i), nfields(mdl)))

## --- Types to allow dispatch to different age sidedness methods
abstract type Sidedness end
struct CDFSidedness{T<:Real} <: Sidedness
s::Vector{T}
end
struct FastSidedness{T<:Real} <: Sidedness
s::Vector{T}
end
# Forward all array-like methods to the wrapped vector
Base.getindex(A::Sidedness, args...) = getindex(A.s, args...)
Base.setindex!(A::Sidedness, args...) = setindex!(A.s, args...)
Base.eachindex(A::Sidedness) = eachindex(A.s)
Base.size(A::Sidedness, args...) = size(A.s, args...)
Base.length(A::Sidedness) = length(A.s)
Base.ndims(A::Sidedness) = ndims(A.s)
Base.ndims(::Type{<:Sidedness}) = 1
Base.copyto!(A::Sidedness, args...) = copyto!(A.s, args...)

## --- Types to allow specification of systematic uncertainties

mutable struct SystematicUncertainty
UPb::Float64
ArAr::Float64
end
SystematicUncertainty() = SystematicUncertainty(NaN, NaN)

2 comments on commit 2978a8e

@brenhinkeller
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register
Release notes:

  • Allow switching between fast approximate and slower CDF-based handling of one-sided constraints

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

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.6.0 -m "<description of version>" 2978a8ee1482b88adcbbeb3bd008e0f351e978ba
git push origin v0.6.0

Please sign in to comment.