-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Feature Request]: Don't use @datanames anymore #333
Comments
@pawelru I'd like to continue discussion here:
If we decide to use names.qenv <- function(x) ls(x) names.teal_data <- function(x) {
unsorted <- names.qenv(x)
.topological_sort(unsorted, join_keys(x))
}
We can consider also other methods names:
|
By looking at the NEWS entries of this incoming release it feels like we should address this issue sooner. It doesn't make sense to enhance datanames and then deprecate them. Improvements will be still relevant but Or maybe we should keep # teal.data 0.6.0.9011
### Enhancements
- `datanames()`
- if `join_keys` are provided, the `datanames()` are now sorted in topological way (`Kahn` algorithm),
which means the parent dataset always precedes the child dataset.
- are extended by the parent dataset name, if one of the child dataset exist in `datanames()` and
the connection between child-parent is set through `join_keys` and `parent` exist in `teal_data` environment.
- do not allow to set a dataset name that do not exist in `teal_data` environment.
- `teal_data` no longer set default `datanames()` based on `join_keys` names - it uses only data names.
|
After short call with @pawelru we initially agreed to the |
Disruptive question here as Was it ever considered to use an S4 object that inherits from "environment". A preliminary test while I was trying to make It adds a slot called
The only problem so far is that # The required change in the class
setClass(
"qenv",
slots = c(
--- env = "environment",
code = "character",
id = "integer",
warnings = "character",
messages = "character"
),
+++ contains = "environment",
prototype = list(
env = new.env(parent = parent.env(.GlobalEnv)), code = character(0), id = integer(0),
warnings = character(0), messages = character(0)
)
) Note that this is not a reproducible code, it's just a sample of the results pkgload::load_all("teal.code")
#> ℹ Loading teal.code
q2 <- qenv() |> within({
iris <- iris
mtcars <- mtcars
})
ls(q2)
#> [1] "iris" "mtcars"
q2$iris |> tibble::as_tibble()
#> # A tibble: 150 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # ℹ 140 more rows
q2[["iris"]] |> tibble::as_tibble()
#> # A tibble: 150 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> 7 4.6 3.4 1.4 0.3 setosa
#> 8 5 3.4 1.5 0.2 setosa
#> 9 4.4 2.9 1.4 0.2 setosa
#> 10 4.9 3.1 1.5 0.1 setosa
#> # ℹ 140 more rows
q2$yada <- 2
#> Error in q2$yada <- 2: cannot add bindings to a locked environment
q2[["yada"]] <- 2
#> Error in q2[["yada"]] <- 2: cannot add bindings to a locked environment Created on 2024-10-29 with reprex v2.1.1 |
Wow @averissimo , very promising finding |
Feature description
@datanames
slot has been introduced only to distinguish temporary/proxy objects from "real" datanames. It was useful inteal
where app didn't have to create a filter-panel. Now (after this)teal
ignoresteal.data::datanames
and simply runsls(x@env)
to determine "datanames".We can keep
datanames
function butnames
(implemented inqenv
) is more relevant in my opinion.Plan:
names
method forqenv
andqenv.error
@datanames
slotdatanames<-
inteal.data
- function has no effect in teal anymore. Please point to use.
for exclusions orteal::set_datanames
datanames()
inteal.data
- point to thenames
teal.data::datanames
in the modules in favour ofnames()
Related issues:
datanames
updates #338check_simple_name()
teal#1366data
raise warnings teal#1352teal_transform_module
to havedatanames = "all"
teal#1347modules/module
to contain more information teal#1378names
argument inget_code
to subset code for specific objects. teal.code#210qenv
object teal.code#211set_datanames
to support negative selection. teal#1380The text was updated successfully, but these errors were encountered: