Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PharmCat committed Nov 12, 2024
1 parent ab61866 commit 1b98277
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/MetidaNCA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ PKSubject, UPKSubject, PDSubject, NCAResult
function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" begin
savefig = Plots.savefig
current = Plots.current
end
end

Expand Down
7 changes: 7 additions & 0 deletions src/nca.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,14 @@ function nca!(data::PDSubject{T,O}; calcm = :lint, intpm = nothing, verbose = 0,
################################################################################
result[:Obsnum] = obsnum = length(obs_cp)

result[:BL] = data.bl

result[:TH] = data.th


result[:Rmax], result[:Tmax], tmaxn = ctmax(time_cp, obs_cp, length(obs_cp))



# ALL NAN AND MISSING VALUES LINEAR INTERPOLATED
step_2_interpolate!(time_cp, obs_cp, einds, 1, :lint)
Expand Down
6 changes: 3 additions & 3 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ function Base.show(io::IO, obj::PDSubject)
PrettyTables.pretty_table(io, metida_table(obj.time, obj.obs; names = (:Time, :Observation)); tf = PrettyTables.tf_compact)
end

function subject_type_str(subj::Type{<:PKSubject})
function subject_type_str(subj::Type{PKS}) where PKS <: PKSubject

Check warning on line 62 in src/show.jl

View check run for this annotation

Codecov / codecov/patch

src/show.jl#L62

Added line #L62 was not covered by tests
"Pharmacokinetics subject"
end
function subject_type_str(subj::Type{<:UPKSubject})
function subject_type_str(subj::Type{UPKS}) where UPKS <: UPKSubject

Check warning on line 65 in src/show.jl

View check run for this annotation

Codecov / codecov/patch

src/show.jl#L65

Added line #L65 was not covered by tests
"Pharmacokinetics subject (urine)"
end
function subject_type_str(subj::Type{<:PDSubject})
function subject_type_str(subj::Type{PDS}) where PDS <: PDSubject

Check warning on line 68 in src/show.jl

View check run for this annotation

Codecov / codecov/patch

src/show.jl#L68

Added line #L68 was not covered by tests
"Pharmacodynamics subject"
end
function Base.show(io::IO, obj::DataSet{ST}) where ST <: AbstractSubject
Expand Down
3 changes: 3 additions & 0 deletions test/pdtest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

@test_nowarn MetidaNCA.pkplot(pd)
@test_nowarn MetidaNCA.pkplot(pd[1], drawth = true, drawbl = true)
p = plot()
@test_nowarn MetidaNCA.pkplot!(pd[1], drawth = true, drawbl = true)


pd_res = MetidaNCA.nca!(pd[1])
pd_rds = MetidaNCA.nca!(pd)
Expand Down
17 changes: 17 additions & 0 deletions test/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ include("refdicts.jl")
# If typesort defined and NoPageSort() return one plot
pl = @test_nowarn MetidaNCA.pkplot(ds; typesort = :Subject, pagesort = MetidaNCA.NoPageSort(), sort = Dict(:Formulation => "R"))
@test isa(pl, Plots.Plot) == true
#@test_throws "There is no pkplot! methods for DataSet, use pkplot or pkplot! for each subject separately." MetidaNCA.pkplot!(ds; typesort = :Subject, pagesort = MetidaNCA.NoPageSort(), sort = Dict(:Formulation => "R"))


pl = @test_nowarn MetidaNCA.pkplot(ds; typesort = :Formulation, pagesort = MetidaNCA.NoPageSort(), legend = true)
@test isa(pl, Plots.Plot) == true

Expand Down Expand Up @@ -107,12 +110,26 @@ include("refdicts.jl")
@test isa(pl, Plots.Plot) == true

# Return plot for PKSubject

@test_nowarn MetidaNCA.pkplot(ds[1].time, ds[1].obs)
@test_nowarn MetidaNCA.pkplot!(ds[1].time, ds[1].obs)
p = plot()
@test_nowarn MetidaNCA.pkplot!(p, ds[1].time, ds[1].obs)
p = plot()
@test_nowarn MetidaNCA.pkplot!(ds[1])
#p = plot()
#@test_nowarn MetidaNCA.pkplot!(ds[1])

@test_nowarn pl = MetidaNCA.pkplot(ds[1]; ylims = (0, 250), yscale = :log10, legend = false)
@test_nowarn pl = MetidaNCA.pkplot(ds[1]; elim = true, ls = false)
@test_nowarn MetidaNCA.plotstyle(40)
pl = MetidaNCA.pkplot(ds[3])
pl = MetidaNCA.pkplot!(ds[2]; yscale = :log10)

p = plot()
MetidaNCA.pkplot!(ds[1]; ylims = (0, 250), yscale = :log10, legend = false)
#MetidaNCA.pkplot!(p, ds[1]; ylims = (0, 250), yscale = :log10, legend = false)

kr = MetidaNCA.ElimRange(kelstart = 4, kelend = 12, kelexcl = Int[5,6])
MetidaNCA.setkelrange!(ds, kr, [1,2,3])
dsnca = MetidaNCA.nca!(ds)
Expand Down

0 comments on commit 1b98277

Please sign in to comment.