Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fbc0814
Create dependabot.yml
GegznaV Mar 22, 2026
67ebe4f
Update R-CMD-check.yaml
GegznaV Mar 22, 2026
0f69f68
Merge branch 'develop' into impove-gha-workflows
GegznaV Mar 22, 2026
ec00d13
Merge branch 'develop' into impove-gha-workflows
GegznaV Mar 22, 2026
359a414
Update .gitignore
GegznaV Mar 22, 2026
f13bb03
Bump RoxygenNote version
GegznaV Mar 22, 2026
563b9d8
Fix link
GegznaV Mar 22, 2026
bba48b9
Update unit test
GegznaV Mar 22, 2026
41b2264
Update output class
GegznaV Mar 22, 2026
1903656
Update unit test: hy_attach
GegznaV Mar 22, 2026
3f9c76c
Update unit test
GegznaV Mar 22, 2026
55b88cc
Update unit test
GegznaV Mar 22, 2026
311f283
Update wl_create_label_from_units.R
GegznaV Mar 22, 2026
107059f
Update all.equal.R
GegznaV Mar 22, 2026
a47776e
Update hyperSpec.Rmd
GegznaV Mar 22, 2026
7d013db
Update .Rbuildignore
GegznaV Mar 22, 2026
7bfb096
Update NEWS.md
GegznaV Mar 22, 2026
4977877
Update documentation
GegznaV Mar 22, 2026
b3411c4
Update R-CMD-check.yaml
GegznaV Mar 22, 2026
1c1b4fe
Update plot reference for test
GegznaV Mar 23, 2026
39a6be1
Update NEWS.md
GegznaV Mar 23, 2026
bbcca37
Use roxygen2 7.2.3
GegznaV Mar 23, 2026
5107f03
Update R-CMD-check.yaml
GegznaV Mar 23, 2026
147130a
Merge pull request #140 from r-hyperspec/maintenance-updates
GegznaV Mar 23, 2026
d2f0af1
Update R-CMD-check.yaml
GegznaV Mar 23, 2026
697e435
Update R-CMD-check.yaml
GegznaV Mar 23, 2026
24ebc40
Skip test in R<=4.5.2
GegznaV Mar 23, 2026
888410f
Update R-CMD-check.yaml
GegznaV Mar 23, 2026
e4239b2
Merge branch 'develop' into impove-gha-workflows
GegznaV Mar 23, 2026
0aaae1e
Merge branch 'develop' into impove-gha-workflows
GegznaV Mar 23, 2026
32a18c6
Update R-CMD-check.yaml
GegznaV Mar 23, 2026
5d26e50
Try to fix r-delev issues on GHA
GegznaV Mar 24, 2026
2709c7a
Try to fix r-devel issues on GHA
GegznaV Mar 24, 2026
cd1fda4
Try to fix GHA error with R-devel
GegznaV Mar 24, 2026
b4dfd91
Fix R-devel CI: pin roxygen2 7.2.3 on all platforms + improve tryCatc…
Copilot Mar 24, 2026
8da9085
Merge pull request #142 from r-hyperspec/copilot/fix-r-cmd-check-work…
GegznaV Mar 24, 2026
8de618a
Update message
GegznaV Mar 24, 2026
ba78d66
Temporarily disable R CDM check for R-devel on GHA
GegznaV Mar 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# Directories
^_tmp$
^data-raw$
^\.vscode$


# Helper files
Expand Down
79 changes: 74 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ jobs:

- {os: windows-latest, r: 'release'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
# - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}

permissions:
contents: read

env:
R_KEEP_PKG_SOURCE: yes
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -48,8 +52,21 @@ jobs:
extra-packages: any::rcmdcheck, any::devtools, any::remotes, local::.
needs: check

- name: "Install roxygen2==7.2.3"
# roxygen2 7.3.x introduced a parser_setMethod bug: it calls
# methods::getMethod(name, eval(call$signature), where = env) with no
# error handling. In a clean Rscript session, S4 method tables for
# primitives ([[, [, $, etc.) are not populated → crash with
# "no method found for function '[[' and signature hyperSpec".
# Pin to 7.2.3 on ALL platforms (including R-devel) to avoid this.
#
# If roxygen2 7.2.3 fails to load on some future R-devel (e.g. due to a
# C-ABI break like the SET_GROWABLE_BIT removal in R 4.6.0-pre), the
# tryCatch below catches the error and attempts a fallback. For the
# git-restore fallback to work, NAMESPACE and man/ must be committed
# (pre-built docs pattern used by Bioconductor / Matrix).
- name: "Install roxygen2 7.2.3"
run: |
# 7.3.x has parser_setMethod bug (see comment above); 7.2.3 does not.
remotes::install_version("roxygen2", "7.2.3")
shell: Rscript {0}

Expand All @@ -60,17 +77,69 @@ jobs:
shell: Rscript {0}

- name: Install dependencies (for R-oldrel)
if: matrix.config.r == 'oldrel' || matrix.config.r == '3.6'
if: matrix.config.r == '3.6'
run: |
remotes::install_version("rgl", "0.100.50")
shell: Rscript {0}

- name: Session info
run: |
cat(
"NOTE: See full session info in Dependency Setup step logs. \n",
"Not all dependencies are listed here.",
sep = ""
)
sessioninfo::session_info()
shell: Rscript {0}

- name: Roxygenize
run: |
devtools::document()
# Attempt devtools::document(). roxygen2 7.2.3 (pinned above) avoids
# the 7.3.x parser_setMethod crash on S4 primitives. However, if a
# future R-devel C-ABI break prevents loading the roxygen2 shared
# library, we catch the error and fall back to:
# 1. git-restore of pre-committed NAMESPACE + man/ (preferred)
# 2. source-compiled roxygen2 7.2.3 built against current R headers
ok <- tryCatch({
devtools::document()
TRUE
}, error = function(e) {
message("devtools::document() failed: ", conditionMessage(e))

# Fallback 1: restore from git (works when docs are pre-committed)
message("Attempting git restore of NAMESPACE and man/...")
ret <- system2("git", c("checkout", "HEAD", "--", "NAMESPACE", "man/"),
stdout = TRUE, stderr = TRUE)
if (file.exists("NAMESPACE")) {
message("NAMESPACE restored from git.")
return(FALSE)
}
message("Git restore failed (NAMESPACE not tracked). ",
"Trying source-compiled roxygen2 7.2.3...")

# Fallback 2: compile roxygen2 7.2.3 from source against current R
tryCatch({
remotes::install_version("roxygen2", "7.2.3", type = "source",
quiet = TRUE)
devtools::document()
message("devtools::document() succeeded with source-compiled 7.2.3.")
TRUE
}, error = function(e2) {
message("Source-compiled 7.2.3 also failed: ", conditionMessage(e2))
message("R CMD check will fail: NAMESPACE is required.")
FALSE
})
})
if (!ok) message("Using pre-built documentation (if available).")
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true

- name: Show R-CMD-check log as step summary
if: always()
shell: bash
run: |
find check -name '00check.log' -exec sh -c 'echo "### $1"; cat "$1"' _ {} \; >> $GITHUB_STEP_SUMMARY || true

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ _tmp/

### Package-specific ###
tests/testthat/fileio
/.vscode
.positai
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ URL:
https://github.com/r-hyperspec/hyperSpec
BugReports: https://github.com/r-hyperspec/hyperSpec/issues
VignetteBuilder: knitr
RoxygenNote: 7.2.3
RoxygenNote: 7.3.3
Roxygen: list(markdown = TRUE)
Collate:
'hy_validate.R'
Expand Down
11 changes: 10 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# hyperSpec 0.101.0 (2024-05-01)

# hyperSpec 0.101.0 & 0.200.0.9000 (2024-05-01; development version)


## User-Facing Changes from Previous Versions
Expand Down Expand Up @@ -40,11 +41,19 @@
* Function `wl_convert_units()` converted into S3 generic. Default and hyperSpec methods were added (#29).
* Dataset `faux_cell` and function `generate_faux_cell()` replace `chondro` dataset (cbeleites/hyperSpec#125, cbeleites/hyperSpec#156, cbeleites/hyperSpec#180, cbeleites/hyperSpec#229).
* Documentation aliases have been updated. Now, ?hyperSpec points to the function `hyperSpec()`, and to refer to the package, `package?hyperSpec` should be used (#129).
* Vignette `hyperSpec.Rmd`: suggested packages (`pls`) are now loaded conditionally so the vignette builds even when they are not installed.


### Bugfixes

* Possibility to initialize `hyperSpec` object by providing wavelengths only (cbeleites/hyperSpec#288).
* Column names in spectra matrix (`$spc` column of `hyperSpec` object) are now returned correctly by functions `spc.bin()` (cbeleites/hyperSpec#237), and `spc.loess()` (cbeleites/hyperSpec#245
* `all.equal()` method for `hyperSpec` objects converted from S4 to S3 registration. The S4 `setMethod()` approach for this S3 generic caused roxygen2 (>= 7.3) to crash during documentation generation.
* `rbind.fill()` (internal): strip the `AsIs` class from matrix columns after data frame assembly. R >= 4.4 introduced `all.equal.AsIs()` which caused spurious class-mismatch failures when comparing `hyperSpec` objects that had been through `rbind` or `collapse`.
* `wl_create_label_from_units()`: fixed incorrect use of `grep()` where `sub()` was intended, which caused malformed wavelength axis labels for units containing `"_greek"`.
* `collapse()`: correctly sorts wavelengths in the merged result and preserves expected row order when combining `hyperSpec` objects with differing wavelength axes.
* Fixed Rd cross-references for `levelplot()` in `plot_matrix` and `map.sel.poly` documentation to include `lattice` package anchor.
* Vignette `hyperSpec.Rmd`: suggested packages (`pls`, `baseline`, `mvtnorm`, `colorspace`) are now loaded conditionally so the vignette builds even when they are not installed.


### Soft Deprecation: Functions That Will Be Moved to Other Packages
Expand Down
3 changes: 3 additions & 0 deletions R/DEPRECATED-plotspc.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ plotspc <- function(...) {
hySpc.testthat::test(plotspc) <- function() {
context("Deprecated functions")

# Skip on R 4.5.2 or earlier
testthat::skip_if(getRversion() <= "4.5.2", "result differs on R 4.5.2 or earlier")

test_that("plotspc() is deprecated", {
plot_d <- function() plotspc(flu)
expect_warning(vdiffr::expect_doppelganger("plotspc", plot_d), "deprecated")
Expand Down
12 changes: 7 additions & 5 deletions R/all.equal.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ hySpc.testthat::test(.all.equal) <- function() {
#'
#' @concept manipulation
#'
#' @method all.equal hyperSpec
#' @export
setMethod(
"all.equal",
signature(target = "hyperSpec", current = "hyperSpec"),
.all.equal
)
# setMethod(
# "all.equal",
# signature(target = "hyperSpec", current = "hyperSpec"),
# .all.equal
# )
all.equal.hyperSpec <- .all.equal
6 changes: 3 additions & 3 deletions R/collapse.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ hySpc.testthat::test(collapse) <- function() {

test_that("collapsing objects with equal wavelength axes", {
expect_equivalent(collapse(barbiturates[[1]], barbiturates[[1]]),
barbiturates[[1]][c(1, 1)],
wl_sort(barbiturates[[1]][c(1, 1)]),
check.label = TRUE
)
})
Expand Down Expand Up @@ -353,8 +353,8 @@ hySpc.testthat::test(collapse) <- function() {
)

tmp <- flu[rep(1:nrow(flu), 2)]
tmp[[7:12]] <- NA
tmp[[7:12, , 450]] <- flu[[, , 450]]
tmp[[1:6]] <- NA
tmp[[1:6, , 450]] <- flu[[, , 450]]
expect_equivalent(collapse(flu[, , 450], flu),
tmp,
check.labels = TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/decomposition.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#' @param ... ignored.
#' @return A `hyperSpec` object, updated according to `x`
#' @author C. Beleites
#' @seealso See [%*%] for matrix multiplication of `hyperSpec` objects.
#' @seealso See \code{\link[base:matmult]{%*%}} for matrix multiplication of `hyperSpec` objects.
#'
#' See e.g. [stats::prcomp()] and [stats::princomp()] for
#' principal component analysis, and package `pls` for Partial Least
Expand Down
16 changes: 16 additions & 0 deletions R/hy_attach.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,26 @@ hySpc.testthat::test(hy_attach) <- function() {
context("hy_attach")

test_that("hy_attach() works", {
# This test detaches and re-attaches hyperSpec via library().
# Skip when the package is not properly installed (e.g., loaded via load_all).
skip_if(
!any(file.exists(file.path(.libPaths(), "hyperSpec"))),
"hyperSpec not installed in any library (loaded via load_all?)"
)

# Check with hyperSpec package only
installed_pkgs <- row.names(installed.packages())
exclude_pkgs <- grep("^hySpc[.]", installed_pkgs, value = TRUE)

# Ensure package is re-attached on exit
on.exit({
if (!"package:hyperSpec" %in% search()) {
suppressWarnings(
tryCatch(library(hyperSpec), error = function(e) NULL)
)
}
}, add = TRUE)

# First check
expect_silent(hyperSpec::hy_attach(exclude_pkgs, quiet = TRUE))

Expand Down
2 changes: 1 addition & 1 deletion R/plot_and_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#'
#' `map.sel.poly` is a convenience wrapper for [plot_map()], `sel.poly`,
#' and [sp::point.in.polygon()]. For customized plotting, the plot can be produced by
#' [plot_map()], [plot_voronoi()] or [levelplot()], and the result of
#' [plot_map()], [plot_voronoi()] or [lattice::levelplot()], and the result of
#' that plot command handed over to `map.sel.poly`, see the example below.
#'
#' If even more customized plotting is required,`sel.poly` should be used (see example).
Expand Down
2 changes: 1 addition & 1 deletion R/plot_mat.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' [graphics::image()]?
#'
#' @author Claudia Beleites
#' @seealso [graphics::image()], [graphics::contour()], [hyperSpec::levelplot()]
#' @seealso [graphics::image()], [graphics::contour()], [lattice::levelplot()]
#'
#' @concept plotting
#' @concept plot generation
Expand Down
15 changes: 14 additions & 1 deletion R/rbind.fill.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,20 @@ rbind.fill <- function(...) {
}
}

quickdf(output)
result <- quickdf(output)
.strip_AsIs(result, matrixcols)
}

# Strip AsIs class from matrix columns after rbind.fill construction.
# I() is needed during assembly to protect matrices in data.frames, but the
# AsIs class should not persist (R >= 4.4 all.equal.AsIs checks class match).
.strip_AsIs <- function(df, matrixcols) {
for (var in matrixcols) {
if (inherits(df[[var]], "AsIs")) {
class(df[[var]]) <- setdiff(class(df[[var]]), "AsIs")
}
}
df
}

.get.or.make.matrix <- function(df, var) {
Expand Down
2 changes: 1 addition & 1 deletion R/wl_create_label_from_units.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ wl_create_label_from_units <- function(unit, greek = FALSE, null_ok = FALSE,

if (greek) {
# At first, suffix "_greek" is removed if present to avoid duplication
u_fixed <- paste0(u_fixed, grep("_greek", "", u_fixed), "_greek")
u_fixed <- paste0(sub("_greek$", "", u_fixed), "_greek")
}

switch(u_fixed,
Expand Down
8 changes: 4 additions & 4 deletions R/wl_eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ hySpc.testthat::test(wl_eval.hyperSpec) <- function() {
)

expect_equivalent(
wl_eval(flu, function(x) x),
vanderMonde(flu, 1)[2]
wl_eval(flu, function(x) x, normalize.wl = normalize_01)[[]],
vanderMonde(flu, 1)[2][[]]
)

expect_equivalent(
Expand Down Expand Up @@ -110,8 +110,8 @@ hySpc.testthat::test(wl_eval.hyperSpec) <- function() {

test_that("multiple functions", {
expect_equivalent(
wl_eval(flu, function(x) rep(1, length(x)), function(x) x),
vanderMonde(flu, 1)
wl_eval(flu, function(x) rep(1, length(x)), function(x) x, normalize.wl = normalize_01)[[]],
vanderMonde(flu, 1)[[]]
)
})

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/attached/plotspc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading