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

stringsAsFactors=TRUE #34

Merged
merged 35 commits into from
Aug 5, 2020
Merged

stringsAsFactors=TRUE #34

merged 35 commits into from
Aug 5, 2020

Conversation

tdhock
Copy link
Collaborator

@tdhock tdhock commented Mar 2, 2020

fixes

  > test_check("animint2", filter="compiler")
  Loading required package: animint2
  [1] "aesthetics"
  mapping: x = Sepal.Length, y = Petal.Length
  geom_point: na.rm = FALSE
  stat_identity: na.rm = FALSE
  position_identity
  $problem.aes
  [1] "foo"
  
  $data.variables
  [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
  
  [1] "animation"
  [1] "compiler errors"
  mapping: x = letter, y = count, fill = stack, key = key, showSelected1 = facet
  geom_bar: width = NULL, na.rm = FALSE
  stat_identity: na.rm = FALSE
  position_stack
  -- 1. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fy) not equal to c("C", "B", "A")[lay$ROW].
  6/9 mismatches
  x[1]: "A"
  y[1]: "C"
  
  x[2]: "A"
  y[2]: "C"
  
  x[3]: "A"
  y[3]: "C"
  
  x[7]: "C"
  y[7]: "A"
  
  x[8]: "C"
  y[8]: "A"
  
  -- 2. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("c", "b", "a")[lay$COL].
  6/9 mismatches
  x[1]: "a"
  y[1]: "c"
  
  x[3]: "c"
  y[3]: "a"
  
  x[4]: "a"
  y[4]: "c"
  
  x[6]: "c"
  y[6]: "a"
  
  x[7]: "a"
  y[7]: "c"
  
  -- 3. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fy) not equal to c("B", "C", "A")[lay$ROW].
  9/9 mismatches
  x[1]: "A"
  y[1]: "B"
  
  x[2]: "A"
  y[2]: "B"
  
  x[3]: "A"
  y[3]: "B"
  
  x[4]: "B"
  y[4]: "C"
  
  x[5]: "B"
  y[5]: "C"
  
  -- 4. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("a", "c", "b")[lay$COL].
  6/9 mismatches
  x[2]: "b"
  y[2]: "c"
  
  x[3]: "c"
  y[3]: "b"
  
  x[5]: "b"
  y[5]: "c"
  
  x[6]: "c"
  y[6]: "b"
  
  x[8]: "b"
  y[8]: "c"
  
  -- 5. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fy) not equal to c("C", "B", "A")[lay$ROW].
  6/9 mismatches
  x[1]: "A"
  y[1]: "C"
  
  x[2]: "A"
  y[2]: "C"
  
  x[3]: "A"
  y[3]: "C"
  
  x[7]: "C"
  y[7]: "A"
  
  x[8]: "C"
  y[8]: "A"
  
  -- 6. Failure: grid: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("c", "b", "a")[lay$COL].
  6/9 mismatches
  x[1]: "a"
  y[1]: "c"
  
  x[3]: "c"
  y[3]: "a"
  
  x[4]: "a"
  y[4]: "c"
  
  x[6]: "c"
  y[6]: "a"
  
  x[7]: "a"
  y[7]: "c"
  
  -- 7. Failure: wrap: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("c", "b", "a")[lay$PANEL].
  2/3 mismatches
  x[1]: "a"
  y[1]: "c"
  
  x[3]: "c"
  y[3]: "a"
  
  -- 8. Failure: wrap: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("a", "c", "b")[lay$PANEL].
  2/3 mismatches
  x[2]: "b"
  y[2]: "c"
  
  x[3]: "c"
  y[3]: "b"
  
  -- 9. Failure: wrap: facet order follows default data frame order (@test-compile
  as.character(lay$fx) not equal to c("c", "b", "a")[lay$PANEL].
  2/3 mismatches
  x[1]: "a"
  y[1]: "c"
  
  x[3]: "c"
  y[3]: "a"
  
  [1] "geom line"
  [1] "plot named timexxx"
  [1] "plot names"
  [1] "geom_point(aes(fill=numeric))"
  [1] "compiler print"
  [1] "save separate chunks"
  -- 10. Failure: identity scale preserves input values (@test-compiler-scales.r#6
  d1$size not equal to as.numeric(df$z).
  3/3 mismatches (average diff: NaN)
  [1] 1 - NA == NA
  [2] 2 - NA == NA
  [3] 3 - NA == NA
  
  -- 11. Failure: identity scale preserves input values (@test-compiler-scales.r#6
  d1$alpha not equal to as.numeric(df$z).
  3/3 mismatches (average diff: NaN)
  [1] 1 - NA == NA
  [2] 2 - NA == NA
  [3] 3 - NA == NA
  
  [1] "selectors"
  [1] "stat_summary"
  [1] "compiler unlink previous"
  == testthat results ===========================================================
  [ OK: 740 | SKIPPED: 7 | WARNINGS: 13 | FAILED: 11 ]
  1. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#118)
  2. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#119)
  3. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#126)
  4. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#127)
  5. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#134)
  6. Failure: grid: facet order follows default data frame order (@test-compiler-facet-locate.r#135)
  7. Failure: wrap: facet order follows default data frame order (@test-compiler-facet-locate.r#148)
  8. Failure: wrap: facet order follows default data frame order (@test-compiler-facet-locate.r#154)
  9. Failure: wrap: facet order follows default data frame order (@test-compiler-facet-locate.r#160)
  1. ...
  
  Error: testthat unit tests failed
  Execution halted

@tdhock
Copy link
Collaborator Author

tdhock commented Mar 26, 2020

also need to fix:

@tdhock tdhock mentioned this pull request May 15, 2020
@lazycipher
Copy link
Collaborator

I've added a commit with the working driver functions.
Here's the output of tests when used phantomjs and firefox..
Output on Firefox
Output on PhantomJS

Such errors needed to be fixed: https://gist.github.com/lazycipher/2e3d48b16de3a44969ebf84e7481a212#file-output-L32
https://gist.github.com/lazycipher/2e3d48b16de3a44969ebf84e7481a212#file-output-L44

@tdhock
Copy link
Collaborator Author

tdhock commented May 26, 2020

hi for this one you need to figure out where the Rmd file is being generated, try to run the code line by line yourself, where does the Rmd show up?

[1] "knitting multiple animint plots in a single Rmd"
-- 1. Error: (unknown) (@test-renderer1-knit-print.R#12)  ----------------------
The file 'animint-htmltest/index.Rmd' does not exist.

@tdhock
Copy link
Collaborator Author

tdhock commented May 26, 2020

for most of the other ones looks like you are missing some data sets.

[1] "malaria data viz"
-- 3. Error: (unknown) (@test-renderer1-malaria.R#19)  -------------------------
object 'malaria' not found

these files are all in https://github.com/tdhock/animint2/tree/master/data but they are not included in the "built" version of the package which is created by this script https://github.com/tdhock/animint2/blob/master/build.sh because we need to reduce pkg size for upload to CRAN. However these tests should run fine on travis / your machine (don't delete these data sets)

@tdhock
Copy link
Collaborator Author

tdhock commented May 26, 2020

on CRAN we only run the "compiler" test files https://github.com/tdhock/animint2/blob/master/build.sh#L24

@lazycipher
Copy link
Collaborator

  • I checked about the 1st error i.e Rmd file one. Checking code line by line:
Rmd.file <- system.file("examples", "test_knit_print.Rmd", package = "animint2")
index.file <- file.path("animint-htmltest", "index.Rmd")
file.copy(Rmd.file, index.file, overwrite=TRUE)

After running these commands the value of Rmd.file is empty "" while the value of index.file is a path "animint-htmltest/index.Rmd" and the output of 3rd line using file.copy method returns FALSE which shows that the needed example Rmd file isn't available in animint2 package.

  • By default on installing the package, this is what exists in the directory of the package.
.
├── data
│   ├── datalist
│   ├── Rdata.rdb
│   ├── Rdata.rds
│   └── Rdata.rdx
├── DESCRIPTION
├── help
│   ├── aliases.rds
│   ├── animint2.rdb
│   ├── animint2.rdx
│   ├── AnIndex
│   └── paths.rds
├── html
│   ├── 00Index.html
│   └── R.css
├── htmljs
│   ├── animint.js
│   ├── index.html
│   ├── scripts.html
│   ├── styles.css
│   └── vendor
│       ├── d3.v3.js
│       ├── jquery-1.11.3.min.js
│       ├── selectize.css
│       └── selectize.min.js
├── INDEX
├── Meta
│   ├── data.rds
│   ├── features.rds
│   ├── hsearch.rds
│   ├── links.rds
│   ├── nsInfo.rds
│   ├── package.rds
│   └── Rd.rds
├── NAMESPACE
├── NEWS
├── R
│   ├── animint2
│   ├── animint2.rdb
│   └── animint2.rdx
└── shiny
    └── shinyAnimint.js

8 directories, 34 files

The datalist file in data directory doesn't contain the term malaria so I'm assuming it's not bundled along with our package. So how it's supposed to be working on local machine?

@tdhock
Copy link
Collaborator Author

tdhock commented May 27, 2020

first of all please use system.file(mustWork=TRUE) so you get an error (instead of an empty string) when the file does not exist.

second of all those data files do exist in the github repo, so they must be getting lost somewhere in the package installation. How is the package being installed? If build.sh is being used then that is a problem because it deletes some data files which are necessary for testing on Travis (but which are too large for CRAN). Please use R CMD INSTALL path/to/animint2-directory

@lazycipher
Copy link
Collaborator

Okay got it! I was installing using the archive tar file. But now installed using the repo code as you told me.
This is the output I'm getting. OUTPUT
I'm looking into it! Please let me know if there's any suggestion.

@tdhock
Copy link
Collaborator Author

tdhock commented May 28, 2020

ok there still seem to be several failures, can you please investigate for each failure please determine whether it is

  • a false positive test failure, so actually there is no problem with the rendered data viz, and we should change the test code.
  • a true test failure, so there is some problem with the rendered data viz, and we should change the rendering code.

At some point in time all of these tests were passing, so I suspect that most of these are true test failures, and there are some minor changes to the rendering code that we must do.

It is helpful to use a browser with developer tools for the headless browser testing, so you can inspect the rendered html and see what it looks like, have you ever done that? https://developer.mozilla.org/en-US/docs/Tools

@lazycipher
Copy link
Collaborator

Yes I've used developer tools.
I'll follow and update you as soon as possible.

@lazycipher
Copy link
Collaborator

@tdhock, I'm getting this error when using geom_point() from animint2.
Please confirm if it's working fine on your system or not.

scatter <- ggplot()+
+   geom_point(
+     mapping=aes(x=life.expectancy, y=fertility.rate, color=region),
+     data=WorldBank1975)
> scatter
Error in unit(unclass(x), attr(x, "unit"), attr(x, "data")) : 
  Invalid unit
In addition: Warning message:
Removed 27 rows containing missing values (geom_point). 

Following this simple example: Example
It gives same error when used different functions.

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 2, 2020

yes this is a known issue with R-4 #31 so please investigate and fix. ggplot2 fixed these grid unit related issues already so you should check their code e.g. https://github.com/tidyverse/ggplot2/blob/master/R/margins.R to see how they fixed it.

@lazycipher
Copy link
Collaborator

Thanks for letting me know. Let me look around to solve this issue.

@lazycipher
Copy link
Collaborator

Making changes in margin worked. I was working on the issue related to global vars.
Error:

[1] "global variables"
-- 1. Failure: animint.js only defines 1 object, called animint (@test-renderer1
`diff.vars` not identical to "animint".
Lengths differ: 0 is not 1

I found out that the code is written here L16 returns the first entry of array which should return the whole array with all values so that we can calculate the difference.

Updating the function and removing [[1]] makes it work.
vars <- remDr$executeScript(myScript)[[1]] returns:

vars
[1] "close"

while vars <- remDr$executeScript(myScript) returns a list of 221 browser global variables.

Making the change passes the test:

> tests_run(filter = "global")
[1] "global variables"
== testthat results  ===========================================================
[ OK: 1 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 0 ]
>

@lazycipher
Copy link
Collaborator

In the knit-print test. The snippets aren't rendering. May you guide me a bit in what to look for, please?
Screenshot:
screencapture-file-E-GSoC-animint2-tests-testthat-animint-htmltest-index-html-2020-06-04-16_04_29

The code is being executed and the animated vizs are opening in other tabs.

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 4, 2020

great work about the margin fix!
the knit print test is supposed to make sure that rendering animints in the context of Rmd files works.
rendering the Rmd file should result in a web page with one animint displayed after each block of code with an animint.
for example this web page http://members.cbio.mines-paristech.fr/~thocking/animint2-manual/Ch02-ggplot2.html#rendering-with-animint was generated using this Rmd file https://github.com/tdhock/animint-book/edit/master/Ch02-ggplot2.Rmd
does that make sense?
if that is not working any more, maybe there has been some recent breaking changes in knitr?
we should check the NEWS https://github.com/yihui/knitr/releases -- is there any recent changes in knit_print?
you should read the custom print methods vignette https://cran.r-project.org/web/packages/knitr/vignettes/knit_print.html to see how this works. animint2 uses a custom knit_print method, https://github.com/tdhock/animint2/blob/master/R/z_knitr.R

@lazycipher
Copy link
Collaborator

I noticed that many errors are because of clickID not working. I really don't understand why it doesn't work on animint2 generated webpages.
I replaced the clickID function with this JS script and most of them worked.

remDr$executeScript(sprintf("document.getElementById('%s').click()", as.character(id)))

where id is the supplied id to be clicked.

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 9, 2020

hi where are your commits? I don't see any commits since May. Can you please your fixes to this branch?

@lazycipher
Copy link
Collaborator

I haven't committed and pushed! let me do that asap!

@@ -71,6 +71,7 @@ S3method(heightDetails,titleGrob)
S3method(heightDetails,zeroGrob)
S3method(interleave,default)
S3method(interleave,unit)
S3method(knit_print,animint)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @lazycipher this commit fixes the Rmd rendering problems for me. does it work for you?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! It's fixed now!

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 24, 2020

glad to see tests are passing on travis of your fork,but what is the issue/difference?
tdhock/animint2 errors on

$ Rscript -e 'deps <- remotes::dev_package_deps(dependencies = NA);remotes::install_deps(dependencies = TRUE);if (!all(deps$package %in% installed.packages())) { message("missing: ", paste(setdiff(deps$package, installed.packages()), collapse=", ")); q(status = 1, save = "no")}'

Error in utils::download.file(url, path, method = method, quiet = quiet,  : 

  cannot open URL 'https://api.github.com/repos/ropensci/RSelenium/contents/DESCRIPTION?ref=v1.7.4'

Calls: <Anonymous> ... github_DESCRIPTION -> download -> base_download -> base_download_headers

Execution halted

does your fork do that/work on that line?

@lazycipher
Copy link
Collaborator

Yes it's working on forked one. The only difference I can see is the url that is being called. It includes the DESCRIPTION?ref= in main repo.

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 24, 2020

hi maybe you should remove this line in the DESCRIPTION which tells devtools to install a specific (maybe incompatible?) version of RSelenium

Remotes: ropensci/RSelenium@22f06b9f2a675015d0daa3318319044e4e60d2fa

DESCRIPTION Outdated
rpart,
svglite
Enhances: sp
Remotes: ropensci/RSelenium@v1.7.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tdhock, I've already changed this version thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in your fork do you have @v1.7.4? i'm confused

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I pushed the same in r4-fixes branch in this repo as well.
https://travis-ci.org/github/lazycipher/animint2/jobs/701227388#L1067

@lazycipher
Copy link
Collaborator

lazycipher commented Jun 24, 2020

@tdhock, Can you check if there's any config you changed in your Travis dashboard, please?

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 24, 2020

not sure what may have changed, but can't you check because you are a collaborator? https://stackoverflow.com/questions/25857012/is-it-possible-to-set-up-travis-for-a-project-for-which-you-are-a-collaborator

@lazycipher
Copy link
Collaborator

lazycipher commented Jun 25, 2020

I looked and found the only difference was an env variable GITHUB_PAT and I don't know what it helps in.
Screenshot from 2020-06-25 17-15-29

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 25, 2020

GITHUB_PAT is for the gist test (allows travis to post a gist)

@lazycipher
Copy link
Collaborator

@tdhock, Okay! Got you!
I really don't understand why the same thing works on forked one while it doesn't on the main one!
https://travis-ci.org/github/lazycipher/animint2/jobs/701227388#L1067

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 25, 2020

I don't understand either.
If you can't get it to work, it is ok to continue work during GSOC using your fork.

@lazycipher
Copy link
Collaborator

@tdhock sounds good!
let me move ahead then!

@tdhock
Copy link
Collaborator Author

tdhock commented Jun 27, 2020

once you do get your fork working please do try to port the changes back here (maybe in a new branch/pr?)

@lazycipher
Copy link
Collaborator

sounds good to me! if you say, I can push commits to this branch only.

@lazycipher
Copy link
Collaborator

@tdhock, Looks like the secure token specified in travis.yml was revoked or expired.
I changed that and It worked.

@lazycipher
Copy link
Collaborator

@faizan-khan-iit, Should we merge this branch to master as all tests are passing?

@tdhock
Copy link
Collaborator Author

tdhock commented Aug 5, 2020

great thanks for the update please merge

@lazycipher
Copy link
Collaborator

Thank you so much!
Merging!

@lazycipher lazycipher merged commit 522b5b9 into master Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants