Skip to content

Commit

Permalink
fix table export
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Aug 22, 2023
1 parent 040f0b4 commit f90b49c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MetidaStats"
uuid = "75cdad26-409a-4e43-8ad7-d54b4fa665a0"
authors = ["PharmCat <v.s.arnautov@yandex.ru>"]
version = "0.2.0"
version = "0.2.1"

[deps]

Expand Down
1 change: 1 addition & 0 deletions src/MetidaStats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module MetidaStats
Tables,
indsdict!,
metida_table,
metida_table_,
getid,
MetidaTable,
sortbyvec!,
Expand Down
90 changes: 1 addition & 89 deletions src/descriptive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,94 +29,6 @@ const STATLIST = [:n,
:sek,
:sum]

#=
function sortbyvec!(a, vec)
sort!(a, by = x -> findfirst(y -> x == y, vec))
end
=#
#=
ispositive(::Missing) = false
ispositive(x::AbstractFloat) = isnan(x) ? false : x > zero(x)
ispositive(x) = x > zero(x)
################################################################################
struct SkipNonPositive{T}
x::T
end
skipnonpositive(itr) = SkipNonPositive(itr)
Base.IteratorEltype(::Type{SkipNonPositive{T}}) where {T} = Base.IteratorEltype(T)
#Base.eltype(::Type{SkipNonPositive{T}}) where {T} = nonmissingtype(eltype(T))
function Base.iterate(itr::SkipNonPositive, state...)
y = iterate(itr.x, state...)
y === nothing && return nothing
item, state = y
while !ispositive(item)
y = iterate(itr.x, state)
y === nothing && return nothing
item, state = y
end
item, state
end
Base.IndexStyle(::Type{<:SkipNonPositive{T}}) where {T} = IndexStyle(T)
Base.eachindex(itr::SkipNonPositive) =
Iterators.filter(i -> ispositive(@inbounds(itr.x[i])), eachindex(itr.x))
Base.keys(itr::SkipNonPositive) =
Iterators.filter(i -> ispositive(@inbounds(itr.x[i])), keys(itr.x))
Base.@propagate_inbounds function getindex(itr::SkipNonPositive, I...)
v = itr.x[I...]
!ispositive(v) && throw(ErrorException("the value at index $I is non positive"))
v
end
function Base.length(itr::SkipNonPositive)
n = 0
for i in itr n+=1 end
n
end
################################################################################
struct SkipNaNorMissing{T}
x::T
end
skipnanormissing(itr) = SkipNaNorMissing(itr)
Base.IteratorEltype(::Type{SkipNaNorMissing{T}}) where {T} = Base.IteratorEltype(T)
#Base.eltype(::Type{SkipNaNorMissing{T}}) where {T} = nonmissingtype(eltype(T))
function Base.iterate(itr::SkipNaNorMissing, state...)
y = iterate(itr.x, state...)
y === nothing && return nothing
item, state = y
while isnanormissing(item)
y = iterate(itr.x, state)
y === nothing && return nothing
item, state = y
end
item, state
end
Base.IndexStyle(::Type{<:SkipNaNorMissing{T}}) where {T} = IndexStyle(T)
Base.eachindex(itr::SkipNaNorMissing) =
Iterators.filter(i -> isnanormissing(@inbounds(itr.x[i])), eachindex(itr.x))
Base.keys(itr::SkipNaNorMissing) =
Iterators.filter(i -> isnanormissing(@inbounds(itr.x[i])), keys(itr.x))
Base.@propagate_inbounds function getindex(itr::SkipNaNorMissing, I...)
v = itr.x[I...]
!isnanormissing(v) && throw(ErrorException("The value at index $I is NaN or missing!"))
v
end
function Base.length(itr::SkipNaNorMissing)
n = 0
for i in itr n+=1 end
n
end
=#
################################################################################
#=
length2(x) = length(x)
function length2(itr::Base.SkipMissing)
n = 0
for i in itr n+=1 end
n
end
=#
################################################################################
"""
dataimport(data; vars, sort = nothing)
Expand Down Expand Up @@ -477,7 +389,7 @@ end
#
################################################################################

function MetidaBase.metida_table(obj::DataSet{DS}; sort = nothing, stats = nothing, id = nothing) where DS <: Descriptives
function MetidaBase.metida_table_(obj::DataSet{DS}; sort = nothing, stats = nothing, id = nothing) where DS <: Descriptives
idset = Set(keys(first(obj).data.id))
resset = Set(keys(first(obj).result))
if length(obj) > 1
Expand Down

0 comments on commit f90b49c

Please sign in to comment.