Skip to content

Commit

Permalink
- use length instead of size to get # sims in AbstractTrial
Browse files Browse the repository at this point in the history
- VCTRunning -> VCTRunner
- test use of previous sims in RunSampling
  • Loading branch information
drbergman committed Sep 9, 2024
1 parent 24b9966 commit ecd21ed
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/VCTClasses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ abstract type AbstractTrial end
abstract type AbstractSampling <: AbstractTrial end
abstract type AbstractMonad <: AbstractSampling end

Base.size(T::AbstractTrial) = getSimulations(T) |> size
Base.length(T::AbstractTrial) = getSimulations(T) |> length

##########################################
######## AbstractSamplingIDs #########
Expand Down Expand Up @@ -91,7 +91,7 @@ end

Simulation(simulation_id::Int) = getSimulation(simulation_id)

Base.size(simulation::Simulation) = 1
Base.length(simulation::Simulation) = 1

##########################################
############### Monad ################
Expand Down
2 changes: 1 addition & 1 deletion src/VCTModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include("VCTLoader.jl")
include("VCTSensitivity.jl")
include("VCTCompilation.jl")
include("VCTDeletion.jl")
include("VCTRunning.jl")
include("VCTRunner.jl")
include("VCTRecorder.jl")

include("../PhysiCell-XMLRules/src/PhysiCell_XMLRules.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/VCTRunning.jl → src/VCTRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function runAbstractTrial(T::AbstractTrial; use_previous_sims::Bool=false, force

n_asterisks = 1
asterisks = Dict{String, Int}()
size_T = size(T)
size_T = length(T)
println("Finished $(typeof(T)) $(T.id).")
println("\t- Consists of $(size_T) simulations.")
print( "\t- Scheduled $(length(simulation_tasks)) simulations to complete this $(typeof(T)).")
Expand Down
23 changes: 17 additions & 6 deletions test/test-project/VCT/RunSampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,35 @@ println("""
############################################
""")

runAbstractTrial(sampling)
n_ran, n_success = runAbstractTrial(sampling)

println("""
############################################
## SAMPLING SUCCESSFULLY RUN! ##
############################################
""")

simulation_ids = getSimulations(sampling)
expected_num_sims = monad_min_length
n_simulations = size(sampling) # number of simulations recorded (in .csvs) for this sampling
n_expected_sims = monad_min_length
for ev in EV
global expected_num_sims *= length(ev.values)
global n_expected_sims *= length(ev.values)
end
n_variations = lenght(sampling.variation_ids)

@test length(simulation_ids) == expected_num_sims
# make sure the number of simulations in this sampling is what we expected based on...
@test n_simulations == n_expected_sims # the EVs...
@test n_simulations == n_variations * monad_min_length # ...how many variation ids we recorded (number of rulesets_variations_ids must match variation_ids on construction of sampling)
@test n_simulations == n_ran # ...how many simulations we started
@test n_simulations == n_success # ...how many simulations succeeded

println("""
############################################
## SAMPLING SUCCESSFULLY IN CSVS! ##
############################################
""")
""")

n_ran, n_success = runAbstractTrial(sampling; use_previous_sims=true)

# no new simulations should have been run
@test n_ran == 0
@test n_success == 0

0 comments on commit ecd21ed

Please sign in to comment.