Conversation
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
==========================================
- Coverage 55.42% 51.69% -3.73%
==========================================
Files 4 4
Lines 83 118 +35
==========================================
+ Hits 46 61 +15
- Misses 37 57 +20
Continue to review full report at Codecov.
|
| """ | ||
| function sample_scenarios end | ||
|
|
||
| function sample_scenarios(sp::AbstractStochasticProgram, n::Int, depth_max = 1000,to::TimerOutput=TimerOutput(), verbose::Int=0) |
There was a problem hiding this comment.
80C.
For consistency, we should keep the PEP8 all along :
- add space after comma:
, to::... - no space before and after equal symbol "=" in function arguments.
|
|
||
| function sample_scenarios(sp::AbstractStochasticProgram, n::Int, depth_max = 1000,to::TimerOutput=TimerOutput(), verbose::Int=0) | ||
| scenarios = [] | ||
| for i = 1:n |
There was a problem hiding this comment.
I would tend to follow JuMP guideline for for loop:
https://github.com/JuliaOpt/JuMP.jl/blob/master/docs/src/style.md#for-loops
|
|
||
| function sample_scenario(sp::AbstractStochasticProgram, depth_max = 1000,to::TimerOutput=TimerOutput(), verbose::Int=0) | ||
| node = get(sp,MasterNode()) | ||
| s = [] |
There was a problem hiding this comment.
I would say that s is not that explicit :p
Is it possible to type the array?
| ``` | ||
| """ | ||
| struct RandomTransition <: AbstractNodeAttribute end | ||
| function get(sp::AbstractStochasticProgram, tr::RandomTransition,node::Int) |
There was a problem hiding this comment.
I would add a space between , and node::Int
| RandomTransition <: AbstractNodeAttribute | ||
|
|
||
| return a randomly selected transition from node `node` | ||
| ### Examples |
There was a problem hiding this comment.
Following other example in SOI
| struct RandomTransition <: AbstractNodeAttribute end | ||
| function get(sp::AbstractStochasticProgram, tr::RandomTransition,node::Int) | ||
| r = rand() | ||
| cdf = 0 |
There was a problem hiding this comment.
I would use : cdf = 0. for type stability
|
|
||
| struct IsLeaf <: AbstractNodeAttribute end | ||
| function get(sp::AbstractStochasticProgram, node::Int) | ||
| return isempty(get(sp,OutTransitions(),node)) |
| return isempty(get(sp,OutTransitions(),node)) | ||
| end | ||
| function is_empty(sp::AbstractStochasticProgram, node::Int) | ||
| return get(sp,IsLeaf(),node) |
| s = Vector{:<AbstractTransition} | ||
| it = 0 | ||
| while !is_leaf(sp,node) && it < depth_max | ||
| tr = get(sp,RandomTransition,node) |
There was a problem hiding this comment.
RandomTransition -> RandomTransition ()
No description provided.