moodymudskipper / flow

View and Browse Code Using Flow Diagrams
https://moodymudskipper.github.io/flow/
Other
395 stars 26 forks source link

Some simple functions fail #45

Closed smingerson closed 3 years ago

smingerson commented 3 years ago

Functions such as identity() and max() fail. Not that there's really anything useful to be gained from viewing the diagrams of these functions, but a more informative error would be great if diagrams for them don't pan out. Thank you!

library(flow)
x <- 7
fx <- function(x) {x+1}
flow_run(fx(x))
flow_run(identity(x))
#> Error in bdexpr[[1L]]: object of type 'symbol' is not subsettable
#> [1] 8
flow_run(max(x))
#> Error in while (as.character(bdexpr[[1L]]) == "{") bdexpr <- bdexpr[[2L]]: argument is of length zero
flow_run(date())
#> [1] "Wed Aug 19 16:41:21 2020"
moodymudskipper commented 3 years ago

Thanks for your precious feedback.

flow doesn't work on primitives like max, and indeed there is nothing to show there, but I need to put a better error message and I will.

I'm suprised about identity, good catch! It seems that I need an exception for flow_run when the body is a symbol (flow_view works)

moodymudskipper commented 3 years ago

ah, funny, about identity it's actually a base R bug, utils::isS3stdGeneric(identity) triggers an error.

It was easy to work around fortunately.

And functions without body, such as primitives like max, now fail explicitly.

library(flow)
flow_view(identity)

flow_view(max)
#> Error in as.function.default(c(as.list(formals(fun)), list(value)), envir): l'utilisation de l'environnement NULL n'est plus autorisée
flow_run(identity(1))
#> Error in bdexpr[[1L]]: objet de type 'symbol' non indiçable
flow_run(max(1))
#> Error in while (as.character(bdexpr[[1L]]) == "{") bdexpr <- bdexpr[[2L]]: l'argument est de longueur nulle

Created on 2020-08-20 by the reprex package (v0.3.0)

https://github.com/moodymudskipper/flow/commit/a6585f14cf13e0f072b5a234838ef17b9320a8ff https://github.com/moodymudskipper/flow/commit/b920419655181d018a08773f630add5d0d7da7b2

github-actions[bot] commented 2 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.