From 2291de1cc7a33bc9cafe7ed3dca81d42206b1466 Mon Sep 17 00:00:00 2001 From: Stuart Daines Date: Mon, 30 Dec 2024 20:33:39 +0000 Subject: [PATCH] really remove CommonDataModelExt --- Project cdm.toml | 71 ------ .../CommonDataModelExt/CommonDataModelExt.jl | 93 -------- src/Types cdm2.jl | 222 ------------------ 3 files changed, 386 deletions(-) delete mode 100644 Project cdm.toml delete mode 100644 ext_hide/CommonDataModelExt/CommonDataModelExt.jl delete mode 100644 src/Types cdm2.jl diff --git a/Project cdm.toml b/Project cdm.toml deleted file mode 100644 index b374209..0000000 --- a/Project cdm.toml +++ /dev/null @@ -1,71 +0,0 @@ -name = "PALEOboxes" -uuid = "804b410e-d900-4b2a-9ecd-f5a06d4c1fd4" -authors = ["Stuart Daines "] -version = "0.22.0" - -[deps] -Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458" -BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" -DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" -Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" -Infiltrator = "5903a43b-9cc3-4c30-8d17-598619ec4e9b" -InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" -LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" -MAT = "23992714-dd62-5051-b70f-ba57cb901cac" -NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" -OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" -Preferences = "21216c6a-2e73-6563-6e65-726566657250" -Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" -Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" -SIMD = "fdea26ae-647d-5447-a871-4b548cad5224" -SLEEF_jll = "63e82ce6-3d80-5af4-a84c-484b71ab98bb" -SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" -StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" -TestEnv = "1e6cf692-eddd-4d53-88a5-2d735e33781b" -TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f" -YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" - -[weakdeps] -CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157" - -[extensions] -CommonDataModelExt = "CommonDataModel" - -[compat] -Atomix = "0.1, 1.0" -BenchmarkTools = "1.0" -CommonDataModel = "0.3.7" -DataFrames = "1.1" -DocStringExtensions = "0.8, 0.9" -Documenter = "1" -Graphs = "1.4" -Infiltrator = "1.0" -Interpolations = "0.13, 0.14, 0.15" -MAT = "0.10" -NCDatasets = "0.12, 0.13, 0.14" -OrderedCollections = "1.4" -PrecompileTools = "1.0" -Preferences = "1.2" -Revise = "3.1" -SIMD = "3.3" -SLEEF_jll = "3.4" -StaticArrays = "1.4" -StructArrays = "0.6, 0.7" -TestEnv = "1.0" -TimerOutputs = "0.5" -YAML = "0.4.7" -julia = "1.10" - -[extras] -CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["CommonDataModel", "Documenter", "Logging", "Test"] diff --git a/ext_hide/CommonDataModelExt/CommonDataModelExt.jl b/ext_hide/CommonDataModelExt/CommonDataModelExt.jl deleted file mode 100644 index c2bdcfc..0000000 --- a/ext_hide/CommonDataModelExt/CommonDataModelExt.jl +++ /dev/null @@ -1,93 +0,0 @@ -module CommonDataModelExt - -import PALEOboxes as PB -import CommonDataModel as CDM - -##################################### -# Wrapper types -###################################### - -struct ModelCDM <: CDM.AbstractDataset - model::PB.Model - modeldata::Union{Nothing, PB.AbstractModelData} -end - -PB.CDModel(model::PB.Model) = ModelCDM(model, nothing) -PB.CDModel(modeldata::PB.AbstractModelData) = ModelCDM(modeldata.model, modeldata) - -struct DomainCDM <: CDM.AbstractDataset - domain::PB.Domain - modeldata::Union{Nothing, PB.AbstractModelData} -end - -PB.CDModel(domain::PB.Domain) = DomainCDM(domain, nothing) - - -struct VariableDomainCDM <: CDM.AbstractDataset - variabledomain::PB.VariableDomain - modeldata::Union{Nothing, PB.AbstractModelData} - data -end - -PB.CDModel(variabledomain::PB.VariableDomain) = VariableDomainCDM(variabledomain, nothing, nothing) - -###################################### -# Model -###################################### - -# iterable with all group names -CDM.groupnames(m::ModelCDM) = [d.name for d in m.model.domains] - -CDM.group(m::ModelCDM, name::AbstractString) = DomainCDM(PB.get_domain(m.model, name; allow_not_found=false), m.modeldata) - -############################################### -# Domain -################################################ - -CDM.name(d::DomainCDM) = d.domain.name - -# TODO -# parentdataset(d::DomainCDM) - -# returns a list of variable names as strings -Base.keys(d::DomainCDM) = [v.name for v in PB.get_variables(d.domain)] - -function CDM.variable(d::DomainCDM, varname::AbstractString) - variabledomain = PB.get_variable(d.domain, varname; allow_not_found=false) - if isnothing(d.modeldata) - data = nothing - else - data = PB.get_data(variabledomain, d.modeldata) - end - return VariableDomainCDM(variabledomain, d.modeldata, data) -end - -CDM.dimnames(d::DomainCDM) = [nd.name for nd in PB.get_dimensions(d.domain)] - -CDM.dim(d::DomainCDM, name::AbstractString) = PB.get_dimension(d.domain, name).size - - -############################################### -# VariableDomain -################################################ - -CDM.name(v::VariableDomainCDM) = v.variabledomain.name - -CDM.dataset(v::VariableDomainCDM) = DomainCDM(v.variabledomain.domain, v.modeldata) - -CDM.dimnames(v::VariableDomainCDM) = [nd.name for nd in PB.get_dimensions(v.variabledomain)] - -Base.ndims(v::VariableDomainCDM) = length(CDM.dimnames(v)) - -Base.size(v::VariableDomainCDM) = (nd.size for nd in PB.get_dimensions(v.variabledomain)) - -CDM.attribnames(v::VariableDomainCDM) = keys(v.variabledomain.attributes) - -CDM.attrib(v::VariableDomainCDM, name::Symbol) = v.variabledomain.attributes[name] - -Base.getindex(v::VariableDomainCDM, indices...) = Base.getindex(v.data, indices...) - -Base.eltype(v::VariableDomainCDM) = Base.eltype(v.data) - - -end # module \ No newline at end of file diff --git a/src/Types cdm2.jl b/src/Types cdm2.jl deleted file mode 100644 index 94cc1c2..0000000 --- a/src/Types cdm2.jl +++ /dev/null @@ -1,222 +0,0 @@ -# TODO there doesn't seem to be an easy way of parameterising ModelData by an Array type ? -const PaleoArrayType = Array - -################################ -# CommonDataModel adaptor -################################ - -""" - CDModel(x) - -Create a CommonDataModel adaptor for PALEO object x -""" -function CDModel end - -################################ -# Parameters -############################### - -abstract type AbstractParameter -end - -################################# -# Reactions -################################### - - -""" - AbstractReactionMethod - -Base Type for Reaction Methods. - -""" -abstract type AbstractReactionMethod -end - - -abstract type AbstractReaction -end - - -############################################## -# Variables -############################################### - -""" - VariableBase - -A `Model` biogeochemical `Variable`. `Reaction`s access `Variable`s using derived Types [`VariableReaction`](@ref) -which are links to [`VariableDomain`](@ref)s. -""" -abstract type VariableBase -end - -""" - show_variables(obj, ...) -> Table - -Show all Variables attached to PALEO object `obj` -""" -function show_variables end - -""" - get_variable(obj, varname, ...) -> variable - -Get `variable <: VariableBase` by name from PALEO object -""" -function get_variable end - -""" - has_variable(obj, varname, ...) -> Bool - -True if PALEO object containts `varname` -""" -function has_variable end - - -""" - @enum VariableType - -Enumeration of `VariableBase` subtypes. Allowed values: -- `VariableReaction`: `VT_ReactProperty`, `VT_ReactDependency`, `VT_ReactContributor`, `VT_ReactTarget` -- `VariableDomain` : `VT_DomPropDep`, `VT_DomContribTarget` -""" -@enum VariableType::Cint begin - VT_Undefined = 0 - VT_ReactProperty - VT_ReactDependency - VT_ReactContributor - VT_ReactTarget - VT_DomPropDep - VT_DomContribTarget -end - - -abstract type VariableDomain <: VariableBase -end - -abstract type AbstractModel -end - -""" - AbstractDomain - -A model region containing Fields and Reactions that act on them. -""" -abstract type AbstractDomain -end - -abstract type AbstractSubdomain -end - -abstract type AbstractMesh -end - -const AbstractMeshOrNothing = Union{AbstractMesh, Nothing} - -""" - function get_mesh(obj, ...) - -Return an [`AbstractMesh`](@ref) for PALEO object `obj` -""" -function get_mesh end - -abstract type AbstractCellRange -end - -abstract type AbstractSpace -end - -abstract type AbstractData -end - -"parse eg \"ScalarData\" or \"PALEOboxes.ScalarData\" as ScalarData" -function Base.parse(::Type{AbstractData}, str::AbstractString) - dtype = tryparse(AbstractData, str) - - !isnothing(dtype) || - throw(ArgumentError("$str is not a subtype of AbstractData")) - return dtype -end - -function Base.tryparse(::Type{AbstractData}, str::AbstractString) - dtype = getproperty(@__MODULE__, Symbol(replace(str, "PALEOboxes."=>""))) - - return (dtype <: AbstractData) ? dtype : nothing -end - - -""" - AbstractField - -Defines a Field in a Domain -""" -abstract type AbstractField -end - -"`model` data arrays etc" -abstract type AbstractModelData -end - -"struct to hold Domain Field data" -abstract type AbstractDomainData -end - -""" - function get_table(obj, ...) - -Return a Tables.jl data table view for PALEO object `obj` -""" -function get_table end - - -############################################# -# ReactionMethodDispatchList -############################################# - -""" - ReactionMethodDispatchList - -Defines a list of [`ReactionMethod`](@ref) with corresponding [`CellRange`](@ref) -and views on Variable data (sub)arrays. -""" -struct ReactionMethodDispatchList{M <:Tuple, V <:Tuple, C <: Tuple} - methods::M - vardatas::V - cellranges::C -end - -ReactionMethodDispatchList(methods::Vector, vardatas::Vector, cellranges::Vector) = - ReactionMethodDispatchList(Tuple(methods), Tuple(vardatas), Tuple(cellranges)) - -struct ReactionMethodDispatchListNoGen - methods::Vector - vardatas::Vector - cellranges::Vector -end - -# See https://discourse.julialang.org/t/pretty-print-of-type/19555 -# Customize typeof function, as full type name is too verbose (as Tuples are of length ~ number of ReactionMethods to call) -Base.show(io::IO, ::Type{PALEOboxes.ReactionMethodDispatchList{M, V, C}}) where {M, V, C} = - print(io, "PALEOboxes.ReactionMethodDispatchList{M::Tuple, V::Tuple, C::Tuple each of length=$(fieldcount(M))}") - -function Base.show(io::IO, dispatchlist::ReactionMethodDispatchList) - print(io, typeof(dispatchlist)) -end - -function Base.show(io::IO, ::MIME"text/plain", dl::ReactionMethodDispatchList) - println(io, typeof(dl)) - for i in eachindex(dl.methodfns) - println(io, " ", dl.methods[i], ", ", dl.cellranges[i]) - end -end - -""" - infoerror(io::IOBuffer, message::AbstractString) - -Output accumulated log messages in io, then raise `ErrorException` with message -""" -function infoerror(io::IOBuffer, message::AbstractString) - s = String(take!(io)) - isempty(s) || @info s - error(message) -end \ No newline at end of file