MRC-CSO-SPHSU / UKSEABMLib.jl

MIT License
1 stars 1 forks source link

Debug instructions within simulation functions #20

Closed AtiyahElsheikh closed 1 year ago

AtiyahElsheikh commented 1 year ago

related to #2

Debug instructions (printing chosen variables, delayed printing & checking correctness) are enabled by macros within the code, e.g.

doX!()
...
    assumption() do
        @assert alive(person)       
        @assert isMale(person) || isFemale(person) # Assumption 
        @assert typeof(agep) == Rational{Int}
    end
...
end # doX!

The client needs extra to externally setup / initialise global variables within SE*.Utilities module, e.g.

verbose(sim) ? setVerbose!() : unsetVerbose!()
    setDelay!(sim.parameters.sleeptime)
    sim.parameters.checkassumption ? checkAssumptions!() :
                                        ignoreAssumptions!()

This is not obviously known for the user in advance how to do it. Moreover, it is not good to miss with global variables here and there.

Proper and common way is to use keyword arguments with default values:

doX!(....;verbose=false, sleeptime=0.0, ...)

Also, in the long-term it is proper to have (most of) the validation through unit testing.

AtiyahElsheikh commented 1 year ago

Further solutions subject to investigation

AtiyahElsheikh commented 1 year ago

verbose statements etc. are now isolated outside computationally intensive routines. More generic code has been added. Using Logging standard library is nice, but it is not a priority at the moment.