Closed cerisola closed 2 years ago
Currently, the bfield distribution argument takes a default value of nothing, i.e.
bfield
nothing
function bfield(N, Δt, J::GenericSD, noise::Noise, distro=nothing) if isnothing(distro) distro = Normal(0., 1/sqrt(Δt)) end ... end
which is then initialised to a Normal distribution as shown.
Apparently, Julia allows for default arguments to depend on the mandatory values. That is, something like this should work:
function bfield(N, Δt, J::GenericSD, noise::Noise, distro=Normal(0., 1/sqrt(Δt))) ... end
If possible to do it this way, I think it would be an improvement as it would be clearer to the user what the default of nothing is actually doing.
Tested and working. Much nicer.
Currently, the
bfield
distribution argument takes a default value ofnothing
, i.e.which is then initialised to a Normal distribution as shown.
Apparently, Julia allows for default arguments to depend on the mandatory values. That is, something like this should work:
If possible to do it this way, I think it would be an improvement as it would be clearer to the user what the default of
nothing
is actually doing.