zdebruine / RcppML

Rcpp Machine Learning: Fast robust NMF, divisive clustering, and more
GNU General Public License v2.0
89 stars 15 forks source link

Functions don't work unless Matrix is loaded #28

Closed EmilHvitfeldt closed 2 years ago

EmilHvitfeldt commented 2 years ago

Hello 👋

nmf() doesn't work unless the {Matrix} package is explicitly loaded. Below is reprex using examples from README.

A <- Matrix::rsparsematrix(1000, 100, 0.1) # sparse Matrix::dgCMatrix
model <- RcppML::nmf(A, k = 10, nonneg = TRUE)
#> 
#> iter |      tol 
#> ---------------
#> Error in Rcpp_nmf_sparse(A, k, tol, maxit, verbose, nonneg, L1, seed, : Cannot convert object to an environment: [type=character; target=ENVSXP].

library(Matrix)
model <- RcppML::nmf(A, k = 10, nonneg = TRUE)
#> 
#> iter |      tol 
#> ---------------
#>    1 | 9.03e-01
#>    2 | 3.69e-02
#>    3 | 1.85e-02
#>    4 | 1.15e-02
#>    5 | 7.51e-03
#>    6 | 5.05e-03
#>    7 | 3.25e-03
#>    8 | 2.03e-03
#>    9 | 1.44e-03
#>   10 | 9.80e-04
#>   11 | 7.43e-04
#>   12 | 5.99e-04
#>   13 | 5.74e-04
#>   14 | 5.76e-04
#>   15 | 5.64e-04
#>   16 | 5.48e-04
#>   17 | 4.88e-04
#>   18 | 4.27e-04
#>   19 | 3.45e-04
#>   20 | 2.88e-04
#>   21 | 2.47e-04
#>   22 | 2.42e-04
#>   23 | 2.39e-04
#>   24 | 2.42e-04
#>   25 | 2.40e-04
#>   26 | 1.75e-04
#>   27 | 1.56e-04
#>   28 | 1.43e-04
#>   29 | 1.34e-04
#>   30 | 1.30e-04
#>   31 | 1.24e-04
#>   32 | 1.18e-04
#>   33 | 1.09e-04
#>   34 | 9.56e-05

Created on 2022-01-26 by the reprex package (v2.0.1)

zdebruine commented 2 years ago

Thanks, this applies only to the CRAN release, correct? I'm staging major (non-breaking) updates in the dev version, should be on CRAN in a month or so.

MarcElosua commented 2 years ago

I had the same issue with the CRAN package and its resolved after installing the devel version

zdebruine commented 2 years ago

Issue resolved in development version. When development version hits CRAN this issue will be fully resolved.