From f4c2107b39178e739bb2f29d84a10a9c9f3a6bc4 Mon Sep 17 00:00:00 2001 From: Zacharias Steinmetz Date: Tue, 5 Sep 2023 15:30:41 +0200 Subject: [PATCH] Set data.table threads to 2 for package checks (#139) * Seems to pass CRAN checks now (tested with rhub) * Submit v1.0.2 --- CRAN-SUBMISSION | 6 +- DESCRIPTION | 4 +- NEWS.md | 7 +++ R/def_features.R | 1 + R/interactive_plots.R | 1 + R/read_multi.R | 1 + README.md | 2 +- man/def_features.Rd | 1 + man/interactive_plots.Rd | 1 + man/read_multi.Rd | 1 + tests/testthat.R | 3 + tests/testthat/test-adj_range.R | 2 - tests/testthat/test-as_OpenSpecy.R | 2 - tests/testthat/test-conform_spec.R | 2 - tests/testthat/test-gen_OpenSpecy.R | 1 - tests/testthat/test-io_spec.R | 6 +- tests/testthat/test-manage_spec.R | 1 - tests/testthat/test-read_ext.R | 2 - vignettes/sop.Rmd | 2 + vignettes/sop.html | 86 ++++++++++++++--------------- 20 files changed, 69 insertions(+), 63 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 3bdf6072..cc039433 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.0.1 -Date: 2023-09-04 13:32:12 UTC -SHA: 0ae4952382c771ea3f729f1303fd6431182d7d95 +Version: 1.0.2 +Date: 2023-09-05 13:16:55 UTC +SHA: 92ce663a7883e3c9886fb7c2ada24fd7deb4c49b diff --git a/DESCRIPTION b/DESCRIPTION index 6a3ec7a2..ab60e6d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: OpenSpecy Type: Package Title: Analyze, Process, Identify, and Share Raman and (FT)IR Spectra -Version: 1.0.1 -Date: 2023-09-04 +Version: 1.0.2 +Date: 2023-09-05 Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"), email = "wincowger@gmail.com", comment = c(ORCID = "0000-0001-9226-3104")), diff --git a/NEWS.md b/NEWS.md index 9f5e0578..f06a9276 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# OpenSpecy 1.0.2 + +## Bug Fixes + +- Set data.table threads to 2 for (CRAN) checks + + # OpenSpecy 1.0.1 ## Bug Fixes diff --git a/R/def_features.R b/R/def_features.R index ce71a989..0b167299 100644 --- a/R/def_features.R +++ b/R/def_features.R @@ -19,6 +19,7 @@ #' collapsed for the features. #' #' @examples +#' \dontshow{data.table::setDTthreads(2)} #' tiny_map <- read_extdata("CA_tiny_map.zip") |> read_any() #' identified_map <- def_features(tiny_map, tiny_map$metadata$x == 0) #' collapse_spec(identified_map) diff --git a/R/interactive_plots.R b/R/interactive_plots.R index 034cc817..117f3be7 100644 --- a/R/interactive_plots.R +++ b/R/interactive_plots.R @@ -41,6 +41,7 @@ #' spectra from the \code{OpenSpecy} object(s). #' #' @examples +#' \dontshow{data.table::setDTthreads(2)} #' data("raman_hdpe") #' tiny_map <- read_extdata("CA_tiny_map.zip") |> read_zip() #' plotly_spec(raman_hdpe) diff --git a/R/read_multi.R b/R/read_multi.R index 7dbc10d3..ba101e63 100644 --- a/R/read_multi.R +++ b/R/read_multi.R @@ -19,6 +19,7 @@ #' All \code{read_*()} functions return \code{OpenSpecy} objects #' #' @examples +#' \dontshow{data.table::setDTthreads(2)} #' read_extdata("raman_hdpe.csv") |> read_any() #' read_extdata("ftir_ldpe_soil.asp") |> read_any() #' read_extdata("testdata_zipped.zip") |> read_zip() diff --git a/README.md b/README.md index face4a37..dd5e34dd 100644 --- a/README.md +++ b/README.md @@ -102,5 +102,5 @@ Needs an Open Source Community: Open Specy to the Rescue!” [10.1021/acs.analchem.1c00123](https://doi.org/10.1021/acs.analchem.1c00123). Cowger W, Steinmetz Z (2023). “OpenSpecy: Analyze, Process, -Identify, and Share Raman and (FT)IR Spectra.” *R package*, **1.0.1**. +Identify, and Share Raman and (FT)IR Spectra.” *R package*, **1.0.2**. [https://github.com/wincowgerDEV/OpenSpecy-package](https://github.com/wincowgerDEV/OpenSpecy-package). diff --git a/man/def_features.Rd b/man/def_features.Rd index f358a1ff..0071ce89 100644 --- a/man/def_features.Rd +++ b/man/def_features.Rd @@ -49,6 +49,7 @@ It also updates the metadata with centroid coordinates, while preserving the feature information on area and Feret max. } \examples{ +\dontshow{data.table::setDTthreads(2)} tiny_map <- read_extdata("CA_tiny_map.zip") |> read_any() identified_map <- def_features(tiny_map, tiny_map$metadata$x == 0) collapse_spec(identified_map) diff --git a/man/interactive_plots.Rd b/man/interactive_plots.Rd index e7677990..82b906ad 100644 --- a/man/interactive_plots.Rd +++ b/man/interactive_plots.Rd @@ -118,6 +118,7 @@ These functions generate heatmaps, spectral plots, and interactive plots for OpenSpecy data. } \examples{ +\dontshow{data.table::setDTthreads(2)} data("raman_hdpe") tiny_map <- read_extdata("CA_tiny_map.zip") |> read_zip() plotly_spec(raman_hdpe) diff --git a/man/read_multi.Rd b/man/read_multi.Rd index 6d3bcdd6..3e220879 100644 --- a/man/read_multi.Rd +++ b/man/read_multi.Rd @@ -29,6 +29,7 @@ with ENVI file format or as individual files in a zip folder. If individual files, spectra are concatenated. } \examples{ +\dontshow{data.table::setDTthreads(2)} read_extdata("raman_hdpe.csv") |> read_any() read_extdata("ftir_ldpe_soil.asp") |> read_any() read_extdata("testdata_zipped.zip") |> read_zip() diff --git a/tests/testthat.R b/tests/testthat.R index 828ce133..73fbe078 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,7 @@ library(testthat) library(OpenSpecy) +library(data.table) +setDTthreads(2) + test_check("OpenSpecy") diff --git a/tests/testthat/test-adj_range.R b/tests/testthat/test-adj_range.R index 96c00bdf..dd14aa61 100644 --- a/tests/testthat/test-adj_range.R +++ b/tests/testthat/test-adj_range.R @@ -1,5 +1,3 @@ -library(data.table) - test_that("flatten_range() error handling", { test <- as_OpenSpecy(x = 1:10, spectra = data.table(V1 = 1:10)) diff --git a/tests/testthat/test-as_OpenSpecy.R b/tests/testthat/test-as_OpenSpecy.R index 9383e82d..4ceae631 100644 --- a/tests/testthat/test-as_OpenSpecy.R +++ b/tests/testthat/test-as_OpenSpecy.R @@ -1,5 +1,3 @@ -library(data.table) - data("raman_hdpe") df <- read_extdata("raman_hdpe.csv") |> read.csv() diff --git a/tests/testthat/test-conform_spec.R b/tests/testthat/test-conform_spec.R index 3526dc1b..fddf9723 100644 --- a/tests/testthat/test-conform_spec.R +++ b/tests/testthat/test-conform_spec.R @@ -1,5 +1,3 @@ -library(data.table) - data("raman_hdpe") test_that("conform_spec() throws an error for non-OpenSpecy objects", { diff --git a/tests/testthat/test-gen_OpenSpecy.R b/tests/testthat/test-gen_OpenSpecy.R index b40f999c..e31ff403 100644 --- a/tests/testthat/test-gen_OpenSpecy.R +++ b/tests/testthat/test-gen_OpenSpecy.R @@ -1,4 +1,3 @@ -library(data.table) data("raman_hdpe") csv <- read_extdata("raman_hdpe.csv") |> read.csv() diff --git a/tests/testthat/test-io_spec.R b/tests/testthat/test-io_spec.R index e0602e3b..90bf8c3c 100644 --- a/tests/testthat/test-io_spec.R +++ b/tests/testthat/test-io_spec.R @@ -1,11 +1,9 @@ -# Loading test data -data(raman_hdpe) - # Create temp dir for testthat tmp <- file.path(tempdir(), "OpenSpecy-testthat") dir.create(tmp, showWarnings = F) -library(data.table) +# Loading test data +data(raman_hdpe) test_that("extdata files are present", { ed <- read_extdata() diff --git a/tests/testthat/test-manage_spec.R b/tests/testthat/test-manage_spec.R index 46125d98..5c9d1a66 100644 --- a/tests/testthat/test-manage_spec.R +++ b/tests/testthat/test-manage_spec.R @@ -1,4 +1,3 @@ -library(data.table) data("raman_hdpe") specs <- lapply(c(read_extdata("raman_hdpe.yml"), diff --git a/tests/testthat/test-read_ext.R b/tests/testthat/test-read_ext.R index 67b6004d..a0fe2af4 100644 --- a/tests/testthat/test-read_ext.R +++ b/tests/testthat/test-read_ext.R @@ -2,8 +2,6 @@ tmp <- file.path(tempdir(), "OpenSpecy-testthat") dir.create(tmp, showWarnings = F) -library(data.table) - data("raman_hdpe") test_that("extdata files are present", { diff --git a/vignettes/sop.Rmd b/vignettes/sop.Rmd index 5162a647..a72b098b 100644 --- a/vignettes/sop.Rmd +++ b/vignettes/sop.Rmd @@ -16,6 +16,8 @@ knitr::opts_chunk$set( comment = "#>", warning = FALSE ) + +data.table::setDTthreads(2) ``` # Document Overview diff --git a/vignettes/sop.html b/vignettes/sop.html index c4eeef64..5f181d47 100644 --- a/vignettes/sop.html +++ b/vignettes/sop.html @@ -11,7 +11,7 @@ - + Open Specy Package Tutorial @@ -2265,7 +2265,7 @@

Open Specy Package Tutorial

Win Cowger, Zacharias Steinmetz

-

2023-09-03

+

2023-09-05

@@ -2383,21 +2383,21 @@

Read Data

# Access the spectra
 scratch_OpenSpecy$spectra
 #>      runif.n...201.
-#>   1:      0.1815802
-#>   2:      0.6254903
-#>   3:      0.3591791
-#>   4:      0.4808269
-#>   5:      0.8114175
+#>   1:      0.4410329
+#>   2:      0.5256822
+#>   3:      0.2287054
+#>   4:      0.2914207
+#>   5:      0.9443179
 #>  ---               
-#> 197:      0.1298203
-#> 198:      0.3499974
-#> 199:      0.5182786
-#> 200:      0.5913277
-#> 201:      0.5329917
+#> 197: 0.2062708 +#> 198: 0.3752062 +#> 199: 0.3591172 +#> 200: 0.9028912 +#> 201: 0.6674249
# Access the metadata
 scratch_OpenSpecy$metadata
 #>    x y  file_name                          file_id         col_id
-#> 1: 1 1 fake_noise 63394fb9d279c1fd2fc4d3ac660dc3b2 runif.n...201.
+#> 1: 1 1 fake_noise 52ca18b9d0bbd6a3b5f208e77b43ae8f runif.n...201.
# Performs checks to ensure that OpenSpecy objects are adhering to our standards;
 # returns TRUE if it passes. 
 check_OpenSpecy(scratch_OpenSpecy)
@@ -2409,21 +2409,21 @@ 

Read Data

We have some generic functions built for inspecting the spectra:

print(scratch_OpenSpecy) # shows the raw object
 #>      wavenumber runif.n...201.
-#>   1:       1000      0.1815802
-#>   2:       1005      0.6254903
-#>   3:       1010      0.3591791
-#>   4:       1015      0.4808269
-#>   5:       1020      0.8114175
+#>   1:       1000      0.4410329
+#>   2:       1005      0.5256822
+#>   3:       1010      0.2287054
+#>   4:       1015      0.2914207
+#>   5:       1020      0.9443179
 #>  ---                          
-#> 197:       1980      0.1298203
-#> 198:       1985      0.3499974
-#> 199:       1990      0.5182786
-#> 200:       1995      0.5913277
-#> 201:       2000      0.5329917
+#> 197:       1980      0.2062708
+#> 198:       1985      0.3752062
+#> 199:       1990      0.3591172
+#> 200:       1995      0.9028912
+#> 201:       2000      0.6674249
 #> 
 #> $metadata
 #>    x y  file_name                          file_id         col_id
-#> 1: 1 1 fake_noise 63394fb9d279c1fd2fc4d3ac660dc3b2 runif.n...201.
+#> 1: 1 1 fake_noise 52ca18b9d0bbd6a3b5f208e77b43ae8f runif.n...201.
summary(scratch_OpenSpecy) # summarizes the contents of the spectra
 #> $wavenumber
 #>  Length Min. Max. Res.
@@ -2431,7 +2431,7 @@ 

Read Data

#> #> $spectra #> Number Min. Intensity Max. Intensity -#> 1 0.004187569 0.9860589 +#> 1 0.009082985 0.9867296 #> #> $metadata #> Min. Max. @@ -2440,12 +2440,12 @@

Read Data

#> [1] "x" "y" "file_name" "file_id" "col_id"
head(scratch_OpenSpecy) # shows the top wavenumbers and intensities
 #>    wavenumber runif.n...201.
-#> 1:       1000      0.1815802
-#> 2:       1005      0.6254903
-#> 3:       1010      0.3591791
-#> 4:       1015      0.4808269
-#> 5:       1020      0.8114175
-#> 6:       1025      0.7978346
+#> 1: 1000 0.4410329 +#> 2: 1005 0.5256822 +#> 3: 1010 0.2287054 +#> 4: 1015 0.2914207 +#> 5: 1020 0.9443179 +#> 6: 1025 0.8042844

Save Data

@@ -2474,14 +2474,14 @@

Spectra

efficient and the other is interactive. Here is an example of quick and efficient plotting.

plot(scratch_OpenSpecy) # quick and efficient
-

+

This is an example of an interactive plot. You can plot two different datasets simultaneously to compare.

# This will min-max normalize your data even if it isn't already but are not
 # changing your underlying data
 plotly_spec(scratch_OpenSpecy, json_example)
-
- +
+

Maps

@@ -2498,16 +2498,16 @@

Maps

values of the spectra.

heatmap_spec(spectral_map,
              z = spectral_map$metadata$x) # will show more advanced example 
-
- +
+
                                          # later in tutorial

An interactive plot of the heatmap and spectra overlayed can be generated with the interactive_plot() function. A user can hover over the heatmap to identify the next row id they are interested in and update the value of select to see that spectrum.

interactive_plot(spectral_map, select = 100, z = spectral_map$metadata$x)
-
- +
+
@@ -2556,7 +2556,7 @@

Sampling OpenSpecy Objects

sample_spec function serves this purpose.

sample_spec(spectral_map,size = 10) |>
   plot()
-

+

Processing

@@ -2666,8 +2666,8 @@

Threshold Signal-Noise

spectral_map_p$metadata$sig_noise <- sig_noise(spectral_map_p) heatmap_spec(spectral_map_p, sn = spectral_map_p$metadata$sig_noise, min_sn = 5)
-
- +
+

Intensity Adjustment

@@ -2685,8 +2685,8 @@

Intensity Adjustment

adj_intens(type = "transmittance") plotly_spec(trans_raman_hdpe, rev_trans_raman_hdpe)
-
- +
+

Conforming