Skip to content

Commit d475f88

Browse files
authored
Merge pull request #753 from njtierney/remove-log-base-arg
remove `base` argument from `log`. Resolves #597.
2 parents 39ef12f + 172ea61 commit d475f88

File tree

7 files changed

+85
-7
lines changed

7 files changed

+85
-7
lines changed

DESCRIPTION

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Imports:
3939
coda,
4040
future (>= 1.22.1),
4141
glue (>= 1.5.1),
42+
lifecycle,
4243
methods,
4344
parallelly (>= 1.29.0),
4445
progress (>= 1.2.0),

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# greta (development version)
22

3+
## Changes
4+
5+
- `log.greta_array()` function warns if user uses the `base` arg, as it was unused, (#597).
6+
37
# greta 0.5.0
48

59
This version of greta uses Tensorflow 2.0.0, which comes with it a host of new very exciting features!

R/functions.R

+15-4
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
#' @details TensorFlow only enables rounding to integers, so `round()` will
8888
#' error if `digits` is set to anything other than `0`.
8989
#'
90-
#' Any additional arguments to `chol()`, `chol2inv`, and
91-
#' `solve()` will be ignored, see the TensorFlow documentation for
92-
#' details of these routines.
90+
#' Any additional arguments to `chol()`, `chol2inv`, `solve()`, and `log()`
91+
#' will be ignored, see the TensorFlow documentation for details of these
92+
#' routines.
9393
#'
9494
#' `sweep()` only works on two-dimensional greta arrays (so `MARGIN`
9595
#' can only be either 1 or 2), and only for subtraction, addition, division
@@ -121,7 +121,18 @@
121121
NULL
122122

123123
#' @export
124-
log.greta_array <- function(x, base = exp(1)) {
124+
log.greta_array <- function(x, base = lifecycle::deprecated()) {
125+
126+
if (lifecycle::is_present(base)) {
127+
lifecycle::deprecate_warn(
128+
when = "0.5.1",
129+
what = "log(base)",
130+
details = "The `base` argument is (and actually was) never used in \\
131+
`log.greta_array()`. See the TensorFlow documentation for details of \\
132+
this routine."
133+
)
134+
}
135+
125136
if (has_representation(x, "log")) {
126137
result <- copy_representation(x, "log")
127138
} else {

greta.Rproj

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version: 1.0
2+
ProjectId: 425469f5-737a-40a5-856a-8078552f4e50
23

34
RestoreWorkspace: Default
45
SaveWorkspace: Default

man/functions.Rd

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/functions.md

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
# log.greta_array has a warning when base argument used
2+
3+
Code
4+
log(x)
5+
Message
6+
greta array <operation>
7+
8+
Output
9+
[,1]
10+
[1,] ?
11+
Message
12+
13+
14+
---
15+
16+
The `base` argument of `log()` is deprecated as of greta 0.5.1.
17+
i The `base` argument is (and actually was) never used in `log.greta_array()`. See the TensorFlow documentation for details of this routine.
18+
19+
---
20+
21+
Code
22+
y
23+
Message
24+
greta array <data>
25+
26+
Output
27+
[,1] [,2] [,3]
28+
[1,] 1 4 7
29+
[2,] 2 5 8
30+
[3,] 3 6 9
31+
Message
32+
33+
34+
---
35+
36+
The `base` argument of `log()` is deprecated as of greta 0.5.1.
37+
i The `base` argument is (and actually was) never used in `log.greta_array()`. See the TensorFlow documentation for details of this routine.
38+
139
# cummax and cummin functions error informatively
240

341
Code

tests/testthat/test_functions.R

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
set.seed(2020 - 02 - 11)
22

3+
test_that("log.greta_array has a warning when base argument used",{
4+
skip_if_not(check_tf_version())
5+
6+
x <- normal(0, 1)
7+
expect_snapshot(
8+
log(x)
9+
)
10+
11+
expect_snapshot_warning(
12+
log(x, base = 3)
13+
)
14+
15+
y <- as_data(matrix(1:9, nrow = 3, ncol = 3))
16+
expect_snapshot(
17+
y
18+
)
19+
20+
expect_snapshot_warning(
21+
log(exp(x), base = 3)
22+
)
23+
24+
})
25+
326
test_that("simple functions work as expected", {
427
skip_if_not(check_tf_version())
528

0 commit comments

Comments
 (0)