weecology / LDATS

Latent Dirichlet Allocation coupled with Bayesian Time Series analyses
https://weecology.github.io/LDATS
Other
25 stars 5 forks source link

Add as.matrix to sim_TS #142

Closed diazrenata closed 4 years ago

diazrenata commented 5 years ago

If X only has one column, X[in1,] is a vector and the matrix multiplication fails. Adding the as.matrix seems to fix it.

codecov-io commented 5 years ago

Codecov Report

Merging #142 into sim_edits will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           sim_edits     #142   +/-   ##
==========================================
  Coverage      97.71%   97.71%           
==========================================
  Files             11       11           
  Lines           1223     1223           
==========================================
  Hits            1195     1195           
  Misses            28       28
Impacted Files Coverage Δ
R/simulate.R 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f4f1a84...b67292f. Read the comment docs.

gavinsimpson commented 4 years ago

A simpler fix to avoid this issue entirely would be to stop R dropping the empty dimension when X is subset. For example:

X_Eta <- X[in1, , drop = FALSE] %*% Eta[in2,]`

If Eta is also a matrix object then it to probably should be protected from dropping empty dimensions. I'm not sure if that is possible given other code, but to be defensive one would use

X_Eta <- X[in1, , drop = FALSE] %*% Eta[in2, , drop = FALSE]