Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Jul 3, 2021
1 parent f419ba8 commit 8cb4d42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
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.1.1"
version = "0.1.2"

[deps]
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Expand Down
6 changes: 5 additions & 1 deletion src/MetidaBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
__precompile__(true)
module MetidaBase

using StatsModels, Tables
using Tables, StatsModels

import Tables: istable, columnaccess, columns, getcolumn, columnnames

import StatsModels: StatisticalModel

import Base: getindex, length, ht_keyindex

include("abstracttype.jl")
Expand Down
19 changes: 9 additions & 10 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,26 @@ end
Base.first(ds::DataSet) = first(ds.data)

function Base.getindex(ds::DataSet{T}, col::Colon, ind) where T <: AbstractResultData
type = typeof(getindormiss(ds[1].result, ind))
if length(ds) > 1
@inbounds for i = 1:length(ds)
type = promote_type(type, typeof(getindormiss(ds[i].result, ind)))
end
end
v = Vector{type}(undef, length(ds))
v = Vector{Any}(undef, length(ds))
@inbounds for i = 1:length(ds)
v[i] = getindormiss(ds[i].result, ind)
end
v
end

function Base.getindex(ds::DataSet{T}, col::Int, ind) where T <: AbstractResultData
getindormiss(ds[col].result, ind)
end


function Base.length(ds::DataSet)
length(ds.data)
end

function getindormiss(d, i)
ind = ht_keyindex(d, i)
if ind > 0 return d.vals[ind] else return missing end
function getindormiss(d::Dict{K, V}, i::K)::Union{V, Missing} where K where V
ind::Int = ht_keyindex(d, i)
if ind > 0 return d.vals[ind] end
missing
end
function islessdict(a::Dict{A1,A2}, b::Dict{B1,B2}, k::Union{AbstractVector, Set}) where A1 where A2 where B1 where B2
l = length(k)
Expand Down

0 comments on commit 8cb4d42

Please sign in to comment.