Skip to content

Commit d98982d

Browse files
committed
use rbindDesign() to avoid S3 dispatch confusion (closes #50)
1 parent a4879d3 commit d98982d

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: SimDesign
22
Title: Structure for Organizing Monte Carlo Simulation Designs
3-
Version: 2.18.6
3+
Version: 2.18.7
44
Authors@R: c(person("Phil", "Chalmers", email = "rphilip.chalmers@gmail.com", role = c("aut", "cre"),
55
comment = c(ORCID="0000-0001-5332-2810")),
66
person("Matthew", "Sigal", role = c("ctb")),

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ S3method(print,PBA)
1111
S3method(print,RM)
1212
S3method(print,SFA)
1313
S3method(print,SimDesign)
14-
S3method(rbind,Design)
1514
S3method(rbind,SimDesign)
1615
S3method(summary,SimDesign)
1716
S3method(summary,SimSolve)
@@ -67,6 +66,7 @@ export(new_TelegramNotifier)
6766
export(quiet)
6867
export(rHeadrick)
6968
export(rValeMaurelli)
69+
export(rbindDesign)
7070
export(reSummarise)
7171
export(rejectionSampling)
7272
export(rint)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Changes in SimDesign 2.19
44

5+
- S3 `rbind.Design()` changed to `rbindDesign` as there was some confusion
6+
in the S3 dispatch purpose when internal ID elements needed to be tracked
7+
(see #50)
8+
59
- Multiple parameter `bias()` returned incorrect behavior/errors
610
for `relative` and `abs_relative` types (see #60)
711

R/Design.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ printDesign <- function(x, whichlist, ..., n = NULL, width = NULL, n_extra = NUL
289289

290290
#' @rdname createDesign
291291
#' @export
292-
rbind.Design <- function(...){
292+
rbindDesign <- function(...){
293293
dots <- list(...)
294294
for(i in 1:length(dots))
295295
class(dots[[i]]) <- class(dots[[i]])[-1]

man/createDesign.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/tests/test-02-aggregate.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ test_that('aggregate', {
207207
replications = 10, boot_method = 'basic')
208208
expect_true(all(dim(tmp) == c(8,13)))
209209

210-
tmp <- runSimulation(rbind(Design, Design), generate=mysim, analyse=mycomputeGood, summarise=mycollect, verbose=FALSE,
210+
tmp <- runSimulation(rbindDesign(Design, Design), generate=mysim, analyse=mycomputeGood, summarise=mycollect, verbose=FALSE,
211211
replications = 10, parallel=FALSE, save_results = TRUE)
212212
out <- reSummarise(summarise = mycollect, dir=DIR)
213213
expect_true(all(dim(out) == c(16,5)))

vignettes/HPC-computing.Rmd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Final
479479
or via the more informative (and less memory intensive) `SimCollect(..., check.only=TRUE)` flag.
480480

481481
```{r eval=FALSE}
482-
Missed <- aggregate_simulations(files=dir(), check.only=TRUE)
482+
Missed <- SimCollect(files=dir(), check.only=TRUE)
483483
Missed
484484
```
485485

@@ -494,12 +494,12 @@ Missed
494494
Next, build a new simulation structure containing only the missing information components.
495495

496496
```{r include=FALSE}
497-
subDesign <- createDesign(N=c(10,30))
497+
subDesign <- Design[c(1,3), ]
498498
replications_missed <- c(1000, 2000)
499499
```
500500

501501
```{r eval=FALSE}
502-
subDesign <- subset(Missed, select=N)
502+
subDesign <- Design[c(1,3),]
503503
replications_missed <- subset(Missed, select=MISSED_REPLICATIONS)
504504
```
505505

@@ -508,9 +508,11 @@ subDesign
508508
replications_missed
509509
```
510510

511-
At this point, you can return to the above logic of organizing the simulation script job, distributing the information across as many array jobs as necessary to fill in the missing information. However, as before you must be *very careful* about the random number generators per row in `subDesign` **and** the original submission job. The fix in this case is straightforward as well: simply create a continuation from the previous logic, where the new elements are treated as additional rows in the resulting object as though they were part of the initial job submission.
511+
At this point, you can return to the above logic of organizing the simulation script job, distributing the information across as many array jobs as necessary to fill in the missing information. However, as before you must be *very careful* about the random number generators per row in `subDesign` **and** the original submission job. The fix in this case is straightforward as well: simply create a continuation from the previous logic, where the new elements are treated as additional rows in the resulting object as though they were part of the initial job submission. Note that the `subDesign` component must use the
512+
original `Design` object in its construction so that the internal
513+
`Design.ID` attributes are properly tracked.
512514

513-
So, we now just glue on the new `subDesign` information to the original expanded version, though telling the scheduler to only evaluate these new rows in the `#SBATCH --array` specification (this is technically unnecessary, but is conceptually clear and keeps all simulation files and array IDs consistent).
515+
Finally, we now glue on the new `subDesign` information to the original expanded version using `rbindDesign()`, though telling the scheduler to only evaluate these new rows in the `#SBATCH --array` specification (this is technically unnecessary, but is conceptually clear and keeps all simulation files and array IDs consistent).
514516

515517
```{r}
516518
rc <- 50
@@ -521,7 +523,7 @@ replications_left <- rep(replications_missed/rc, each=rc)
521523
table(replications_left)
522524
523525
# new total design and replication objects
524-
Design_total <- rbind(Design300, Design_left)
526+
Design_total <- rbindDesign(Design300, Design_left)
525527
nrow(Design_total)
526528
replications_total <- c(replications, replications_left)
527529
table(replications_total)

0 commit comments

Comments
 (0)