Skip to content
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

routines.R -> publicly visible #17

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions share/jupyter/kernels/xr/resources/execute.R
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ handle_error <- function(e) {
}

handle_value <- function(execution_counter) function(obj, visible) {
set_last_value(obj)
if (!visible) return()

# only doing text-plain for now
2 changes: 1 addition & 1 deletion share/jupyter/kernels/xr/resources/routines.R
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@ publish_stream <- function(name, text) {
}

display_data <- function(data = NULL, metadata = NULL) {
.Call("xeusr_display_data", jsonlite::toJSON(data), jsonlite::toJSON(metadata), PACKAGE = "(embedding)")
invisible(.Call("xeusr_display_data", jsonlite::toJSON(data), jsonlite::toJSON(metadata), PACKAGE = "(embedding)"))
}
3 changes: 2 additions & 1 deletion share/jupyter/kernels/xr/resources/setup.R
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ local({
"..", "share", "jupyter", "kernels", "xr", "resources"
)

files <- setdiff(list.files(here), "setup.R")
files <- setdiff(list.files(here), c("setup.R", "routines.R"))

xeus_env$.xeus_call <- function(fn, ...) {
get(fn, envir = xeus_private_env)(...)
@@ -26,5 +26,6 @@ local({
for (f in files) {
sys.source(file.path(here, f), envir = xeus_private_env)
}
sys.source(file.path(here, "routines.R"), envir = xeus_env)

})
6 changes: 6 additions & 0 deletions share/jupyter/kernels/xr/resources/utils.R
Original file line number Diff line number Diff line change
@@ -10,6 +10,12 @@ namedlist <- function() {
`names<-`(list(), character())
}

set_last_value <- function(obj) {
unlockBinding(".Last.value", .BaseNamespaceEnv)
assign(".Last.value", obj, .BaseNamespaceEnv)
lockBinding(".Last.value", .BaseNamespaceEnv)
}

# borrowed from IRkernel
plot_builds_upon <- function(prev, current) {
if (is.null(prev)) {