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

Forces exact match on attribute to avoid problems #561

Merged
merged 3 commits into from
Feb 19, 2024
Merged
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
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* `set_filter_state` no longer accepts a nested list. Use `teal_slices()` and `teal_slice()` instead.
* Renamed `FilteredDataset` subclass that handles `data.frame`s from `DefaultFilteredDataset` to `DataframeFilteredDataset`. Added new class `DefaultFilteredDataset` that will store any type of object. Filtering will is not supported.

### Bug fixes

* Performs an exact match when determining the default label of a dataset from attributes.

### Miscellaneous

* Specified minimal version of package dependencies.
Expand Down
2 changes: 1 addition & 1 deletion R/FilterState.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ FilterState <- R6::R6Class( # nolint
if (is.null(isolate(slice$keep_na)) && anyNA(x)) slice$keep_na <- TRUE
private$teal_slice <- slice
# Obtain variable label.
varlabel <- attr(x, "label")
varlabel <- attr(x, "label", exact = TRUE)
# Display only when different from varname.
private$varlabel <-
if (is.null(varlabel) || identical(varlabel, private$get_varname())) {
Expand Down
2 changes: 1 addition & 1 deletion R/FilterStateChoices.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ ChoicesFilterState <- R6::R6Class( # nolint
x_factor <- if (!is.factor(x)) {
structure(
factor(as.character(x), levels = as.character(sort(unique(x)))),
label = attr(x, "label")
label = attr(x, "label", exact = TRUE)
)
} else {
x
Expand Down
16 changes: 8 additions & 8 deletions R/FilteredDataset-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@
#' }
#' @keywords internal
#' @export
init_filtered_dataset <- function(dataset, # nolint
init_filtered_dataset <- function(dataset,
dataname,
keys = character(0),
parent_name = character(0),
parent = reactive(dataset),
join_keys = character(0),
label = attr(dataset, "label")) {
label = attr(dataset, "label", exact = TRUE)) {
UseMethod("init_filtered_dataset")
}

#' @keywords internal
#' @export
init_filtered_dataset.data.frame <- function(dataset, # nolint
init_filtered_dataset.data.frame <- function(dataset,
dataname,
keys = character(0),
parent_name = character(0),
parent = NULL,
join_keys = character(0),
label = attr(dataset, "label")) {
label = attr(dataset, "label", exact = TRUE)) {
DataframeFilteredDataset$new(
dataset = dataset,
dataname = dataname,
Expand All @@ -114,13 +114,13 @@ init_filtered_dataset.data.frame <- function(dataset, # nolint

#' @keywords internal
#' @export
init_filtered_dataset.MultiAssayExperiment <- function(dataset, # nolint
init_filtered_dataset.MultiAssayExperiment <- function(dataset,
dataname,
keys = character(0),
parent_name, # ignored
parent, # ignored
join_keys, # ignored
label = attr(dataset, "label")) {
label = attr(dataset, "label", exact = TRUE)) {
if (!requireNamespace("MultiAssayExperiment", quietly = TRUE)) {
stop("Cannot load MultiAssayExperiment - please install the package or restart your session.")
}
Expand All @@ -134,13 +134,13 @@ init_filtered_dataset.MultiAssayExperiment <- function(dataset, # nolint

#' @keywords internal
#' @export
init_filtered_dataset.default <- function(dataset, # nolint
init_filtered_dataset.default <- function(dataset,
dataname,
keys, # ignored
parent_name, # ignored
parent, # ignored
join_keys, # ignored
label = attr(dataset, "label")) {
label = attr(dataset, "label", exact = TRUE)) {
DefaultFilteredDataset$new(
dataset = dataset,
dataname = dataname,
Expand Down
2 changes: 1 addition & 1 deletion R/FilteredDataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FilteredDataset <- R6::R6Class( # nolint
#'
#' @return Object of class `FilteredDataset`, invisibly.
#'
initialize = function(dataset, dataname, keys = character(0), label = attr(dataset, "label")) {
initialize = function(dataset, dataname, keys = character(0), label = attr(dataset, "label", exact = TRUE)) {
logger::log_trace("Instantiating { class(self)[1] }, dataname: { dataname }")

# dataset assertion in child classes
Expand Down
2 changes: 1 addition & 1 deletion man/FilteredDataset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/init_filtered_dataset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading