Skip to content

Commit

Permalink
Merge pull request #166 from rolfsimoes/dev
Browse files Browse the repository at this point in the history
Fix #160
  • Loading branch information
rolfsimoes authored Jun 10, 2024
2 parents 2f6452f + e5e0cbe commit 4d1ca0b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
10 changes: 4 additions & 6 deletions R/assets-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,7 @@ assets_select <- function(items, ..., asset_names = NULL, select_fn = NULL) {
assets_select.doc_item <- function(items, ...,
asset_names = NULL,
select_fn = NULL) {
exprs <- unquote(
expr = as.list(substitute(list(...), env = environment())[-1]),
env = parent.frame()
)
exprs <- as.list(substitute(list(...), env = environment()))[-1]
init_length <- length(items$assets)
if (!is.null(asset_names)) {
asset_names <- intersect(names(items$assets), asset_names)
Expand All @@ -354,9 +351,10 @@ assets_select.doc_item <- function(items, ...,
if (length(exprs) > 0) {
if (!is.null(names(exprs)))
.error("Select expressions cannot be named.")
for (i in seq_along(exprs)) {
for (expr in exprs) {
expr <- unquote(expr = expr, env = parent.frame())
sel <- map_lgl(names(items$assets), function(key) {
select_eval(key = key, asset = items$assets[[key]], expr = exprs[[i]])
select_eval(key = key, asset = items$assets[[key]], expr = expr)
})
items$assets <- items$assets[sel]
}
Expand Down
10 changes: 4 additions & 6 deletions R/items-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,13 @@ items_filter <- function(items, ..., filter_fn = NULL) {
#' @export
items_filter.doc_items <- function(items, ..., filter_fn = NULL) {
init_length <- items_length(items)
exprs <- unquote(
expr = as.list(substitute(list(...), env = environment())[-1]),
env = parent.frame()
)
exprs <- as.list(substitute(list(...), env = environment()))[-1]
if (length(exprs) > 0) {
if (!is.null(names(exprs)))
.error("Filter expressions cannot be named.")
for (i in seq_along(exprs)) {
sel <- map_lgl(items$features, eval_filter_expr, expr = exprs[[i]])
for (expr in exprs) {
expr <- unquote(expr = expr, env = parent.frame())
sel <- map_lgl(items$features, eval_filter_expr, expr = expr)
items$features <- items$features[sel]
}
}
Expand Down
6 changes: 2 additions & 4 deletions R/static-funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,10 @@ links <- function(x, ...) {

#' @export
links.rstac_doc <- function(x, ...) {
exprs <- unquote(
expr = as.list(substitute(list(...), env = environment())[-1]),
env = parent.frame()
)
exprs <- as.list(substitute(list(...), env = environment()))[-1]
sel <- !logical(length(x$links))
for (expr in exprs) {
expr <- unquote(expr = expr, env = parent.frame())
sel <- sel & map_lgl(x$links, function(x) {
tryCatch(
eval(expr, envir = x),
Expand Down

0 comments on commit 4d1ca0b

Please sign in to comment.