Skip to content

Commit

Permalink
precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Mar 14, 2023
1 parent fa15edd commit 3f0820b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsModels = "3eaba693-59b7-5ba5-a881-562e759f1c8d"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
Expand All @@ -18,6 +19,7 @@ CategoricalArrays = "0.9, 0.10"
CPUSummary = "0.1"
PrettyTables = "2"
Requires = "1"
SnoopPrecompile = "1"
StatsBase = "0.29, 0.30, 0.31, 0.32, 0.33"
StatsModels = "0.6, 0.7"
Tables = "1"
Expand Down
3 changes: 1 addition & 2 deletions src/MetidaBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module MetidaBase

using Tables, PrettyTables, StatsModels, CategoricalArrays, Requires#, Reexport

#@reexport using StatsModels
#import DataFrames, TypedTables
import StatsBase
import StatsModels: StatisticalModel, RegressionModel
import Tables: istable, columnaccess, columns, getcolumn, columnnames, schema, rowaccess, rows
Expand All @@ -19,6 +17,7 @@ module MetidaBase
include("types.jl")
include("utils.jl")
include("iterators.jl")
include("precompile.jl")

function __init__()
@require DataFrames="a93c6f00-e57d-5684-b7b6-d8193f3e46c0" include("dataframes.jl")
Expand Down
46 changes: 46 additions & 0 deletions src/precompile.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import SnoopPrecompile

SnoopPrecompile.@precompile_all_calls begin
sdfromcv(0.4)
varfromcv(0.4)
cvfromvar(0.4)
cvfromsd(0.4)
nonunique([1,2,3,3,4,5,6,6])
sortbyvec!([1,2,3,4,5,6,7,8], [2,5,3,1,8,4,6,7])
mt = metida_table([1,2,3], ["a", "b", "c"])
Tables.istable(mt)
Tables.rowaccess(mt)
mt = mt[:, [:x1, :x2]]
mtr = mt[1, :]
names(mt)
mt = MetidaBase.metida_table([1,2,3], ["a", "b", "c"], names = (:a, :b))
pushfirst!(mt, [0, " "])
ntr = NamedTuple{(:b, :a)}(["d", 10])
pushfirst!(mt, ntr)
size(mt, 1) == 5
Tables.rows(mt)
for (i,j) in enumerate(mt)
mt[i, :a]
end
length(mt)
mt2 = MetidaBase.metida_table([1,2,3], ["a", "b", "c"], names = (:a, :b))
append!(mt, mt2)
mtd = MetidaBase.indsdict!(Dict(), mt)

v1 = [1, 2, -6, missing, NaN, 0]
itr1 = skipnanormissing(v1)
for i in itr1
!isnanormissing(i)
end
collect(itr1)
collect(eachindex(itr1))
eltype(itr1)
itr2 = skipnonpositive(v1)
for i in itr2
ispositive(i)
end
collect(eachindex(itr2))
eltype(itr2)
collect(keys(itr2))
length(itr2)
end
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Заполняет словарь d индексами индивидуальных значений

function indsdict!(d::Dict, cdata::Union{Tuple, NamedTuple, AbstractVector{AbstractVector}})
@inbounds for (i, element) in enumerate(zip(cdata...))
ind = ht_keyindex(d, element)
Expand Down Expand Up @@ -71,7 +72,6 @@ ispositive(x) = x > zero(x)

# STATISTICS


#CV2se
"""
sdfromcv(cv::Real)::AbstractFloat
Expand Down
21 changes: 10 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ using MetidaBase
using Test, Tables, TypedTables, DataFrames, CSV


struct ExampleIDStruct <: MetidaBase.AbstractSubject
#time
#obs
id::Dict
end
struct ExampleResultStruct{T} <: MetidaBase.AbstractSubjectResult{T}
data::T
result::Dict
end


@testset "MetidaBase.jl" begin

struct ExampleIDStruct <: MetidaBase.AbstractSubject
#time
#obs
id::Dict
end
struct ExampleResultStruct{T} <: MetidaBase.AbstractSubjectResult{T}
data::T
result::Dict
end

io = IOBuffer();
#####################################################################
# metida_table
Expand Down

0 comments on commit 3f0820b

Please sign in to comment.