Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omega label detection #146

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions R/xpdb_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-xpose_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})