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

convert_Wavelength2Energy() fails on a RLum.Data.Spectrum object if order=TRUE #133

Closed
mcol opened this issue Aug 9, 2024 · 2 comments
Closed
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have

Comments

@mcol
Copy link
Contributor

mcol commented Aug 9, 2024

Running this snippet:

lambda <- seq(400,800,50)
data <- matrix(data = rep(1, 2 * length(lambda)), ncol = 2)
rownames(data) <- lambda
colnames(data) <- 1:ncol(data)
object <- set_RLum(class = "RLum.Data.Spectrum", data = data[,1,drop = FALSE])
convert_Wavelength2Energy(object, order = TRUE)

fails with:

Error in (function (cl, name, valueClass)  : 
  assignment of an object of class “numeric” is not valid for @‘data’ in an object of class “RLum.Data.Spectrum”; is(value, "matrix") is not TRUE
@mcol mcol added the bug (potentially) Is seems like a bug, but it's unclear what real effect it may have label Aug 9, 2024
@mcol
Copy link
Contributor Author

mcol commented Aug 9, 2024

The error occurs at this line:

object@data <- object@data[order(as.numeric(rownames(object@data))), ]

because if object is of the RLum.Data.Spectrum class, it is a 1-column matrix, and the line above implicitly turns it into a vector, so the assignment fails. Adding drop=FALSE fixes the issue.

@RLumSK
Copy link
Member

RLumSK commented Aug 12, 2024

Fixes with PR #134

@RLumSK RLumSK closed this as completed Aug 12, 2024
@mcol mcol added this to the v0.9.25 (autumn CRAN release) milestone Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have
Projects
None yet
Development

No branches or pull requests

2 participants