insightsengineering / insightsengineering/teal.slice

[Bug]: Unnecessary warning is being shown when setting choices for second time

Open
#676 1 comment 0 reactions 1 assignee Claimed by @averissimo View on GitHub
bug
Dominant language
R
Stars
12
Forks
7
Avg merge
3d 31m
Merged PRs (30d)
1

Description

### What happened?

Unnecessary warning when running a teal app with a shared `teal_slice` between modules.

- First module would calculate `mtcars$mpg` choices to be in an interval up to `33.9`, but after prettyfying the range it would be changed to `34.0`
- Second module using the same slice would use interval up to `33.9` and see that it's different from `34.0` and throw warning:

> `[WARN] 2026-02-11 11:23:48.1990 pid:170614 token:[34ce178c] teal.slice In ‘private$set_choices(slice$choices)’: Choices adjusted (some values outside of variable range). Varname: mpg, dataname: new_mtcars.`

### Sample app

```r
library(teal)

filters <- c(
# iris
"iris_sl1", "iris_sw1", "iris_pl1", "iris_pw1", "iris_species", "iris_id",
# mtcars
"mtcars_mpg", "mtcars_cyl", "mtcars_disp", "mtcars_hp", "mtcars_drat",
"mtcars_wt", "mtcars_qsec", "mtcars_vs", "mtcars_am", "mtcars_gear"
)

mapping <- lapply(1:13 |> sprintf("mod%d", ... = _) |> setNames(nm = _), \(x) sample(filters, floor(runif(1, 0, 12) + 1)))

names(mapping)[3] <- "mod3 with longer label"

app <- init(
data = within(teal_data(), {
new_iris <- tibble::rownames_to_column(iris, var = "id")
new_mtcars <- tibble::rownames_to_column(mtcars, var = "id")
}),
modules = teal::modules(
teal::example_module(label = "mod1"),
teal::example_module(label = "mod2"),
teal::example_module(label = "mod3 with longer label"),
teal::example_module(label = "mod4"),
teal::example_module(label = "mod5"),
teal::example_module(label = "mod6"),
teal::example_module(label = "mod7"),
teal::example_module(label = "mod8"),
teal::example_module(label = "mod9"),
teal::example_module(label = "mod10"),
teal::example_module(label = "mod11"),
teal::example_module(label = "mod12"),
teal::example_module(label = "mod13")
),
filter = teal::teal_slices(
# Iris filters (10 filters)
teal_slice(dataname = "new_iris", varname = "Sepal.Length", id = "iris_sl1"),
teal_slice(dataname = "new_iris", varname = "Sepal.Width", id = "iris_sw1"),
teal_slice(dataname = "new_iris", varname = "Petal.Length", id = "iris_pl1"),
teal_slice(dataname = "new_iris", varname = "Petal.Width", id = "iris_pw1"),
teal_slice(dataname = "new_iris", varname = "Species", id = "iris_species"),
teal_slice(dataname = "new_iris", varname = "id", id = "iris_id"),

# Mtcars filters (10 filters)
teal_slice(dataname = "new_mtcars", varname = "mpg", id = "mtcars_mpg"),
teal_slice(dataname = "new_mtcars", varname = "cyl", id = "mtcars_cyl"),
teal_slice(dataname = "new_mtcars", varname = "disp", id = "mtcars_disp"),
teal_slice(dataname = "new_mtcars", varname = "hp", id = "mtcars_hp"),
teal_slice(dataname = "new_mtcars", varname = "drat", id = "mtcars_drat"),
teal_slice(dataname = "new_mtcars", varname = "wt", id = "mtcars_wt"),
teal_slice(dataname = "new_mtcars", varname = "qsec", id = "mtcars_qsec"),
teal_slice(dataname = "new_mtcars", varname = "vs", id = "mtcars_vs"),
teal_slice(dataname = "new_mtcars", varname = "am", id = "mtcars_am"),
teal_slice(dataname = "new_mtcars", varname = "gear", id = "mtcars_gear"),

module_specific = TRUE,

mapping = mapping
# mapping = list(
# "mod1" = c("iris_sl1", "iris_sw1", "iris_pl1", "mtcars_mpg"),
# "mod13" = c("mtcars_mpg", "mtcars_drat", "iris_species")
# )
)
) |> shiny::runApp()
```

### sessionInfo()

```R

```

### Relevant log output

```R

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.