dpc10ster / RJafroc

Artificial Intelligence: Evaluating AI, optimizing AI
19 stars 8 forks source link

testthat failure on Ubuntu #65

Closed dpc10ster closed 3 years ago

dpc10ster commented 3 years ago

This used to pass; now testthat fails for two test files, but only on Ubuntu:

test-PlotEmpiricalOperatingCharacteristics.R
test-predicted-plots.R
pwep commented 3 years ago

Already looking into it. Looks like it is failing on the "devel" version of R on Linux, as it is passing for Windows,Mac and Linux "release" version. I expect the output format in the "devel" version has changed - I'll dig into the change log and think about how we can address it.

dpc10ster commented 3 years ago

Thanks; could you briefly look at issue #64? I have no idea why he cannot download the master branch. This is one reason for CRAN submission - CRAN is way out of date.

dpc10ster commented 3 years ago

Already looking into it. Looks like it is failing on the "devel" version of R on Linux, as it is passing for Windows,Mac and Linux "release" version. I expect the output format in the "devel" version has changed - I'll dig into the change log and think about how we can address it.

For what it is worth, I got an identical failure on Ubuntu developer version using rhub; the checking code is in inst/cranSubmission/cranSubmission.R.

pwep commented 3 years ago

Interesting issue here. As you say, the expect_equal function is failing for all the plot tests.

I've downloaded a Docker image of the R-devel environment and tested the function outputs against what is saved in the .rds files.

The object generated by the functions appear identical, but the way the internal representation is traversed in the devel version is different, causing the error. This could be a bug in the devel version.

The code below generates a plot in variable a and an identical plot in b. The expect_equal test passes on release versions of R but fails in devel. It would appear that the devel version is having trouble correctly identifying two identical plot objects generated by ggplot2

R release version

> a <- PlotBinormalFit(c(1,2), c(0.5,0.5))
> b <- PlotBinormalFit(c(1,2), c(0.5,0.5))
> expect_equal(a, b)
>

(no warnings or errors)

R devel version

> a <- PlotBinormalFit(c(1,2), c(0.5,0.5))
> b <- PlotBinormalFit(c(1,2), c(0.5,0.5))
> expect_equal(a,b)
Error: `a` not equal to `b`.
Component “layers”: Component 1: Component 11: Component 3: target is not list-like
Component “scales”: Component “super”: Component “...”: target is not list-like
Component “coordinates”: Component “super”: Component “...”: target is not list-like
Component “facet”: Component “super”: Component “...”: target is not list-like
>

It feels like a ggplot2 / testthat issue. The non-ggplot2 code below

b <- plot(x=2) a <- plot(x=2) expect_equal(a,b)

...works as expected on both release and devel however the simple gpplot2 code below finds no equality on devel

library(ggplot2)
> a <- ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point()
> b <- ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point()
> expect_equal(a,b)
Error: `a` not equal to `b`.
Component “layers”: Component 1: Component 11: Component 3: target is not list-like
Component “scales”: Component “super”: Component “...”: target is not list-like
Component “coordinates”: Component “super”: Component “...”: target is not list-like
Component “facet”: Component “super”: Component “...”: target is not list-like
>
dpc10ster commented 3 years ago

Thanks for your, as usual, careful analysis. Should this be posted to ggplot2 or testthat or Ubuntu R devel as an issue? Or, for the purpose of CRAN submission, we can supply your simple example showing that this is not an RJafroc issue.

pwep commented 3 years ago

So R-devel has changed the behaviour of all.equal(), which is the basis of expect_equal() function we are using for the plot-based tests. Other packages are having this issue too: https://github.com/tidyverse/ggplot2/pull/4294 refers to the problem for ggplot2 and offers a solution. For the moment I'm going to try adding check.environment = FALSE as a fix for RJafroc plot tests. A pull request will follow shortly...

dpc10ster commented 3 years ago

This has been fixed by Peter; https://github.com/dpc10ster/RJafroc/pull/67#issue-535571162