镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Warning for set / := when numToDo > nrow(x)? #3557

Open

Description

@MichaelChirico

Follow-up to #2837 inspired by #1885 / #3460

We decided running duplicated every time we run set/:= to help protect against duplicated assignment is overkill & an efficiency killer.

However, when length(i) > nrow(x), there's no need to run duplicated -- there's guaranteed to be at least one duplicate in i (Pigeonhole):

DT = data.table(a = 1L)
DT[c(1, 1), a := 2:3]

We could warn in this case?

Activity

  1. jangorecki commented on May 12, 2019

    @jangorecki
    Member

    unless DT[c(1, NA), a := 2:3]

  2. franknarf1 commented on May 12, 2019

    @franknarf1
    Contributor

    Re @jangorecki 's example, you can use numToDo instead of length(i) then? That count is already recorded with NAs removed as seen in

    > DT[c(1, NA), a := 2:3, verbose=TRUE]
    Detected that j uses these columns: a 
    Assigning to 1 row subset of 1 rows
    RHS_list_of_columns == false
    

    I guess this would just be adding a warning near the message above

    if (verbose) Rprintf("Assigning to %d row subset of %d rows\n", numToDo, nrow);

    Related #2022

  3. changed the title [-]Warning for set / := when length(i) > nrow(x)?[/-] [+]Warning for set / := when numToDo > nrow(x)?[/+] on May 13, 2019
  4. MichaelChirico commented on May 13, 2019

    @MichaelChirico
    MemberAuthor

    Thanks Frank/Jan, yes length(i) is not the condition we should use but it seems numToDo would be the corrected adjustment.

    Main Q is whether we thing this is warning-worthy behavior? Or perhaps just something to append to/reiterate in the verbose message?

  5. jangorecki commented on Nov 30, 2019

    @jangorecki
    Member

    @MichaelChirico lets start with verbose message, this at least won't make any breaking changes

  6. jangorecki commented on May 19, 2020

    @jangorecki
    Member

    isn't it duplicate of #2022 ?

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

    by-referenceIssues related to by-reference/copying behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions