dosreislab / mcmc3r

mcmc3r: an R package for MCMCTree
MIT License
2 stars 2 forks source link

The testing code using class(X) == "matrix" returns an error because… #10

Closed gaballench closed 1 year ago

gaballench commented 1 year ago

The testing code using class(X) == "matrix" returns an error because matrix classes are both matrix and array, which is problematic when using that result inside an if clause as such comparison will be of length 2 (class(X) returns "matrix" "array"). Matrices were not also arrays in previous versions of R but this has changed (at least from 4.x). A safe approach is to test inheritance rather than class as suggested in all the tests involving checking that an object is of class "matrix". Using the previous version of class checking prevented running the vignette for reproducing the results with the Carnivora dataset. Both tests and vignette are running with the proposed changes.

gaballench commented 1 year ago

This has been noted in other packages and confirms the new behaviour of class() for matrices from R 4.x https://github.com/tidymodels/recipes/issues/422.