DorisAmoakohene / Researchwork_Rdata.table

0 stars 0 forks source link

Issue 5371 plotting is giving me a linear graph #3

Open DorisAmoakohene opened 1 year ago

DorisAmoakohene commented 1 year ago

@tdhock i am trying to plot the atime version, to check The before Regression, Regression and Fixed of the above issues but my graph is giving me a linear which seems not to be accurate

This is the link to the codes I am reproducing https://github.com/Rdatatable/data.table/pull/5463

atime.list.3 <- atime::atime_versions(
pkg.path=tdir,
pkg.edit.fun=function(old.Package, new.Package, sha, new.pkg.path){
      pkg_find_replace <- function(glob, FIND, REPLACE){
        atime::glob_find_replace(file.path(new.pkg.path, glob), FIND, REPLACE)
      }
      Package_regex <- gsub(".", "_?", old.Package, fixed=TRUE)
      Package_ <- gsub(".", "_", old.Package, fixed=TRUE)
      new.Package_ <- paste0(Package_, "_", sha)
      pkg_find_replace(
        "DESCRIPTION", 
        paste0("Package:\\s+", old.Package),
        paste("Package:", new.Package))
      pkg_find_replace(
        file.path("src","Makevars.*in"),
        Package_regex,
        new.Package_)
      pkg_find_replace(
        file.path("R", "onLoad.R"),
        Package_regex,
        new.Package_)
      pkg_find_replace(
        file.path("R", "onLoad.R"),
        sprintf('packageVersion\\("%s"\\)', old.Package),
        sprintf('packageVersion\\("%s"\\)', new.Package))
      pkg_find_replace(
        file.path("src", "init.c"),
        paste0("R_init_", Package_regex),
        paste0("R_init_", gsub("[.]", "_", new.Package_)))
      pkg_find_replace(
        "NAMESPACE",
        sprintf('useDynLib\\("?%s"?', Package_regex),
        paste0('useDynLib(', new.Package_))
    },
  N=10^seq(3,8),
  setup={
    d1 <- abs(rnorm(N, sd = 4))
    d2 <- as.integer(cumsum(d1))
    tm <- as.POSIXct("2020-01-01 09:30:00") + d2
    nIds <- 3
    tmCol <- rep(tm, nIds)
    idCol <- rep(c("a", "b", "c"), N)
    f1 <- function() {
    dt <- data.table(tm = tmCol, v = 1, id = idCol)
    dt[, tm1 := tm - 40]
    dt[, tm2 := tm]
    dt[, rowNum := .I]
    dt[dt, .(vs = sum(v)), on = .(id, rowNum <= rowNum, tm >= tm1, tm < tm2), by = .EACHI]
    }
    },

  expr=data.table:::`[.data.table`(f1),
  "Before"="be2f72e6f5c90622fe72e1c315ca05769a9dc854",
  "Regression"="e793f53466d99f86e70fc2611b708ae8c601a451", #Before and Regression:https://github.com/Rdatatable/data.table/pull/4491/commits from this commits id in github. on(news items tweak and move items up)
  "Fixed"="58409197426ced4714af842650b0cc3b9e2cb842") #fixed:#https://github.com/Rdatatable/data.table/pull/5463/commits; taken from the last commits in here. for fixed.
library(data.table)
set.seed(1)
n <- 1e6
d1 <- abs(rnorm(n, sd = 4))
d2 <- as.integer(cumsum(d1))
tm <- as.POSIXct("2020-01-01 09:30:00") + d2
nIds <- 3
tmCol <- rep(tm, nIds)
idCol <- rep(c("a", "b", "c"), n)
f1 <- function() {
    dt <- data.table(tm = tmCol, v = 1, id = idCol)
    dt[, tm1 := tm - 40]
    dt[, tm2 := tm]
    dt[, rowNum := .I]
    dt[dt, .(vs = sum(v)), on = .(id, rowNum <= rowNum, tm >= tm1, tm < tm2), by = .EACHI]
}
system.time(
  f1()
)

Screenshot 2023-11-10 180441

tdhock commented 12 months ago

expr does not do anything. It should probably do the last line of

    dt[, tm1 := tm - 40]
    dt[, tm2 := tm]
    dt[, rowNum := .I]
    dt[dt, .(vs = sum(v)), on = .(id, rowNum <= rowNum, tm >= tm1, tm < tm2), by = .EACHI]