Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Aug 22, 2023
1 parent f90b49c commit bc5f87e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/descriptive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ function MetidaBase.metida_table_(obj::DataSet{DS}; sort = nothing, stats = noth
end
mt1 = metida_table((getid(obj, :, c) for c in idset)...; names = idset)
mt2 = metida_table((obj[:, c] for c in ressetl)...; names = ressetl)
MetidaTable(merge(mt1.table, mt2.table))
merge(mt1.table, mt2.table)
end

################################################################################
Expand Down
12 changes: 8 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MetidaStats
using MetidaBase
import MetidaBase: metida_table
using StatsBase
using Test
using DataFrames, CSV
Expand All @@ -15,15 +16,18 @@ io = IOBuffer();

di = MetidaStats.dataimport(ds, vars = [:var1, :var2])

mt = MetidaStats.metida_table(des; stats = [:mean, :geom])
mt = metida_table(des; stats = [:mean, :geom])

mt = MetidaStats.metida_table(des; stats = [:mean, :geom], id = [:Variable,:row])
mt = MetidaBase.metida_table(des; stats = [:mean, :geom], id = [:Variable,:row])

des2 = MetidaStats.descriptives(ds, [:var1, :var2], [:col, :row]; skipmissing = true, skipnonpositive = true, stats = MetidaStats.STATLIST)

@test_nowarn DataFrame(des2)

@test des[:, :mean] == des2[:, :mean]

show(io, des)
@test_nowarn show(io, des)
@test_nowarn show(io, di)

sort!(des2, [:col, :row, :Variable])

Expand Down Expand Up @@ -111,7 +115,6 @@ io = IOBuffer();
di = MetidaStats.dataimport(ds, vars = [:var1, :var2], sort = [:col, :row])
sort!(di, [:col, :row, :Variable])


des2[1, :skew] skewness(di[1].obs)

des2[1, :kurt] kurtosis(di[1].obs)
Expand All @@ -121,6 +124,7 @@ io = IOBuffer();
sort!(des3, [:col, :row, :Variable])
@test des3[2, :mean] des2[2, :mean]
@test des3[2, :geom] === NaN

des4 = MetidaStats.descriptives(ds, [:var1], [:col, :row]; skipmissing = false, skipnonpositive = false, stats = MetidaStats.STATLIST)
sort!(des4, [:col, :row, :Variable])
@test des4[1, :mean] des2[1, :mean]
Expand Down

0 comments on commit bc5f87e

Please sign in to comment.