Skip to content

Commit 62fce06

Browse files
authored
Merge pull request #526 from utkarshpawade/fix/storage-mode-integer-conversion
Replace apply() with storage.mode() for integer to numeric conversion
2 parents a86c556 + 989cce1 commit 62fce06

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# bayesplot (development version)
22

3+
* Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`.
34
* Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`.
45
* Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`.
56
* Added unit tests for `ppc_error_data()` and `ppc_loo_pit_data()` covering output structure, argument handling, and edge cases.

R/helpers-ppc.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ validate_predictions <- function(predictions, n_obs = NULL) {
7373
}
7474

7575
if (is.integer(predictions)) {
76-
if (nrow(predictions) == 1) {
77-
predictions[1, ] <- as.numeric(predictions[1,, drop = FALSE])
78-
}
79-
else {
80-
predictions <- apply(predictions, 2, as.numeric)
81-
}
76+
storage.mode(predictions) <- "numeric"
8277
}
8378

8479
if (anyNA(predictions)) {

0 commit comments

Comments
 (0)