Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r-devel failures for 0.1.7 #113

Closed
brodieG opened this issue Dec 7, 2017 · 0 comments
Closed

r-devel failures for 0.1.7 #113

brodieG opened this issue Dec 7, 2017 · 0 comments
Labels
Milestone

Comments

@brodieG
Copy link
Owner

brodieG commented Dec 7, 2017

Dear Brodie,

on the R-devel mailing list, recently the issue was raised why
str() was printing "atomic" (instead of e.g. "int") and not
mentioning the names e.g., forkin the case
structure(1:4, .Names=letters[1:4], foo = "bar")

https://stat.ethz.ch/pipermail/r-devel/2017-November/075163.html

In previous/current versions of R, we've had

> str(  structure(1:4, .Names=letters[1:4], foo = "bar")  )
atomic [1:4] 1 2 3 4
- attr(*, "foo")= chr "bar"

whereas in R-devel

> str(  structure(1:4, .Names=letters[1:4], foo = "bar")  )
Named int [1:4] 1 2 3 4
- attr(*, "names")= chr [1:4] "a" "b" "c" "d"
- attr(*, "foo")= chr "bar"
>

which is much more internally coherent with the output (in all
versions of R) of

> str(  structure(1:4, .Names=letters[1:4])  )
Named int [1:4] 1 2 3 4
- attr(*, "names")= chr [1:4] "a" "b" "c" "d"
>

..... so far for motivation.

In any case, in your testthat.misc.R ~ line 15 :

  obj <- list(
    a=a, b=b, c=1:50,
    d=long.string,
    e=list(1, structure(2, zz=list(a=1, b=list("a", ls=long.string))), e=letters)
  )
  str.txt <- capture.output(str(obj))
  expect_equal(
    diffobj:::str_levels(str.txt, wrap=FALSE),
    c(0L, 1L, 3L, 1L, 2L, 4L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 4L, 5L,  5L, 2L)
  )

now gives an error ... as does the subsequent test.
It is also a case where the new output is "clearly"(in the eye
of the beholder) nicer than before.

To make your check work both with "old R" (R < 3.5.0, i.e. all
versions before R-devel) and with R-devel,
you can use if(getRversion() ....) to distinguish, and indeed,
I've checked that the appended small patch makes your package
work fine with R-devel, too

Best regards,
Martin Maechler

diff -r -uBbw diffobj_CRAN/tests/testthat/testthat.misc.R diffobj/tests/testthat/testthat.misc.R
--- diffobj_CRAN/tests/testthat/testthat.misc.R    2016-11-20 15:25:34.000000000 +0100
+++ diffobj/tests/testthat/testthat.misc.R    2017-11-27 09:44:47.889579000 +0100
@@ -13,12 +13,18 @@
  str.txt <- capture.output(str(obj))
  expect_equal(
    diffobj:::str_levels(str.txt, wrap=FALSE),
+    if(getRversion() < "3.5")
    c(0L, 1L, 3L, 1L, 2L, 4L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 4L, 5L,  5L, 2L)
+    else # nicer str()
+    c(0L, 1L, 2L, 1L, 2L, 3L, 1L, 1L, 1L, 2L, 2L, 3L, 4L, 4L, 5L, 5L, 2L)
  )
  str.txt.w <- capture.output(str(obj, width=30L, strict.width="wrap"))
  expect_equal(
    diffobj:::str_levels(str.txt.w, wrap=TRUE),
+    if(getRversion() < "3.5")
    c(0L, 1L, 1L, 3L, 1L, 1L, 2L, 2L, 4L, 4L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L,  5L, 5L, 2L, 2L)
+    else # nicer str()
+    c(0L, 1L, 2L, 1L, 1L, 2L, 2L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,  1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 2L, 2L)
  )
  # cat(
  #  paste(
@brodieG brodieG added the bug label Dec 7, 2017
@brodieG brodieG added this to the 0.1.8 milestone Dec 9, 2017
brodieG added a commit that referenced this issue Dec 10, 2017
Fix #113: r-devel test breaks due to 'str' changes
Fix #111: handle rowname-less DFs and related bugs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant