Skip to content

Commit

Permalink
add better 0-length ptype for tfd_irreg
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-s committed Feb 14, 2024
1 parent d196b5e commit ff91f79
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/tfd-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ new_tfd <- function(arg = NULL, datalist = NULL, regular = TRUE,
# FIXME: names weirdness- tfd objects will ALWAYS be named if they were
# created from an (intermediate) data.frame, but may be unnamed for different
# provenance....
if (vctrs::vec_size(datalist) == 0) {
if (vctrs::vec_size(datalist) == 0 || all(is.na(unlist(datalist)))) {
subclass <- ifelse(regular, "tfd_reg", "tfd_irreg")
message("empty input `data`; returning prototype of length 0")
datalist <- ifelse(regular,
list(),
list(list(arg = list(), value = list()))
)
message("empty or missing input `data`; returning prototype of length 0")
ret <- vctrs::new_vctr(
datalist,
arg = list(numeric()),
Expand Down

0 comments on commit ff91f79

Please sign in to comment.