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 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)) +})