inbo/inborutils

4 test fail locally

Closed this issue · 9 comments

Discovered as part of #73 (comment):

══ testthat results  ════════════════════════════════════
[ OK: 25 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 4 ]
1. Failure: input and output projections are both CRS-class (sp points) (@test-reproject_coordinates.R#143) 
2. Failure: input projections of CRS-class (sp points), output of crs-class (sf points) (@test-reproject_coordinates.R#148) 
3. Failure: input projections of crs-class (sf points), output of CRS-class (sp points) (@test-reproject_coordinates.R#153) 
4. Failure: input and output projections are both crs-class (sf points) (@test-reproject_coordinates.R#158) 
devtools::session_info()
Session info ──────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       macOS Mojave 10.14.6        
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Brussels             
 date     2020-02-18Packages ──────────────────────────────────────────────────────────────────────────────────────
 ! package     * version    date       lib source                        
   assertable    0.2.7      2019-09-21 [1] CRAN (R 3.6.0)                
   assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                
   backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.0)                
   bit           1.1-15.1   2020-01-14 [1] CRAN (R 3.6.0)                
   bit64         0.9-7      2017-05-08 [1] CRAN (R 3.6.0)                
   blob          1.2.1      2020-01-20 [1] CRAN (R 3.6.0)                
   callr         3.4.1      2020-01-24 [1] CRAN (R 3.6.0)                
   class         7.3-15     2019-01-01 [1] CRAN (R 3.6.0)                
   classInt      0.4-2      2019-10-17 [1] CRAN (R 3.6.0)                
   cli           2.0.1      2020-01-08 [1] CRAN (R 3.6.0)                
   colorspace    1.4-1      2019-03-18 [1] CRAN (R 3.6.0)                
   commonmark    1.7        2018-12-01 [1] CRAN (R 3.6.0)                
   crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                
   crosstalk     1.0.0      2016-12-21 [1] CRAN (R 3.6.0)                
   curl          4.3        2019-12-02 [1] CRAN (R 3.6.0)                
   data.table    1.12.8     2019-12-09 [1] CRAN (R 3.6.0)                
   DBI           1.1.0      2019-12-15 [1] CRAN (R 3.6.0)                
   desc          1.2.0      2018-05-01 [1] CRAN (R 3.6.0)                
   devtools      2.2.1      2019-09-24 [1] CRAN (R 3.6.0)                
   digest        0.6.24     2020-02-12 [1] CRAN (R 3.6.0)                
   dplyr         0.8.4      2020-01-31 [1] CRAN (R 3.6.0)                
   e1071         1.7-3      2019-11-26 [1] CRAN (R 3.6.0)                
   ellipsis      0.3.0      2019-09-20 [1] CRAN (R 3.6.0)                
   fansi         0.4.1      2020-01-08 [1] CRAN (R 3.6.0)                
   fastmap       1.0.1      2019-10-08 [1] CRAN (R 3.6.0)                
   fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.0)                
   geoaxe        0.1.0      2016-02-19 [1] CRAN (R 3.6.0)                
   ggplot2       3.2.1      2019-08-10 [1] CRAN (R 3.6.0)                
   glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                
   gtable        0.3.0      2019-03-25 [1] CRAN (R 3.6.0)                
   hms           0.5.3      2020-02-03 [1] Github (tidyverse/hms@1bd14da)
   htmltools     0.4.0      2019-10-04 [1] CRAN (R 3.6.0)                
   htmlwidgets   1.5.1      2019-10-08 [1] CRAN (R 3.6.0)                
   httpuv        1.5.2      2019-09-11 [1] CRAN (R 3.6.0)                
   httr          1.4.1      2019-08-05 [1] CRAN (R 3.6.0)                
 R inborutils  * 0.1.0.9072 <NA>       [?] <NA>                          
   iterators     1.0.12     2019-07-26 [1] CRAN (R 3.6.0)                
   jsonlite      1.6.1      2020-02-02 [1] CRAN (R 3.6.0)                
   KernSmooth    2.23-16    2019-10-15 [1] CRAN (R 3.6.0)                
   later         1.0.0      2019-10-04 [1] CRAN (R 3.6.0)                
   lattice       0.20-38    2018-11-04 [1] CRAN (R 3.6.0)                
   lazyeval      0.2.2      2019-03-15 [1] CRAN (R 3.6.0)                
   leaflet       2.0.3      2019-11-16 [1] CRAN (R 3.6.0)                
   lifecycle     0.1.0      2019-08-01 [1] CRAN (R 3.6.0)                
   lubridate     1.7.4      2018-04-11 [1] CRAN (R 3.6.0)                
   magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)                
   memoise       1.1.0      2017-04-21 [1] CRAN (R 3.6.0)                
   mime          0.9        2020-02-04 [1] CRAN (R 3.6.0)                
   munsell       0.5.0      2018-06-12 [1] CRAN (R 3.6.0)                
   oai           0.3.0      2019-09-07 [1] CRAN (R 3.6.0)                
   odbc          1.2.2      2020-01-10 [1] CRAN (R 3.6.0)                
   pillar        1.4.3      2019-12-20 [1] CRAN (R 3.6.0)                
   pkgbuild      1.0.6      2019-10-09 [1] CRAN (R 3.6.0)                
   pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 3.6.0)                
   pkgload       1.0.2      2018-10-29 [1] CRAN (R 3.6.0)                
   plyr          1.8.5      2019-12-10 [1] CRAN (R 3.6.0)                
   prettyunits   1.1.1      2020-01-24 [1] CRAN (R 3.6.0)                
   processx      3.4.1      2019-07-18 [1] CRAN (R 3.6.0)                
   promises      1.1.0      2019-10-04 [1] CRAN (R 3.6.0)                
   ps            1.3.0      2018-12-21 [1] CRAN (R 3.6.0)                
   purrr         0.3.3      2019-10-18 [1] CRAN (R 3.6.0)                
   R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.0)                
   Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.0)                
   readr         1.3.1      2018-12-21 [1] CRAN (R 3.6.0)                
   remotes       2.1.0      2019-06-24 [1] CRAN (R 3.6.0)                
   rgbif         2.0.0      2020-01-31 [1] CRAN (R 3.6.0)                
   rgdal         1.4-8      2019-11-27 [1] CRAN (R 3.6.0)                
   rgeos         0.5-2      2019-10-03 [1] CRAN (R 3.6.0)                
   rlang         0.4.4      2020-01-28 [1] CRAN (R 3.6.0)                
   roxygen2      7.0.2      2019-12-02 [1] CRAN (R 3.6.0)                
   rprojroot     1.3-2      2018-01-03 [1] CRAN (R 3.6.0)                
   RSQLite       2.2.0      2020-01-07 [1] CRAN (R 3.6.0)                
   rstudioapi    0.11       2020-02-07 [1] CRAN (R 3.6.0)                
   scales        1.1.0      2019-11-18 [1] CRAN (R 3.6.0)                
   sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                
   sf            0.8-1      2020-01-28 [1] CRAN (R 3.6.0)                
   shiny         1.4.0      2019-10-10 [1] CRAN (R 3.6.0)                
   sp            1.3-2      2019-11-07 [1] CRAN (R 3.6.0)                
   stringi       1.4.5      2020-01-11 [1] CRAN (R 3.6.0)                
   stringr       1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                
   testthat      2.3.1      2019-12-01 [1] CRAN (R 3.6.0)                
   tibble        2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                
   tidyr         1.0.2      2020-01-24 [1] CRAN (R 3.6.0)                
   tidyselect    1.0.0      2020-01-27 [1] CRAN (R 3.6.0)                
   units         0.6-5      2019-10-08 [1] CRAN (R 3.6.0)                
   usethis       1.5.1      2019-07-04 [1] CRAN (R 3.6.0)                
   vctrs         0.2.2      2020-01-24 [1] CRAN (R 3.6.0)                
   whisker       0.4        2019-08-28 [1] CRAN (R 3.6.0)                
   withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                
   xml2          1.2.2      2019-08-09 [1] CRAN (R 3.6.0)                
   xtable        1.8-4      2019-04-21 [1] CRAN (R 3.6.0)                

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

 R ── Package was removed from disk.

I can confirm the issue on my machine, the error messages seems a bit more complete, so I include them below:

test-reproject_coordinates.R:143: failure: input and output projections are both CRS-class (sp points)
`data_out_sp_sp` not equal to `read_reproj_df_sp`.
Rows in x but not y: 1. Rows in y but not x: 1. 

test-reproject_coordinates.R:148: failure: input projections of CRS-class (sp points), output of crs-class (sf points)
`data_out_sp_sf` not equal to `read_reproj_df_sf`.
Incompatible type for column `lat`: x matrix, y numeric
Incompatible type for column `lon`: x matrix, y numeric

test-reproject_coordinates.R:153: failure: input projections of crs-class (sf points), output of CRS-class (sp points)
`data_out_sf_sp` not equal to `read_reproj_df_sp`.
Rows in x but not y: 1. Rows in y but not x: 1. 

test-reproject_coordinates.R:158: failure: input and output projections are both crs-class (sf points)
`data_out_sf_sf` not equal to `read_reproj_df_sf`.
Incompatible type for column `lat`: x matrix, y numeric
Incompatible type for column `lon`: x matrix, y numeric

I will give a look. Thanks for reporting and reminding me.

This may have to do with current migrations in sf, sp and rgdal, in response to upcoming PROJ and GDAL upgrades (https://gdalbarn.com/).

Learn more about it in:

In the case of this reprojecting function, maybe you can take advantage of Michael Summer's reproj package, where he has also made an issue on PROJ 6 checks.

Actually I found the source of all the problems.
The function does NOT return a data.frame but a "special" df.

> class(data_out_sp_sf)
[1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame" 

If input is of class data.frame then it's fine. The problem is when input is a tibble data.frame. Then spec_tbl_df occurs in the output.

This is wrong. The output should be a data.frame as the input. I will solve this in this PR.

That is a data.frame in the sense that it inherits a data.frame. Check inherits(data_out_sp_sf, "data.frame"), it should be TRUE.

Yes, @ThierryO , thanks.

From readr documentation:

readr now returns results with a spec_tbl_df subclass. This differs from a regular tibble only in that the spec attribute (which holds the column specification) is lost as soon as the object is subset and a normal tbl_df object is returned.

@niconoe , I think I found it. It should be

as.data.frame(st_coordinates(df_reproj))

as st_coordinates returns matrices.

I will check further.

@peterdesmet , I think this issue can be closed (see merged PR #82). Do you still encounter problems with those tests?

Yes, I now only get 3 warning if I run devtools::test()