Skip to content

IRKernel prints data.table with := #933

Description

@matthieugomez

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)

Activity

  1. mattdowle commented on Apr 28, 2016

    @mattdowle
    Member

    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

  2. jankatins commented on May 19, 2016

    @jankatins

    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

  3. added this to the v1.9.8 milestone on May 19, 2016
  4. mattdowle commented on May 19, 2016

    @mattdowle
    Member

    @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.

  5. mattdowle commented on May 19, 2016

    @mattdowle
    Member
  6. mattdowle commented on May 26, 2016

    @mattdowle
    Member
  7. modified the milestones: , v1.9.8 on Jul 21, 2016
  8. modified the milestones: , on Feb 1, 2017
  9. modified the milestones: , on Mar 30, 2018
  10. removed this from the milestone on May 10, 2018
  11. MichaelChirico commented on Jun 7, 2020

    @MichaelChirico
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions