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

IRKernel prints data.table with := #933

Closed
matthieugomez opened this issue Nov 6, 2014 · 6 comments
Closed

IRKernel prints data.table with := #933

matthieugomez opened this issue Nov 6, 2014 · 6 comments
Labels

Comments

@matthieugomez
Copy link
Contributor

It's basically the same issue than with knitr. I have printed the variable SYS (at line 82 of data.table.R) after a command such as DT[, a:=1] in IRKernel but I don't know enough to do a pull request.

[[1]]
IRkernel::main()

[[2]]
kernel$run()

[[3]]
handle_shell()

[[4]]
executor$execute(msg)

[[5]]
with_top_env(userenv, {
    tryCatch(evaluate(request$content$code, envir = userenv, 
        output_handler = oh, stop_on_error = 0), interrupt = function(cond) {
        interrupted <<- TRUE
    }, error = handle_error)
})

[[6]]
tryCatch(evaluate(request$content$code, envir = userenv, output_handler = oh, 
    stop_on_error = 0), interrupt = function(cond) {
    interrupted <<- TRUE
}, error = handle_error)

[[7]]
tryCatchList(expr, classes, parentenv, handlers)

[[8]]
tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), 
    names[nh], parentenv, handlers[[nh]])

[[9]]
doTryCatch(return(expr), name, parentenv, handler)

[[10]]
tryCatchList(expr, names[-nh], parentenv, handlers[-nh])

[[11]]
tryCatchOne(expr, names, parentenv, handlers[[1L]])

[[12]]
doTryCatch(return(expr), name, parentenv, handler)

[[13]]
evaluate(request$content$code, envir = userenv, output_handler = oh, 
    stop_on_error = 0)

[[14]]
evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, 
    debug = debug, last = i == length(out), use_try = stop_on_error != 
        2L, keep_warning = keep_warning, keep_message = keep_message, 
    output_handler = output_handler)

[[15]]
handle(pv <- withCallingHandlers(withVisible(value_fun(ev$value, 
    ev$visible)), warning = wHandler, error = eHandler, message = mHandler))

[[16]]
try(f, silent = TRUE)

[[17]]
tryCatch(expr, error = function(e) {
    call <- conditionCall(e)
    if (!is.null(call)) {
        if (identical(call[[1L]], quote(doTryCatch))) 
            call <- sys.call(-4L)
        dcall <- deparse(call)[1L]
        prefix <- paste("Error in", dcall, ": ")
        LONG <- 75L
        msg <- conditionMessage(e)
        sm <- strsplit(msg, "\n")[[1L]]
        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
        if (is.na(w)) 
            w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], 
                type = "b")
        if (w > LONG) 
            prefix <- paste0(prefix, "\n  ")
    }
    else prefix <- "Error : "
    msg <- paste0(prefix, conditionMessage(e), "\n")
    .Internal(seterrmessage(msg[1L]))
    if (!silent && identical(getOption("show.error.messages"), 
        TRUE)) {
        cat(msg, file = stderr())
        .Internal(printDeferredWarnings())
    }
    invisible(structure(msg, class = "try-error", condition = e))
})

[[18]]
tryCatchList(expr, classes, parentenv, handlers)

[[19]]
tryCatchOne(expr, names, parentenv, handlers[[1L]])

[[20]]
doTryCatch(return(expr), name, parentenv, handler)

[[21]]
withCallingHandlers(withVisible(value_fun(ev$value, ev$visible)), 
    warning = wHandler, error = eHandler, message = mHandler)

[[22]]
withVisible(value_fun(ev$value, ev$visible))

[[23]]
value_fun(ev$value, ev$visible)

[[24]]
value_handler(x)

[[25]]
paste(capture.output(print(obj)), collapse = "\n")

[[26]]
capture.output(print(obj))

[[27]]
evalVis(expr)

[[28]]
withVisible(eval(expr, pf))

[[29]]
eval(expr, pf)

[[30]]
eval(expr, envir, enclos)

[[31]]
print(obj)

[[32]]
print.data.table(obj)
@mattdowle
Copy link
Member

mattdowle commented Apr 28, 2016

Can this be closed now as it was from 2014 before the changes in v1.9.6 released in Sep 2015.

Although, something related has been raised recently as well :
https://github.com/IRkernel/IRkernel/issues/127#issuecomment-203070341

@jankatins
Copy link

jankatins commented May 19, 2016

irkernel prints via the repr package, i.e. repr_text.default() (source) or repr_text.matrix (source) If the latter, it is also printed by repr_html.matrix, repr_markdown.matrix and repr_latex.matrix . IMO the same workaround as for knit_print.default should go in here:

if (length(SYS) <= 2 || # "> DT" auto-print or "> print(DT)" explicit print (cannot distinguish from R 3.2.0 but that's ok)

Or make that a similar list as

cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdown","knitr", "IRkernel")
so we can contribute to that list.

Or build and export repr_xxx.data.frame methods which only spit out a string representation if print would print the data.table (is that possible?)

cc: @flying-sheep

@mattdowle mattdowle added this to the v1.9.8 milestone May 19, 2016
@mattdowle
Copy link
Member

mattdowle commented May 19, 2016

@JanSchulz Ok good idea. Thanks for investigating. Happy to try the simpler one first and see if it works ("making it a similar list as"). Will do.

@mattdowle
Copy link
Member

@mattdowle
Copy link
Member

@arunsrinivasan arunsrinivasan modified the milestones: v2.0.0, v1.9.8 Jul 21, 2016
@mattdowle mattdowle modified the milestones: v1.10.6, Candidate Feb 1, 2017
@mattdowle mattdowle modified the milestones: v1.10.6, Candidate Mar 30, 2018
@mattdowle mattdowle removed this from the Candidate milestone May 10, 2018
@mattdowle mattdowle added the High label May 29, 2018
@MichaelChirico
Copy link
Member

Just tried this on JupyterLab, it seems OK?

Screenshot 2020-06-07 at 5 43 08 PM

Closing ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants