Skip to content

Commit ff0562f

Browse files
Tweaks (use width=60 everywhere)
1 parent 3fc7a18 commit ff0562f

File tree

4 files changed

+61
-58
lines changed

4 files changed

+61
-58
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: progressr
22
==================
33

4-
Version: 0.5.0-9000 [2020-05-11]
4+
Version: 0.5.0-9000 [2020-05-12]
55

66
SIGNIFICANT CHANGES:
77

OVERVIEW.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To get progress updates, we can call it as:
5858
```r
5959
> library(progressr)
6060
> with_progress(y <- slow_sum(1:10))
61-
|===================== | 40%
61+
|==================== | 40%
6262
```
6363

6464

@@ -72,7 +72,7 @@ handlers("progress")
7272
This progress handler will present itself as:
7373
```r
7474
> with_progress(y <- slow_sum(1:10))
75-
[==================>---------------------------] 40% Added 4
75+
[=================>---------------------------] 40% Added 4
7676
```
7777

7878
To set the default progress handler(s) in all your R sessions, call `progressr::handlers(...)` in your <code>~/.Rprofile</code> file.
@@ -154,19 +154,19 @@ we get
154154
```r
155155
> handlers("txtprogressbar")
156156
> with_progress(y <- slow_sum(1:30))
157-
Step 5
158-
Step 10
159-
|===================== | 43%
157+
Step 5
158+
Step 10
159+
|==================== | 43%
160160
```
161161

162162
and
163163

164164
```r
165165
> handlers("progress")
166166
> with_progress(y <- slow_sum(1:30))
167-
Step 5
168-
Step 10
169-
[=================>----------------------------] 43% Added 13
167+
Step 5
168+
Step 10
169+
[================>---------------------------] 43% Added 13
170170
```
171171

172172

@@ -175,7 +175,7 @@ Step 10
175175
In contrast to other progress-bar frameworks, output from `message()`, `cat()`, `print()` and so on, will _not_ interfere with progress reported via **progressr**. For example, say we have:
176176

177177
```r
178-
my_sqrt <- function(xs) {
178+
slow_sqrt <- function(xs) {
179179
p <- progressor(along = xs)
180180
lapply(xs, function(x) {
181181
message("Calculating the square root of ", x)
@@ -190,10 +190,11 @@ we will get:
190190

191191
```r
192192
> library(progressr)
193-
> with_progress(y <- my_sqrt(1:3))
193+
> handlers("progress")
194+
> with_progress(y <- slow_sqrt(1:8))
194195
Calculating the square root of 1
195196
Calculating the square root of 2
196-
|================= | 66%
197+
[===========>-------------------------------------] 25% x=2
197198
```
198199

199200
This works because `with_progress()` will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as `handlers("beepr")`, then output does not have to be buffered and will appear immediately.
@@ -222,7 +223,7 @@ with_progress({
222223
sqrt(x)
223224
})
224225
})
225-
# |===================== | 40%
226+
# |==================== | 40%
226227
```
227228

228229
### The foreach package
@@ -241,7 +242,7 @@ with_progress({
241242
sqrt(x)
242243
}
243244
})
244-
# |===================== | 40%
245+
# |==================== | 40%
245246
```
246247

247248
### The purrr package
@@ -260,7 +261,7 @@ with_progress({
260261
sqrt(x)
261262
})
262263
})
263-
# |===================== | 40%
264+
# |==================== | 40%
264265
```
265266

266267

@@ -280,7 +281,7 @@ with_progress({
280281
sqrt(x)
281282
})
282283
})
283-
# |===================== | 40%
284+
# |==================== | 40%
284285
```
285286

286287
_Note:_ This solution does not involved the `.progress = TRUE` argument that **plyr** implements. Because **progressr** is more flexible, and because `.progress` is automatically disabled when running in parallel (see below), I recommended to use the above **progressr** approach instead. Having said this, as proof-of-concept, the **progressr** package implements support `.progress = "progressr"` if you still prefer the **plyr** way of doing it.
@@ -312,7 +313,7 @@ with_progress({
312313
sqrt(x)
313314
})
314315
})
315-
## [=================>-----------------------------] 40% x=2
316+
# [=================>------------------------------] 40% x=2
316317
```
317318

318319

@@ -338,7 +339,7 @@ with_progress({
338339
sqrt(x)
339340
}
340341
})
341-
## [=================>-----------------------------] 40% x=2
342+
# [=================>------------------------------] 40% x=2
342343
```
343344

344345

@@ -363,7 +364,7 @@ with_progress({
363364
sqrt(x)
364365
})
365366
})
366-
## [=================>-----------------------------] 40% x=2
367+
# [=================>------------------------------] 40% x=2
367368
```
368369

369370
_Note:_ This solution does not involved the `.progress = TRUE` argument that **furrr** implements. Because **progressr** is more generic and because `.progress = TRUE` only works for certain future backends and produces errors on others, I recommended to stop using `.progress = TRUE` and use the **progressr** package instead.
@@ -392,7 +393,7 @@ with_progress({
392393
sqrt(x)
393394
}, .parallel = TRUE)
394395
})
395-
## [=================>-----------------------------] 40% x=2
396+
# [=================>------------------------------] 40% x=2
396397
```
397398

398399
_Note:_ Although **progressr** implements support for using `.progress = "progressr"` with **plyr**, unfortunately, this will _not_ work when using `.parallel = TRUE`. This is because **plyr** resets `.progress` to the default `"none"` internally regardless how we set `.progress`. See <https://github.com/HenrikBengtsson/progressr/issues/70> for details and a hack that works around this limitation.

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ To get progress updates, we can call it as:
6060
```r
6161
> library(progressr)
6262
> with_progress(y <- slow_sum(1:10))
63-
|===================== | 40%
63+
|==================== | 40%
6464
```
6565

6666

@@ -74,7 +74,7 @@ handlers("progress")
7474
This progress handler will present itself as:
7575
```r
7676
> with_progress(y <- slow_sum(1:10))
77-
[==================>---------------------------] 40% Added 4
77+
[=================>---------------------------] 40% Added 4
7878
```
7979

8080
To set the default progress handler(s) in all your R sessions, call `progressr::handlers(...)` in your <code>~/.Rprofile</code> file.
@@ -156,19 +156,19 @@ we get
156156
```r
157157
> handlers("txtprogressbar")
158158
> with_progress(y <- slow_sum(1:30))
159-
Step 5
160-
Step 10
161-
|===================== | 43%
159+
Step 5
160+
Step 10
161+
|==================== | 43%
162162
```
163163

164164
and
165165

166166
```r
167167
> handlers("progress")
168168
> with_progress(y <- slow_sum(1:30))
169-
Step 5
170-
Step 10
171-
[=================>----------------------------] 43% Added 13
169+
Step 5
170+
Step 10
171+
[================>---------------------------] 43% Added 13
172172
```
173173

174174

@@ -177,7 +177,7 @@ Step 10
177177
In contrast to other progress-bar frameworks, output from `message()`, `cat()`, `print()` and so on, will _not_ interfere with progress reported via **progressr**. For example, say we have:
178178

179179
```r
180-
my_sqrt <- function(xs) {
180+
slow_sqrt <- function(xs) {
181181
p <- progressor(along = xs)
182182
lapply(xs, function(x) {
183183
message("Calculating the square root of ", x)
@@ -192,10 +192,11 @@ we will get:
192192

193193
```r
194194
> library(progressr)
195-
> with_progress(y <- my_sqrt(1:3))
195+
> handlers("progress")
196+
> with_progress(y <- slow_sqrt(1:8))
196197
Calculating the square root of 1
197198
Calculating the square root of 2
198-
|================= | 66%
199+
[===========>-------------------------------------] 25% x=2
199200
```
200201

201202
This works because `with_progress()` will briefly buffer any output internally and only release it when the next progress update is received just before the progress is re-rendered in the terminal. This is why you see a two second delay when running the above example. Note that, if we use progress handlers that do not output to the terminal, such as `handlers("beepr")`, then output does not have to be buffered and will appear immediately.
@@ -224,7 +225,7 @@ with_progress({
224225
sqrt(x)
225226
})
226227
})
227-
# |===================== | 40%
228+
# |==================== | 40%
228229
```
229230

230231
### The foreach package
@@ -243,7 +244,7 @@ with_progress({
243244
sqrt(x)
244245
}
245246
})
246-
# |===================== | 40%
247+
# |==================== | 40%
247248
```
248249

249250
### The purrr package
@@ -262,7 +263,7 @@ with_progress({
262263
sqrt(x)
263264
})
264265
})
265-
# |===================== | 40%
266+
# |==================== | 40%
266267
```
267268

268269

@@ -282,7 +283,7 @@ with_progress({
282283
sqrt(x)
283284
})
284285
})
285-
# |===================== | 40%
286+
# |==================== | 40%
286287
```
287288

288289
_Note:_ This solution does not involved the `.progress = TRUE` argument that **plyr** implements. Because **progressr** is more flexible, and because `.progress` is automatically disabled when running in parallel (see below), I recommended to use the above **progressr** approach instead. Having said this, as proof-of-concept, the **progressr** package implements support `.progress = "progressr"` if you still prefer the **plyr** way of doing it.
@@ -314,7 +315,7 @@ with_progress({
314315
sqrt(x)
315316
})
316317
})
317-
## [=================>-----------------------------] 40% x=2
318+
# [=================>------------------------------] 40% x=2
318319
```
319320

320321

@@ -340,7 +341,7 @@ with_progress({
340341
sqrt(x)
341342
}
342343
})
343-
## [=================>-----------------------------] 40% x=2
344+
# [=================>------------------------------] 40% x=2
344345
```
345346

346347

@@ -365,7 +366,7 @@ with_progress({
365366
sqrt(x)
366367
})
367368
})
368-
## [=================>-----------------------------] 40% x=2
369+
# [=================>------------------------------] 40% x=2
369370
```
370371

371372
_Note:_ This solution does not involved the `.progress = TRUE` argument that **furrr** implements. Because **progressr** is more generic and because `.progress = TRUE` only works for certain future backends and produces errors on others, I recommended to stop using `.progress = TRUE` and use the **progressr** package instead.
@@ -394,7 +395,7 @@ with_progress({
394395
sqrt(x)
395396
}, .parallel = TRUE)
396397
})
397-
## [=================>-----------------------------] 40% x=2
398+
# [=================>------------------------------] 40% x=2
398399
```
399400

400401
_Note:_ Although **progressr** implements support for using `.progress = "progressr"` with **plyr**, unfortunately, this will _not_ work when using `.parallel = TRUE`. This is because **plyr** resets `.progress` to the default `"none"` internally regardless how we set `.progress`. See <https://github.com/HenrikBengtsson/progressr/issues/70> for details and a hack that works around this limitation.

0 commit comments

Comments
 (0)