futureverse / futureverse/progressify

`fwb` transpiler: progress bar is one tick short when `simple = TRUE`

Abierto
#3 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
R
Estrellas
4
Forks
0
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

The `fwb` transpiler's skip count assumes `fwb()` calls `statistic` on unit weights
**twice** when `simple = TRUE`. In the current *fwb* development version it calls it once,
whatever `simple` is, so the wrapper swallows the first real bootstrap replicate's update
and the bar finishes one tick short of `R`. This might cause an issue once the development version is on CRAN, so I wanted to let you know before I submitted it.

`template_fwb_outer` sets:

```r
.progressr_skip_count <- if (.progressr_simple) 2L else 1L
```

and `template_fwb_FUN` decrements that on each call before it starts ticking. The count is
the number of times `fwb()` calls `statistic` before the `R` replicates begin.

In *fwb* 0.6.0 and earlier, `simple = TRUE` did call `statistic` twice on unit weights: the
second call existed only to detect whether `statistic` had a random component, which
determined whether the bootstrap weights could later be recovered. The development version
recovers the weights from recorded RNG streams instead, so that detection became
unnecessary and the second call was removed. There is now exactly one unit-weight call in
both cases.

An unconditional

```r
.progressr_skip_count <- 1L
```

is correct for the development version and for every release after it.

It would break *fwb* 0.6.0, though: `simple = TRUE` there would leave the second
unit-weight call to be counted as a tick, giving `R + 1` updates against a progressor with
`R` steps. So if you want to keep 0.6.0 working, this needs a version test:

```r
.progressr_skip_count <- if (.progressr_simple &&
utils::packageVersion("fwb") <= "0.6.0") 2L else 1L
```

Note that an unconditional skip count also removes the need to infer `simple`,
which the template currently does by reproducing `fwb()`'s default rule:

```r
.progressr_simple <- if (is.null(SIMPLE)) WTYPE != "multinom" else SIMPLE
```

With a constant skip count, `SIMPLE` and `WTYPE` are not needed at all.

### Related, separate: `R` is not always the number of replicates

Worth flagging while you're in this code, since it also makes `.progressr_steps` wrong.

The development version adds an exhaustive multinomial bootstrap: because there are only
`n^n` distinct multinomial resamples of `n` units, when `R` reaches that many `fwb()` uses
each exactly once and **reduces `R`** to that number. The transpiler takes `steps` from the
`R` in the call, so the bar stalls partway.

Only reachable for very small `n` (`n = 6` already has 46656 resamples, so with the default
`R = 999` nothing above `n = 4` is affected), and `fwb()` emits a message saying it has done
this. There may be nothing worth doing about it since the number of replicates isn't knowable
from the call alone, so a transpiler arguably cannot get this right in general. Recording it
rather than proposing a fix. Sorry to add this complication.

(Note: I used Claude Code to help with these edits and this issue.)

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Inspecciona el código generado en template_fwb_outer y template_fwb_FUN, comenzando por cómo se establece y decrementa .progressr_skip_count alrededor de las llamadas a la estadística de fwb(). Verifica las actualizaciones de progreso con respecto a la versión de desarrollo y fwb 0.6.0, incluido el comportamiento dependiente de la versión; se considera completado cuando la primera réplica no se pierde y las versiones compatibles producen exactamente R actualizaciones cuando se puede conocer el número de réplicas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
r
Área
developer-experience, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
68/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.