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

testing error with reticulate #24

Open
joshualerickson opened this issue Jun 30, 2022 · 1 comment
Open

testing error with reticulate #24

joshualerickson opened this issue Jun 30, 2022 · 1 comment
Labels
testing Working with testhat watch Keep an eye on issue

Comments

@joshualerickson
Copy link
Collaborator

I'm getting this error below when running the tests within the testthat framework. For instance, I can run the code outside of the function test_that and the error doesn't occur. It only occurs when running the test... I also get there error in Base R. I'll just block it out for now but keep an eye out for when summarise has year, month and multiple years for landsat.

library(testthat)
library(tidyrgee)
#> 
#> Attaching package: 'tidyrgee'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(rgee)
ee_Initialize()
#> -- rgee 1.1.2 --------------------------------------- earthengine-api 0.1.312 -- 
#>  v user: not_defined
#>  v Initializing Google Earth Engine: v Initializing Google Earth Engine:  DONE!
#>  v Earth Engine account: users/joshualerickson 
#> --------------------------------------------------------------------------------

test_that("working with summarise by filter and grouping", {
  
  ## Landsat 8
  roi <- ee$Geometry$Point(-114.275, 45.891)
  
  
  ld_ic = ee$ImageCollection("LANDSAT/LC08/C01/T1_SR")$filterBounds(roi)
  
  # with == and year
  filter_year_month <- ld_ic %>%
    as_tidyee() %>%
    filter(year == 2018) %>%
    group_by(year, month) %>%
    summarise(stat = c('mean', 'median'))
  
  meta <- filter_year_month$ee_ob$getInfo()
  
  expect_equal(length(meta[["features"]][[1]][["bands"]]), 24)
  
  expect_equal(filter_year_month$vrt$band_names[[1]], c("B1_mean", "B2_mean",
                                                        "B3_mean", "B4_mean",
                                                        "B5_mean", "B6_mean",
                                                        "B7_mean", "B10_mean",
                                                        "B11_mean","sr_aerosol_mean",
                                                        "pixel_qa_mean", "radsat_qa_mean",
                                                        "B1_median", "B2_median",
                                                        "B3_median", "B4_median",
                                                        "B5_median", "B6_median",
                                                        "B7_median", "B10_median",
                                                        "B11_median","sr_aerosol_median",
                                                        "pixel_qa_median","radsat_qa_median" ))
  
  filter_year_month <- ld_ic %>%
    as_tidyee() %>%
    filter(year %in% c(2016:2019)) %>%
    group_by(year, month) %>%
    summarise(stat = c('mean', 'median'))
  
  meta <- filter_year_month$ee_ob$getInfo()
  
  expect_equal(length(meta[["features"]][[1]][["bands"]]), 24)
  
})
#> -- Error (<text>:38:3): working with summarise by filter and grouping ----------
#> <Rcpp::exception/C++Error/error/condition>
#> Error in `py_get_attr_impl(x, name, silent)`: OverflowError: Python int too large to convert to C long
#> Backtrace:
#>   1. ... %>% summarise(stat = c("mean", "median"))
#>   5. tidyrgee::as_tidyee(.)
#>   7. reticulate:::`$.python.builtin.object`(x, "first")
#>   8. reticulate:::py_get_attr_or_item(x, name, TRUE)
#>   9. reticulate::py_get_attr(x, name)
#>  10. reticulate:::py_get_attr_impl(x, name, silent)
#> Error:
#> ! Test failed

Created on 2022-06-29 by the reprex package (v2.0.1)

@joshualerickson joshualerickson added testing Working with testhat watch Keep an eye on issue labels Jun 30, 2022
@zackarno
Copy link
Member

zackarno commented Jul 13, 2022

yeah I ran this code as well and experienced the same as you. Everything works correctly until you put it inside test_that.

As it does not seem to effect the functionality leaving the test out for now seems correct. It looks like another tricky one to understand.

seems likely that it might have some thing to do with large numeric dates:

r-spatial/rgee#79 (comment)

rstudio/reticulate#154 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Working with testhat watch Keep an eye on issue
Projects
None yet
Development

No branches or pull requests

2 participants