Skip to content

Commit

Permalink
metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jan 16, 2025
1 parent 3f4a98b commit 5f22ff8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MetidaBase"
uuid = "075456b7-4006-432f-9324-2f8453996c49"
authors = ["PharmCat <[email protected]> and contributors"]
version = "0.13.0"
version = "0.14.0"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
7 changes: 7 additions & 0 deletions src/dataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
################################################################################
struct DataSet{T <: AbstractData} <: AbstractDataSet{AbstractData}
ds::Vector{T}
metadata::Dict
function DataSet(ds::AbstractVector{T}, metadata::Dict) where T <: AbstractData
new{T}(ds, metadata)::DataSet
end
function DataSet(ds)
DataSet(ds, Dict{Symbol, Any}())
end
end

function getdata(d::DataSet)
Expand Down
12 changes: 12 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ ispositive(::Nothing) = false
ispositive(x::AbstractFloat) = isnan(x) ? false : x > zero(x)
ispositive(x) = x > zero(x)



################################################################################
# Group keyword parsing
################################################################################

parse_gkw(s::String) = [Symbol(s)]
parse_gkw(s::Symbol) = [s]
parse_gkw(s::AbstractVector{<:AbstractString}) = Symbol.(s)
parse_gkw(s::AbstractVector{Symbol}) = s


################################################################################
################################################################################

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ using Test, Tables, TypedTables, DataFrames, CSV
end
exrsds = MetidaBase.DataSet(exrsdsv)

# metadata
dsmeta = MetidaBase.DataSet(exrsdsv, Dict(:name => "SomeName"))

# Index
@test exrsds[:, :r1][1] == 3
@test exrsds[1, :r1] == 3
Expand Down Expand Up @@ -235,4 +238,9 @@ using Test, Tables, TypedTables, DataFrames, CSV
MetidaBase.cvfromvar(0.4) 0.7013021443295824
MetidaBase.cvfromsd(0.4) 0.41654636115540644


@test MetidaBase.parse_gkw("s") == [:s]
@test MetidaBase.parse_gkw(:s) == [:s]
@test MetidaBase.parse_gkw([:s]) == [:s]
@test MetidaBase.parse_gkw(["s"]) == [:s]
end

0 comments on commit 5f22ff8

Please sign in to comment.