Skip to content

Commit

Permalink
Merge pull request #94 from NIEHS/0.8.0
Browse files Browse the repository at this point in the history
test updates
  • Loading branch information
sigmafelix committed Aug 17, 2024
2 parents 9b22ad8 + 3e6cc46 commit 18490e6
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 193 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test-coverage-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ jobs:
name: covr-report
path: ${{ github.workspace }}/chopin-coverage-report.html

- name: Upload workspace dump as artifact if the test fails
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: test-outputs
path: ${{ github.workspace }}/**

- name: Get Values
id: get-values
shell: bash
Expand Down
12 changes: 6 additions & 6 deletions R/processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ setGeneric("summarize_aw", function(x, y, ...) standardGeneric("summarize_aw"))
#' @export
setMethod("summarize_aw", signature(x = "SpatVector", y = "SpatVector"),
function(
x = NULL,
y = NULL,
x,
y,
target_fields = NULL,
id_x = "ID",
fun = stats::weighted.mean,
Expand Down Expand Up @@ -803,8 +803,8 @@ setMethod("summarize_aw", signature(x = "SpatVector", y = "SpatVector"),
#' @export
setMethod("summarize_aw", signature(x = "character", y = "character"),
function(
x = NULL,
y = NULL,
x,
y,
target_fields = NULL,
id_x = "ID",
fun = stats::weighted.mean,
Expand Down Expand Up @@ -843,8 +843,8 @@ setMethod("summarize_aw", signature(x = "character", y = "character"),
#' @export
setMethod("summarize_aw", signature(x = "sf", y = "sf"),
function(
x = NULL,
y = NULL,
x,
y,
target_fields = NULL,
id_x = "ID",
fun = NULL,
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ graph LR
n83318893 -->|No| n58642837
'
DiagrammeR::mermaid(mermaid_chart_raster, width = 500, height = 1200)
DiagrammeR::mermaid(mermaid_chart_raster, width = 1200, height = 400)
```

```{r flowchart-mermaid-vector, echo = FALSE, eval = (Sys.getenv("IN_GALLEY") == "")}
Expand Down Expand Up @@ -114,7 +114,7 @@ graph LR
n77415399 --> n64849552
'
DiagrammeR::mermaid(mermaid_chart_vector, width = 500, height = 1200)
DiagrammeR::mermaid(mermaid_chart_vector, width = 1200, height = 400)
```


Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ system.time(
)
#> Input is a character. Attempt to read it with terra::rast...
#> user system elapsed
#> 7.177 0.227 7.426
#> 7.205 0.206 7.669
```

#### Generate regular grid computational regions
Expand Down Expand Up @@ -298,7 +298,7 @@ system.time(
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Task at CGRIDID: 4 is successfully dispatched.
#> user system elapsed
#> 0.269 0.007 7.656
#> 0.329 0.021 8.337

ncpoints_srtm <-
extract_at(
Expand Down Expand Up @@ -358,7 +358,7 @@ path_nchrchy <- file.path(wdir, "nc_hierarchy.gpkg")
nc_data <- path_nchrchy
nc_county <- sf::st_read(nc_data, layer = "county")
#> Reading layer `county' from data source
#> `/tmp/RtmpW75c95/temp_libpath2a53f823dd4dd7/chopin/extdata/nc_hierarchy.gpkg'
#> `/tmp/RtmpkigVUL/temp_libpath3cdb0b6b55ee11/chopin/extdata/nc_hierarchy.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 100 features and 1 field
#> Geometry type: POLYGON
Expand All @@ -367,7 +367,7 @@ nc_county <- sf::st_read(nc_data, layer = "county")
#> Projected CRS: NAD83 / Conus Albers
nc_tracts <- sf::st_read(nc_data, layer = "tracts")
#> Reading layer `tracts' from data source
#> `/tmp/RtmpW75c95/temp_libpath2a53f823dd4dd7/chopin/extdata/nc_hierarchy.gpkg'
#> `/tmp/RtmpkigVUL/temp_libpath3cdb0b6b55ee11/chopin/extdata/nc_hierarchy.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 2672 features and 1 field
#> Geometry type: MULTIPOLYGON
Expand Down Expand Up @@ -395,7 +395,7 @@ system.time(
)
#> Input is a character. Attempt to read it with terra::rast...
#> user system elapsed
#> 0.893 0.007 0.902
#> 0.910 0.003 0.916

# hierarchical parallelization
system.time(
Expand Down Expand Up @@ -513,7 +513,7 @@ system.time(
#> Input is a character. Attempt to read it with terra::rast...ℹ Your input function at 37055 is dispatched.
#> Input is a character. Attempt to read it with terra::rast...ℹ Your input function at 37047 is dispatched.
#> user system elapsed
#> 0.222 0.071 2.007
#> 0.258 0.073 2.005
```

### `par_multirasters`: parallelize over multiple rasters
Expand All @@ -540,9 +540,9 @@ terra::writeRaster(ncelev, file.path(tdir, "test5.tif"), overwrite = TRUE)
# check if the raster files were exported as expected
testfiles <- list.files(tdir, pattern = "*.tif$", full.names = TRUE)
testfiles
#> [1] "/tmp/RtmpZf1L16/test1.tif" "/tmp/RtmpZf1L16/test2.tif"
#> [3] "/tmp/RtmpZf1L16/test3.tif" "/tmp/RtmpZf1L16/test4.tif"
#> [5] "/tmp/RtmpZf1L16/test5.tif"
#> [1] "/tmp/Rtmpqu68xF/test1.tif" "/tmp/Rtmpqu68xF/test2.tif"
#> [3] "/tmp/Rtmpqu68xF/test3.tif" "/tmp/Rtmpqu68xF/test4.tif"
#> [5] "/tmp/Rtmpqu68xF/test5.tif"
```

``` r
Expand All @@ -559,32 +559,32 @@ system.time(
)
#> ℹ Input is not a character.
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Your input function at /tmp/RtmpZf1L16/test1.tif is dispatched.
#> ℹ Your input function at /tmp/Rtmpqu68xF/test1.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Your input function at /tmp/RtmpZf1L16/test2.tif is dispatched.
#> ℹ Your input function at /tmp/Rtmpqu68xF/test2.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Your input function at /tmp/RtmpZf1L16/test3.tif is dispatched.
#> ℹ Your input function at /tmp/Rtmpqu68xF/test3.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Your input function at /tmp/RtmpZf1L16/test4.tif is dispatched.
#> ℹ Your input function at /tmp/Rtmpqu68xF/test4.tif is dispatched.
#>
#> Input is a character. Attempt to read it with terra::rast...
#> ℹ Your input function at /tmp/RtmpZf1L16/test5.tif is dispatched.
#> ℹ Your input function at /tmp/Rtmpqu68xF/test5.tif is dispatched.
#> user system elapsed
#> 1.693 0.139 2.764
#> 1.713 0.147 2.747
knitr::kable(head(res))
```

| mean | base_raster |
|----------:|:--------------------------|
| 136.80203 | /tmp/RtmpZf1L16/test1.tif |
| 189.76170 | /tmp/RtmpZf1L16/test1.tif |
| 231.16968 | /tmp/RtmpZf1L16/test1.tif |
| 98.03845 | /tmp/RtmpZf1L16/test1.tif |
| 41.23463 | /tmp/RtmpZf1L16/test1.tif |
| 270.96933 | /tmp/RtmpZf1L16/test1.tif |
| 136.80203 | /tmp/Rtmpqu68xF/test1.tif |
| 189.76170 | /tmp/Rtmpqu68xF/test1.tif |
| 231.16968 | /tmp/Rtmpqu68xF/test1.tif |
| 98.03845 | /tmp/Rtmpqu68xF/test1.tif |
| 41.23463 | /tmp/Rtmpqu68xF/test1.tif |
| 270.96933 | /tmp/Rtmpqu68xF/test1.tif |

``` r
# remove temporary raster files
Expand Down Expand Up @@ -619,7 +619,7 @@ pnts <- sf::st_as_sf(pnts)
pnts$pid <- sprintf("RPID-%04d", seq(1, 5000))
rd1 <- sf::st_read(path_ncrd1)
#> Reading layer `ncroads_first' from data source
#> `/tmp/RtmpW75c95/temp_libpath2a53f823dd4dd7/chopin/extdata/ncroads_first.gpkg'
#> `/tmp/RtmpkigVUL/temp_libpath3cdb0b6b55ee11/chopin/extdata/ncroads_first.gpkg'
#> using driver `GPKG'
#> Simple feature collection with 620 features and 4 fields
#> Geometry type: MULTILINESTRING
Expand Down Expand Up @@ -673,11 +673,11 @@ system.time(
restr <- terra::nearest(x = terra::vect(pntst), y = terra::vect(rd1t))
)
#> user system elapsed
#> 0.598 0.000 0.600
#> 0.603 0.000 0.604

pnt_path <- file.path(tdir, "pntst.gpkg")
sf::st_write(pntst, pnt_path)
#> Writing layer `pntst' to data source `/tmp/RtmpZf1L16/pntst.gpkg' using driver `GPKG'
#> Writing layer `pntst' to data source `/tmp/Rtmpqu68xF/pntst.gpkg' using driver `GPKG'
#> Writing 5000 features with 1 fields and geometry type Point.

# we use four threads that were configured above
Expand Down Expand Up @@ -723,7 +723,7 @@ system.time(
#> ℹ Input is a character. Trying to read with terra .
#> ℹ Task at CGRIDID: 8 is successfully dispatched.
#> user system elapsed
#> 0.075 0.006 0.443
#> 0.085 0.000 0.534
```

- We will compare the results from the single-thread and multi-thread
Expand Down
Binary file modified man/figures/README-flowchart-mermaid-raster-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-flowchart-mermaid-vector-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions man/summarize_aw.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 18490e6

Please sign in to comment.