Skip to content

testing error with reticulate #24

@joshualerickson

Description

@joshualerickson

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    testingWorking with testhatwatchKeep an eye on issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions