Move argument checks and OutputsModel formatting from RunModel* functions to utils functions
Move argument checks and OutputsModel formatting from RunModel* functions to utils functions
The issue #123 (closed) highlights the need to eliminate the code redundancy in RunModel*
functions.
So I create a separated issue for this specific task with a separated branch in order to be able to run properly regression tests.
Activity
- Dorchies David changed milestone to %v1.7.0
changed milestone to %v1.7.0
- Dorchies David added ENHANCEMENT label
added ENHANCEMENT label
- Dorchies David created merge request !50 (merged) to address this issue
created merge request !50 (merged) to address this issue
- Dorchies David mentioned in merge request !50 (merged)
mentioned in merge request !50 (merged)
- Dorchies David mentioned in commit 23a72185
mentioned in commit 23a72185
- Dorchies David mentioned in commit 078e10a4
mentioned in commit 078e10a4
- Dorchies David mentioned in commit 329591eb
mentioned in commit 329591eb
- Author Developer
I'm particularly proud of this code line!
class(OutputsModel) <- c("OutputsModel", class(RunOptions)[-1])
- Owner
I prefer this one (if the order ever changes):
class(OutputsModel) <- c("OutputsModel", setdiff(class(RunOptions), "RunOptions"))
- Author Developer
I tried to write to quickest instruction possible and I didn't have in mind any case when this order could change. But I can be wrong.
> microbenchmark::microbenchmark("swap1" = {class(OutputsModel) <- c("OutputsModel", class(RunOptions)[-1])}, "setdiff" = {class(OutputsModel) <- c("OutputsModel", setdiff(class(RunOptions), "RunOptions"))}) Unit: microseconds expr min lq mean median uq max neval swap1 1.3 1.402 1.62510 1.6000 1.602 6.402 100 setdiff 6.7 6.801 7.46598 6.9015 7.101 41.501 100
Using
setdiff
takes 4-5 more times than swap the first item.By security we can enforce the check of RunOptions in RunModel by replacing:
if(!inherits(RunOptions, "RunOptions")) stop...
by
if(class(RunOptions)[1] != "RunOptions")) stop...
(Which could also speed up this check)
Edited by Dorchies David - Author Developer
Definitely, I think that we should be severe on the order of the classes and then assume this order...
- Please register or sign in to reply
- Dorchies David mentioned in commit 0ada9d71
mentioned in commit 0ada9d71
- Dorchies David mentioned in commit 4156920f
mentioned in commit 4156920f
- Dorchies David mentioned in commit 29dec7ea
mentioned in commit 29dec7ea
- Dorchies David mentioned in commit 281beea5
mentioned in commit 281beea5
- Delaigue Olivier changed title from {-Optimisation of OutputsModel creation in RunModel-}* to {+Move argument checks and OutputsModel formatting from RunModel functions to utils functions+}*
changed title from {-Optimisation of OutputsModel creation in RunModel-}* to {+Move argument checks and OutputsModel formatting from RunModel functions to utils functions+}*
- Delaigue Olivier mentioned in commit 08129fd4
mentioned in commit 08129fd4
- Delaigue Olivier mentioned in commit 95154f77
mentioned in commit 95154f77
- Delaigue Olivier mentioned in commit f22f1a98
mentioned in commit f22f1a98
- Delaigue Olivier closed via merge request !50 (merged)
closed via merge request !50 (merged)