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

129: use name hyperSpec() #130

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* New function `hy_browse_homepage()` opens the homepage of *R hyperSpec* in a web browser.
* New function `hy_list_available_hySpc_packages()` lists packages, that are available in GitHub organization `r-hyperSpec`.
* New function `hy_list_installed_hySpc_packages()` lists and function `hy_attach()` conveniently loads and attaches all installed **`r-hyperspec`** family packages (@cbeleites, @GegznaV, cbeleites/hyperSpec#219).
* New function `new_hyperSpec()` that initializes `hyperSpec` object in a similar way as `new("hyperSpec")` does but has autocompletion possibilities in RStudio (cbeleites/hyperSpec#283).
* New function `hyperSpec()` that initializes `hyperSpec` object in a similar way as `new("hyperSpec")` does but has autocompletion possibilities in RStudio (cbeleites/hyperSpec#283, #129).
* New function `wl_convert_units()` (cbeleites/hyperSpec#300).
* New function `wl_create_label_from_units()` that creates labels for wavelength axis (@GegznaV).
* New method `as.hyperSpec(<hyperSpec>)` (cbeleites/hyperSpec#282).
Expand All @@ -39,7 +39,7 @@
* Function `sample()` gains new argument `index`; `sample(..., index = TRUE)` replaced function `isample()` (@GegznaV, #17).
* 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).

### Bugfixes

Expand Down
5 changes: 3 additions & 2 deletions R/hyperspec-package.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#' @name hyperSpec-package
#' @rdname hyperSpec-package
#' @aliases hyperSpec-package
#'
#' @title Package "hyperSpec": interface for hyperspectral datasets
#' @description
#' This package gives an interface to handle hyperspectral data sets in R.
Expand All @@ -20,13 +23,11 @@
#' - `package?hyperSpec` for information about the package.
#' - `class?hyperSpec` for details on the S4 class provided by this package.
#'
#' @rdname hyperSpec-package
#' @include flu.R
#' @include faux_cell.R
#' @include laser.R
#' @include paracetamol.R
#' @include barbiturates.R

#'
#' @keywords package
#' @concept hyperSpec-main
Expand Down
20 changes: 10 additions & 10 deletions R/initialize.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#'
#' To create a new `hyperSpec` object, you can use one of the following functions:
#' - [new()] (i.e., `new("hyperSpec", ...)`);
#' - `new_hyperSpec()`.
#' - `hyperSpec()`.
#'
#' @note
#'
#' A `hyperSpec` object is an S4 object, so its initialization is performed
#' by calling `new("hyperSpec", ...)`. The function `new_hyperSpec()` is provided
#' by calling `new("hyperSpec", ...)`. The function `hyperSpec()` is provided
#' for convenience.
#'
#' @docType methods
Expand All @@ -22,7 +22,7 @@
#' create,hyperSpec-method
#' new
#' new,hyperSpec-method
#' new_hyperSpec
#' hyperSpec-function
#'
#' @param spc (`matrix` or convertible to `matrix`) \cr
#' A spectra matrix with spectra in rows and wavelength intensities in
Expand Down Expand Up @@ -85,11 +85,11 @@
#' @examples
#'
#' new("hyperSpec")
#' new_hyperSpec()
#' hyperSpec()
#'
#' spc <- matrix(rnorm(12), ncol = 4)
#' new("hyperSpec", spc = spc)
#' new_hyperSpec(spc = spc)
#' hyperSpec(spc = spc)
#'
#' new("hyperSpec",
#' data = data.frame(x = letters[1:3]),
Expand Down Expand Up @@ -263,7 +263,7 @@ NULL

#' @rdname initialize
#' @export
new_hyperSpec <- function(spc = NULL, data = NULL, wavelength = NULL,
hyperSpec <- function(spc = NULL, data = NULL, wavelength = NULL,
labels = NULL, gc = hy_get_option("gc"),
log = "ignored") {
new("hyperSpec", spc = spc, data = data, wavelength = wavelength,
Expand Down Expand Up @@ -398,11 +398,11 @@ hySpc.testthat::test(.initialize) <- function() {
})


test_that('new_hyperSpec() and new("hyperSpec") give identical results', {
expect_equal(new_hyperSpec(), new("hyperSpec"))
expect_equal(new_hyperSpec(spc = 1:4), new("hyperSpec", spc = 1:4))
test_that('hyperSpec() and new("hyperSpec") give identical results', {
expect_equal(hyperSpec(), new("hyperSpec"))
expect_equal(hyperSpec(spc = 1:4), new("hyperSpec", spc = 1:4))
expect_equal(
new_hyperSpec(spc = spc, data = data.frame(x = 11:13)),
hyperSpec(spc = spc, data = data.frame(x = 11:13)),
new("hyperSpec", spc = spc, data = data.frame(x = 11:13))
)
})
Expand Down
Loading