From b45d0b6324d1ec9212a3fc7d52b39e2e07e43d18 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Wed, 6 Feb 2019 20:59:35 -0500 Subject: [PATCH 1/2] Test that assignment keeps the correct class --- tests/testthat/test-xpose_data.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/testthat/test-xpose_data.R b/tests/testthat/test-xpose_data.R index e95ef8e2..4e73b504 100644 --- a/tests/testthat/test-xpose_data.R +++ b/tests/testthat/test-xpose_data.R @@ -90,3 +90,8 @@ test_that('properly handles errors in files', { expect_error(grd_vs_iteration(xpdb_5), regex = 'No `files` slot could be found in this xpdb') }) +test_that('Allow assignment within object while maintaining the class', { + xpdb <- xpdb_ex_pk + xpdb$options$quiet <- TRUE + expect_equal(class(xpdb), class(xpdb_ex_pk)) +}) From e113dff0896f3020cd2fb7fc4040d6fecf8f4a22 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Sun, 17 Mar 2019 15:25:46 -0400 Subject: [PATCH 2/2] Detect off-diagonal omega names --- R/xpdb_access.R | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/R/xpdb_access.R b/R/xpdb_access.R index ab9fadc6..ac860139 100644 --- a/R/xpdb_access.R +++ b/R/xpdb_access.R @@ -423,13 +423,24 @@ get_prm <- function(xpdb, } # Assign OMEGA labels - n_omega <- sum(prms$type == 'ome' & prms$diagonal, na.rm = TRUE) + mask_omega <- prms$type == 'ome' & prms$diagonal + mask_omega_all <- + prms$type == 'ome' & + !is.nan(prms$value) & + (prms$diagonal | + !(prms$value == 0 & prms$fixed & !prms$diagonal) + ) + n_omega <- sum(mask_omega, na.rm = TRUE) + n_omega_all <- sum(mask_omega_all, na.rm = TRUE) omega_names <- data$prm_names$omega - if (n_omega != length(omega_names)) { + if (n_omega == length(omega_names)) { + prms$label[mask_omega] <- omega_names + } else if (n_omega_all == length(omega_names)) { + prms$label[mask_omega_all] <- omega_names + } else { + browser() warning('[$prob no.', data$problem, ', subprob no.', data$subprob, ', ', data$method, '] $OMEGA labels did not match the number of OMEGAs in the `.ext` file.', call. = FALSE) - } else { - prms$label[prms$type == 'ome' & prms$diagonal] <- omega_names } # Assign SIGMA labels