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

Clean depracated functions and unit tests #331

Merged
merged 33 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b174ff3
include deprecated.R in Collate: order
cbeleites May 31, 2021
611513d
fix deprecated function unit test
cbeleites May 31, 2021
a49a8d0
fix deprecated function unit test
cbeleites May 31, 2021
ee14e8d
fix deprecation
cbeleites May 31, 2021
e15f966
fix deprecation
cbeleites May 31, 2021
0847d8d
fix deprecation
cbeleites May 31, 2021
bdaa1d0
fix merge
cbeleites May 31, 2021
ca2dee1
deprecation: fix parameters for calling new version
cbeleites May 31, 2021
8d6840a
fix deprecation
cbeleites May 31, 2021
14b28f1
fix deprecation
cbeleites Jun 1, 2021
f89bb24
merge develop into bugfix/321-unit-tests-failing-R-release
cbeleites Jul 3, 2021
d95ac46
deprecate read.jdx()
cbeleites Jul 3, 2021
ce106f2
fix collate order for wl_eval()
cbeleites Jul 3, 2021
73ff749
Merge branch 'develop' into bugfix/321-unit-tests-failing-R-release
GegznaV Jul 10, 2021
0b76935
Update style in read.jdj.R
GegznaV Jul 10, 2021
574cdba
Add message to rename file in separate PR
GegznaV Jul 10, 2021
7b1d104
Update code style
GegznaV Jul 10, 2021
cee9611
Undocument unused arguments of spc.rubberband()
GegznaV Jul 10, 2021
6b77298
Update style
GegznaV Jul 10, 2021
cd38f23
Update style
GegznaV Jul 10, 2021
96803fe
Update style
GegznaV Jul 10, 2021
1eb06ad
Update style
GegznaV Jul 10, 2021
b4f7cf6
Update style of function titles
GegznaV Jul 10, 2021
5965b2f
Merge branch 'develop' into bugfix/321-unit-tests-failing-R-release
GegznaV Jul 10, 2021
8e7f2dd
Merge branch 'develop' into bugfix/321-unit-tests-failing-R-release
GegznaV Jul 10, 2021
c18d5e5
update from devel
GegznaV Jul 10, 2021
20e05e6
Update unit tests: ggplot2
GegznaV Jul 11, 2021
0ead2b0
Update unit tests
GegznaV Jul 11, 2021
3d6a5d4
Update unit tests
GegznaV Jul 11, 2021
c971a04
Update unit tests: suppress deprecation warnings
GegznaV Jul 11, 2021
80f26e4
Deprecate .read.spe.xml
GegznaV Jul 11, 2021
e089843
Update contents of pkgdown website
GegznaV Jul 11, 2021
922e173
Updating from `develop` manually again
GegznaV Jul 11, 2021
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
12 changes: 6 additions & 6 deletions hyperSpec/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Type: Package
Title: Work with Hyperspectral Data, i.e. Spectra + Meta Information (Spatial,
Time, Concentration, ...)
Version: 0.100.0
Date: 2020-08-24
Date: 2021-07-10
Maintainer: Claudia Beleites <[email protected]>
Authors@R: c(
person("Claudia", "Beleites", role = c("aut", "cre", "dtc"), email = "[email protected]"),
Expand Down Expand Up @@ -90,6 +90,7 @@ Collate:
'DEPRECATED-count_lines.R'
'hy_options.R'
'constants-regexps.R'
'extract_numbers.R'
'DEPRECATED-extract_numbers.R'
'DEPRECATED-ggplot2.R'
'DEPRECATED-read.ENVI.R'
Expand All @@ -113,14 +114,18 @@ Collate:
'DEPRECATED-scan.R'
'DEPRECATED-spc-various.R'
'DEPRECATED-spc_bin.R'
'spc_fit_poly.R'
'DEPRECATED-spc_fit_poly.R'
'DEPRECATED-spc_fix_colnames.R'
'DEPRECATED-spc_loess.R'
'DEPRECATED-spc_na_approx.R'
'spc_rubberband.R'
'DEPRECATED-spc_rubberband.R'
'DEPRECATED-spc_spline.R'
'DEPRECATED-wc.R'
'DEPRECATED-wl_convert_units.R'
'normalize01.R'
'wl_eval.R'
'DEPRECATED-wl_eval.R'
'DEPRECATED-wl_sort.R'
'DEPRECATED-write_txt_long.R'
Expand All @@ -131,7 +136,6 @@ Collate:
'all.equal.R'
'apply.R'
'as.data.frame.R'
'extract_numbers.R'
'as_hyperSpec.R'
'barbiturates.R'
'bind.R'
Expand Down Expand Up @@ -173,7 +177,6 @@ Collate:
'merge.R'
'mergeextra.R'
'mvtnorm.R'
'normalize01.R'
'palette_colorblind.R'
'palette_matlab.R'
'pearson_dist.R'
Expand All @@ -193,12 +196,10 @@ Collate:
'seq.R'
'show.R'
'spc_bin.R'
'spc_fit_poly.R'
'spc_fix_colnames.R'
'spc_identify.R'
'spc_loess.R'
'spc_na_approx.R'
'spc_rubberband.R'
'spc_spline.R'
'split.R'
'subset.R'
Expand All @@ -207,7 +208,6 @@ Collate:
'vandermonde.R'
'wl.R'
'wl_convert_units.R'
'wl_eval.R'
'wl_sort.R'
'write_txt_long.R'
'write_txt_wide.R'
Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-count_lines.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-count_lines
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) Count Lines (of an ASCII File)
#' @title (DEPRECATED)
#' Count lines (of an ASCII File)
#'
#' @description
#'
Expand Down
36 changes: 10 additions & 26 deletions hyperSpec/R/DEPRECATED-extract_numbers.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-guess.wavlength
#' @concept deprecated
#'
#' @title (DEPRECATED) Guess Wavelengths from Character Vector
#' @title (DEPRECATED)
#' Guess wavelengths from character vector
#'
#'
#' @description
Expand All @@ -16,7 +17,7 @@
#'
#' Character vectors used for names (e.g. colnames for matrices or data.frames)
#' are often treated by [base::make.names()] or similar functions that
#' produce suitable names (e.g. by prepending "X" to numbers). Such names
#' produce suitable names (e.g. by pre-pending "X" to numbers). Such names
#' cannot be directly converted to numeric.
#'
#' `guess.wavlength()` tries to extract numbers from X which may be
Expand All @@ -35,40 +36,23 @@
#' tmp <- data.frame(flu[[, , 400 ~ 410]])
#' (wl <- colnames(tmp))
#' guess.wavelength(wl)
#' @include extract_numbers.R
guess.wavelength <- function(X) {
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hySpc_deprecated("extract_numbers")
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wl <- regmatches(X, regexpr(.PATTERN.number, X))
wl <- as.numeric(wl)

if (is.null(wl) || length(wl) == 0L || any(is.na(wl))) {
if (hy.getOption("debuglevel") >= 1L) {
message("could not guess wavelengths")
}
wl <- NULL
}

wl
extract_numbers(X)
}

#' @include constants-regexps.R
#' @include hy_options.R
hySpc.testthat::test(guess.wavelength) <- function() {
context("guess.wavelength")

test_that("simple test", {
expect_equal(guess.wavelength(1:5), 1:5)
})

test_that("wavelengths containing characters", {
wl <- seq(600, 602, length.out = 11)
expect_equal(guess.wavelength(make.names(wl)), wl)
})

test_that("return NULL if could not guess wavelenths", {
expect_equal(guess.wavelength(colnames(matrix(1:12, 3))), NULL)
expect_equal(guess.wavelength(letters[1:4]), NULL)
test_that("deprecated", {
expect_warning(
guess.wavelength(1:5),
"Function 'guess.wavelength' is deprecated."
)
})
}
14 changes: 13 additions & 1 deletion hyperSpec/R/DEPRECATED-ggplot2.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' @concept moved to hySpc.ggplot2
#'
#' @title (DEPRECATED)
#' Spectra Plotting with \pkg{ggplot2} Was Moved to \pkg{hySpc.ggplot2}
#' Spectra plotting with \pkg{ggplot2} was moved to \pkg{hySpc.ggplot2}
#'
#' @description
#'
Expand Down Expand Up @@ -609,3 +609,15 @@ colmix.rgb <- function(x, purecol, against = 1, sub = TRUE,

cols
}

# Unit tests -----------------------------------------------------------------

hySpc.testthat::test(qplotspc) <- function() {
context("ggplot2")

test_that("deprecated", {
expect_warning(res <- qplotspc(flu), "deprecated")
expect_warning(res <- qplotmap(flu), "deprecated")
expect_warning(res <- qplotc(flu), "deprecated")
})
}
4 changes: 2 additions & 2 deletions hyperSpec/R/DEPRECATED-read.asc.Andor.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED)
#' Import Raman Spectra/Maps from Andor Cameras/Solis ASCII Files
#' @description
#' Import Raman spectra/maps from Andor cameras/solis ASCII files
#'
#' @description
#' These data input functions are **deprecated** and they will be removed in
#' the next release of \pkg{hyperspec} package.
#' Now functions in package \pkg{hySpc.read.txt}
Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-read.asc.PerkinElmer.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-read.asc.PerkinElmer
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) File import filter PerkinElmer ASCII spectra
#' @title (DEPRECATED)
#' File import filter PerkinElmer ASCII spectra
#'
#' @description
#'
Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-read.ini.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-read.ini
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) Read INI files
#' @title (DEPRECATED)
#' Read INI files
#'
#' @description
#'
Expand Down
22 changes: 21 additions & 1 deletion hyperSpec/R/DEPRECATED-read.spe.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,23 @@ read.spe <- function(filename, xaxis = "file", acc2avg = F, cts_sec = F,
.spc_io_postprocess_optional(spc, filename)
}

#' Read XML footer from SPE file format version 3.0.

#' @name DEPRECATED-read.spe.xml
#' @concept moved to hySpc.read.spe
#'
#' @title (DEPRECATED)
#' Read XML footer from SPE file format version 3.0
#'
#' @description
#'
#' These data input functions are **deprecated** and they will be removed in
#' the next release of \pkg{hyperspec} package.
#' Now functions in package \pkg{hySpc.read.spe}
#' ([link](https://r-hyperspec.github.io/hySpc.read.spe/reference/index.html))
#' should be used as the alternatives.
#'
#'
#' **Old description:**
#'
#' The new SPE file format, introduced in 2012, was designed to be backwards compatible with the
#' previous format 2.5. The most prominent change is the new plain text XML footer holding vast
Expand All @@ -176,6 +192,10 @@ read.spe <- function(filename, xaxis = "file", acc2avg = F, cts_sec = F,
#' @importFrom xml2 as_list read_xml
#'
.read.spe.xml <- function(filename) {
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deprecated_read_spe()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

as_list(read_xml(.read.spe.xml_string(filename)))
}

Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-read.txt.Horiba.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-read.txt.Horiba
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) Import Horiba Labspec exported ASCII files
#' @title (DEPRECATED)
#' Import Horiba Labspec exported ASCII files
#'
#' @description
#' These data input functions are **deprecated** and they will be removed in
Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-read.txt.Renishaw.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-read.txt.Renishaw
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) Import Raman measurements from Renishaw ASCII-files
#' @title (DEPRECATED)
#' Import Raman measurements from Renishaw ASCII-files
#'
#' @description
#'
Expand Down
3 changes: 2 additions & 1 deletion hyperSpec/R/DEPRECATED-read.txt.Shimadzu.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#' @name DEPRECATED-read.txt.Shimadzu
#' @concept moved to hySpc.read.txt
#'
#' @title (DEPRECATED) Reads Shimadzu GCxGC-qMS - Spectra Files (`.txt`)
#' @title (DEPRECATED)
#' Read Shimadzu GCxGC-qMS - spectra files (`.txt`)
#'
#' @description
#'
Expand Down
Loading