Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #27

Merged
merged 30 commits into from
Jan 16, 2025
Merged

Dev #27

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MetidaNCA"
uuid = "097c2839-c7bc-4c4b-a5f2-b4167c1b4e7c"
authors = ["PharmCat <[email protected]>"]
version = "0.5.14"
version = "0.5.15"



Expand All @@ -13,7 +13,7 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]

MetidaBase = "0.11.2, 0.11.3, 0.12"
MetidaBase = "0.11.2, 0.11.3, 0.12, 0.13, 0.14"
RecipesBase = "1"
Requires = "1"
julia = "1"
Expand Down
40 changes: 33 additions & 7 deletions src/import.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

nonunique(v) = [k for (k, v) in StatsBase.countmap(v) if v > 1]

parse_gkw(s::String) = [Symbol(s)]

Check warning on line 5 in src/import.jl

View check run for this annotation

Codecov / codecov/patch

src/import.jl#L5

Added line #L5 was not covered by tests
parse_gkw(s::Symbol) = [s]
parse_gkw(s::AbstractVector{<:AbstractString}) = Symbol.(s)

Check warning on line 7 in src/import.jl

View check run for this annotation

Codecov / codecov/patch

src/import.jl#L7

Added line #L7 was not covered by tests
parse_gkw(s::AbstractVector{Symbol}) = s

function floatparse(data::Missing, warn)
warn && @warn "Value $data parsed as `NaN`"
return NaN

Check warning on line 12 in src/import.jl

View check run for this annotation

Codecov / codecov/patch

src/import.jl#L10-L12

Added lines #L10 - L12 were not covered by tests
end

function floatparse(data::Nothing, warn)
warn && @warn "Value $data parsed as `NaN`"
return NaN
end

floatparse(data::AbstractFloat, ::Any) = data

function floatparse(data::AbstractString, warn)
tp = tryparse(Float64, data)
warn && isnothing(tp) && @warn "Value $data parsed as `NaN`"
floatparse(tp, false)
end
function floatparse(data::Int, warn)
float(data)

Check warning on line 28 in src/import.jl

View check run for this annotation

Codecov / codecov/patch

src/import.jl#L27-L28

Added lines #L27 - L28 were not covered by tests
end
#=
function floatparse(data, warn)
if !isa(data, AbstractFloat) && !ismissing(data)
if isa(data, AbstractString)
Expand All @@ -25,7 +51,7 @@
return data
end
end

=#

#=
function floatparse(data::AbstractVector)
Expand Down Expand Up @@ -107,8 +133,8 @@
See also: [`ElimRange`](@ref), [`DoseTime`](@ref), [`LimitRule`](@ref).
"""
function pkimport(data, time, conc, sort; kelauto = true, elimrange = ElimRange(), dosetime = nothing, limitrule::Union{Nothing, LimitRule} = nothing, warn = true, kwargs...)
if isa(sort, String) sort = [Symbol(sort)] end
if isa(sort, Symbol) sort = [sort] end

sort = parse_gkw(sort)

Tables.istable(data) || error("Data not a table!")

Expand Down Expand Up @@ -216,8 +242,8 @@
* `sort` - subject sorting columns.
"""
function upkimport(data, stime, etime, conc, vol, sort; kelauto = true, elimrange = ElimRange(), dosetime = nothing)
if isa(sort, String) sort = [Symbol(sort)] end
if isa(sort, Symbol) sort = [sort] end

sort = parse_gkw(sort)

cols = Tables.columns(data)
cdata = Tuple(Tables.getcolumn(cols, y) for y in sort)
Expand Down Expand Up @@ -328,8 +354,8 @@

"""
function pdimport(data, time, obs, sort; bl = 0, th = 0, dosetime::Union{Nothing, DoseTime} = nothing, limitrule::Union{Nothing, LimitRule} = nothing, warn = true)
if isa(sort, String) sort = [Symbol(sort)] end
if isa(sort, Symbol) sort = [sort] end

sort = parse_gkw(sort)

Tables.istable(data) || error("Data not a table!")

Expand Down
Loading