@@ -18699,226 +18699,227 @@ test(2264.8, print(DT, show.indices=TRUE), output=ans)
1869918699
1870018700# tests for new consistent replacement of list columns with list(NULL), #5558
1870118701# replacement of a list column with list(NULL) in a single-row data.table, using different assignment methods
18702- DT = data.table(L = list("A"), i = 1L)
18703- ans = data.table(L = list(NULL), i = 1L)
18702+ DT = data.table(L= list("A"), i= 1L)
18703+ ans = data.table(L= list(NULL), i= 1L)
1870418704# test using replacement with $ operator
1870518705DT$L = list(NULL)
1870618706test(2265.01, DT, ans)
18707- DT = data.table(L = list("A"), i = 1L)
18707+ DT = data.table(L= list("A"), i= 1L)
1870818708# standard form with := operator
1870918709test(2265.02, copy(DT)[, L := list(NULL)], ans)
1871018710# functional form with := operator
18711- test(2265.03, copy(DT)[, `:=`(L = list(NULL))], ans)
18711+ test(2265.03, copy(DT)[, `:=`(L= list(NULL))], ans)
1871218712# functional form with 'let' alias
18713- test(2265.04, copy(DT)[, let(L = list(NULL))], ans)
18713+ test(2265.04, copy(DT)[, let(L= list(NULL))], ans)
1871418714# using set()
18715- test(2265.05, set(copy(DT), j = "L", value = list(NULL)), ans)
18716- # tests doing the same as above, but with multiple columns
18717- DT = data.table(L1 = list("A"), L2 = list("B"), i = 1L)
18718- ans = data.table(L1 = list(NULL), L2 = list(NULL), i = 1L)
18715+ test(2265.05, set(copy(DT), j="L", value=list(NULL)), ans)
18716+
18717+ # multiple list columns
18718+ DT = data.table(L1=list("A"), L2=list("B"), i=1L)
18719+ ans = data.table(L1=list(NULL), L2=list(NULL), i=1L)
1871918720DT$L1 = list(NULL)
1872018721DT$L2 = list(NULL)
1872118722test(2265.06, DT, ans)
18722- DT = data.table(L1 = list("A"), L2 = list("B"), i = 1L)
18723+ DT = data.table(L1= list("A"), L2= list("B"), i= 1L)
1872318724# standard form with := operator
1872418725test(2265.07, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
1872518726# functional form with := operator
18726- test(2265.08, copy(DT)[, `:=`(L1 = list(NULL), L2 = list(NULL))], ans)
18727+ test(2265.08, copy(DT)[, `:=`(L1= list(NULL), L2= list(NULL))], ans)
1872718728# functional form with 'let' alias
18728- test(2265.09, copy(DT)[, let(L1 = list(NULL), L2 = list(NULL))], ans)
18729+ test(2265.09, copy(DT)[, let(L1= list(NULL), L2= list(NULL))], ans)
1872918730# using set()
18730- test(2265.10, set(copy(DT), j = c("L1", "L2"), value = list(list(NULL), list(NULL))), ans)
18731+ test(2265.10, set(copy(DT), j= c("L1", "L2"), value= list(list(NULL), list(NULL))), ans)
1873118732
1873218733# replacement of a list column with list(NULL) in a multi-row data.table, using different assignment methods
18733- DT = data.table(L = list("A", "B"), i = 1L)
18734- ans = data.table(L = list(NULL, NULL), i = 1L)
18734+ DT = data.table(L= list("A", "B"), i= 1L)
18735+ ans = data.table(L= list(NULL, NULL), i= 1L)
1873518736# test using replacement with $ operator
1873618737DT$L = list(NULL)
1873718738test(2265.11, DT, ans)
18738- DT = data.table(L = list("A", "B"), i = 1L)
18739+ DT = data.table(L= list("A", "B"), i= 1L)
1873918740# standard form with := operator
1874018741test(2265.12, copy(DT)[, L := list(NULL)], ans)
1874118742# functional form with := operator
18742- test(2265.13, copy(DT)[, `:=`(L = list(NULL))], ans)
18743+ test(2265.13, copy(DT)[, `:=`(L= list(NULL))], ans)
1874318744# functional form with 'let' alias
18744- test(2265.14, copy(DT)[, let(L = list(NULL))], ans)
18745+ test(2265.14, copy(DT)[, let(L= list(NULL))], ans)
1874518746# using set()
18746- test(2265.15, set(copy(DT), j = "L", value = list(NULL)), ans)
18747+ test(2265.15, set(copy(DT), j= "L", value= list(NULL)), ans)
1874718748# tests doing the same as above, but with multiple columns
18748- DT = data.table(L1 = list("A", "B"), L2 = list("B", "C"), i = 1L)
18749- ans = data.table(L1 = list(NULL, NULL), L2 = list(NULL, NULL), i = 1L)
18749+ DT = data.table(L1= list("A", "B"), L2= list("B", "C"), i= 1L)
18750+ ans = data.table(L1= list(NULL, NULL), L2= list(NULL, NULL), i= 1L)
1875018751DT$L1 = list(NULL)
1875118752DT$L2 = list(NULL)
1875218753test(2265.16, DT, ans)
18753- DT = data.table(L1 = list("A", "B"), L2 = list("B", "C"), i = 1L)
18754+ DT = data.table(L1= list("A", "B"), L2= list("B", "C"), i= 1L)
1875418755# standard form with := operator
18755- test(2265.17, copy(DT)[, c("L1", "L2"):= list(list(NULL), list(NULL))], ans)
18756+ test(2265.17, copy(DT)[, c("L1", "L2") := list(list(NULL), list(NULL))], ans)
1875618757# functional form with := operator
18757- test(2265.18, copy(DT)[, `:=`(L1 = list(NULL), L2 = list(NULL))], ans)
18758+ test(2265.18, copy(DT)[, `:=`(L1= list(NULL), L2= list(NULL))], ans)
1875818759# functional form with 'let' alias
18759- test(2265.19, copy(DT)[, let(L1 = list(NULL), L2 = list(NULL))], ans)
18760+ test(2265.19, copy(DT)[, let(L1= list(NULL), L2= list(NULL))], ans)
1876018761# using set()
18761- test(2265.20, set(copy(DT), j = c("L1", "L2"), value = list(list(NULL), list(NULL))), ans)
18762+ test(2265.20, set(copy(DT), j= c("L1", "L2"), value= list(list(NULL), list(NULL))), ans)
1876218763
1876318764# Adding an empty list column to a single-row data.table, using different assignment methods
18764- DT = data.table(L = list("A"), i = 1L)
18765- ans = data.table(L = list("A"), i = 1L, D = list(NULL))
18765+ DT = data.table(L= list("A"), i= 1L)
18766+ ans = data.table(L= list("A"), i= 1L, D= list(NULL))
1876618767warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1876718768# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
1876818769test(2265.21, copy(DT)[, D := list(NULL)], DT, warning=warn)
18769- test(2265.22, set(copy(DT), j = "D", value = list(NULL)), DT, warning=warn)
18770+ test(2265.22, set(copy(DT), j= "D", value= list(NULL)), DT, warning=warn)
1877018771# add a new column by wrapping list(NULL), consistent with old behavior
1877118772DT$D = list(list(NULL))
1877218773test(2265.23, DT, ans)
18773- DT = data.table(L = list("A"), i = 1L)
18774+ DT = data.table(L= list("A"), i= 1L)
1877418775# test adding empty list column in standard form with := operator
1877518776test(2265.24, copy(DT)[, D := .(list(NULL))], ans)
1877618777# functional form with := operator
18777- test(2265.25, copy(DT)[, `:=`(D = list(NULL))], ans)
18778+ test(2265.25, copy(DT)[, `:=`(D= list(NULL))], ans)
1877818779# functional form with 'let' alias
18779- test(2265.26, copy(DT)[, let(D = list(NULL))], ans)
18780+ test(2265.26, copy(DT)[, let(D= list(NULL))], ans)
1878018781# using set()
18781- test(2265.27, set(copy(DT), j = "D", value = list(list(NULL))), ans)
18782+ test(2265.27, set(copy(DT), j= "D", value= list(list(NULL))), ans)
1878218783# tests doing the same as above, but with multiple columns
18783- DT = data.table(L = list("A"), i = 1L)
18784- ans = data.table(L = list("A"), i = 1L, D = list(NULL), R = list(NULL))
18784+ DT = data.table(L= list("A"), i= 1L)
18785+ ans = data.table(L= list("A"), i= 1L, D= list(NULL), R= list(NULL))
1878518786DT$D = list(list(NULL))
1878618787DT$R = list(list(NULL))
1878718788test(2265.28, DT, ans)
18788- DT = data.table(L = list("A"), i = 1L)
18789+ DT = data.table(L= list("A"), i= 1L)
1878918790# standard form with := operator
18790- test(2265.29, copy(DT)[, c("D", "R"):= .(list(NULL))], ans)
18791+ test(2265.29, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
1879118792# functional form with := operator
18792- test(2265.30, copy(DT)[, `:=`(D = list(NULL), R = list(NULL))], ans)
18793+ test(2265.30, copy(DT)[, `:=`(D= list(NULL), R= list(NULL))], ans)
1879318794# functional form with 'let' alias
18794- test(2265.31, copy(DT)[, let(D = list(NULL), R = list(NULL))], ans)
18795+ test(2265.31, copy(DT)[, let(D= list(NULL), R= list(NULL))], ans)
1879518796# using set()
18796- test(2265.32, set(copy(DT), j = c("D", "R"), value = list(list(NULL))), ans)
18797+ test(2265.32, set(copy(DT), j= c("D", "R"), value= list(list(NULL))), ans)
1879718798
1879818799# Adding an empty list column to a multi-row data.table, using different assignment methods
18799- DT = data.table(L = list("A", "B"), i = 1L)
18800- ans = data.table(L = list("A", "B"), i = 1L, D = list(NULL, NULL))
18800+ DT = data.table(L= list("A", "B"), i= 1L)
18801+ ans = data.table(L= list("A", "B"), i= 1L, D= list(NULL, NULL))
1880118802warn = "Tried to assign NULL to column 'D', but this column does not exist to remove"
1880218803# try to add a new empty list by list(NULL) with := in standard form, warns and does not change
1880318804test(2265.33, copy(DT)[, D := list(NULL)], DT, warning=warn)
18804- test(2265.34, set(copy(DT), j = "D", value = list(NULL)), DT, warning=warn)
18805+ test(2265.34, set(copy(DT), j= "D", value= list(NULL)), DT, warning=warn)
1880518806# add a new column by wrapping list(NULL), consistent with old behavior
1880618807DT$D = list(list(NULL))
1880718808test(2265.35, DT, ans)
18808- DT = data.table(L = list("A", "B"), i = 1L)
18809+ DT = data.table(L= list("A", "B"), i= 1L)
1880918810# test adding empty list column in standard form with := operator
1881018811test(2265.36, copy(DT)[, D := .(list(NULL))], ans)
1881118812# functional form with := operator
18812- test(2265.37, copy(DT)[, `:=`(D = list(NULL))], ans)
18813+ test(2265.37, copy(DT)[, `:=`(D= list(NULL))], ans)
1881318814# functional form with 'let' alias
18814- test(2265.38, copy(DT)[, let(D = list(NULL))], ans)
18815+ test(2265.38, copy(DT)[, let(D= list(NULL))], ans)
1881518816# using set()
18816- test(2265.39, set(copy(DT), j = "D", value = list(list(NULL))), ans)
18817+ test(2265.39, set(copy(DT), j= "D", value = list(list(NULL))), ans)
1881718818# tests doing the same as above, but with multiple columns
18818- DT = data.table(L = list("A", "B"), i = 1L)
18819- ans = data.table(L = list("A", "B"), i = 1L, D = list(NULL, NULL), R = list(NULL, NULL))
18819+ DT = data.table(L= list("A", "B"), i= 1L)
18820+ ans = data.table(L= list("A", "B"), i= 1L, D= list(NULL, NULL), R= list(NULL, NULL))
1882018821DT$D = list(list(NULL))
1882118822DT$R = list(list(NULL))
1882218823test(2265.40, DT, ans)
18823- DT = data.table(L = list("A", "B"), i = 1L)
18824+ DT = data.table(L= list("A", "B"), i= 1L)
1882418825# standard form with := operator
18825- test(2265.41, copy(DT)[, c("D", "R"):= .(list(NULL))], ans)
18826+ test(2265.41, copy(DT)[, c("D", "R") := .(list(NULL))], ans)
1882618827# functional form with := operator
18827- test(2265.42, copy(DT)[, `:=`(D = list(NULL), R = list(NULL))], ans)
18828+ test(2265.42, copy(DT)[, `:=`(D= list(NULL), R= list(NULL))], ans)
1882818829# functional form with 'let' alias
18829- test(2265.43, copy(DT)[, let(D = list(NULL), R = list(NULL))], ans)
18830+ test(2265.43, copy(DT)[, let(D= list(NULL), R= list(NULL))], ans)
1883018831# using set()
18831- test(2265.44, set(copy(DT), j = c("D", "R"), value = list(list(NULL))), ans)
18832+ test(2265.44, set(copy(DT), j= c("D", "R"), value= list(list(NULL))), ans)
1883218833
1883318834# Removal of a list column in a single-row data.table, using different assignment methods
1883418835# NOTE: There is only one way to remove columns now, by assigning to NULL
18835- DT = data.table(L = list("A"), i = 1L)
18836- ans = data.table(i = 1L)
18836+ DT = data.table(L= list("A"), i= 1L)
18837+ ans = data.table(i= 1L)
1883718838# test removing a list column by assigning to NULL
1883818839DT$L = NULL
1883918840test(2265.45, DT, ans)
18840- DT = data.table(L = list("A"), i = 1L)
18841+ DT = data.table(L= list("A"), i= 1L)
1884118842# standard form with := operator
1884218843test(2265.46, copy(DT)[, L := NULL], ans)
1884318844# functional form with := operator
18844- test(2265.47, copy(DT)[, `:=`(L = NULL)], ans)
18845+ test(2265.47, copy(DT)[, `:=`(L= NULL)], ans)
1884518846# functional form with 'let' alias
18846- test(2265.48, copy(DT)[, let(L = NULL)], ans)
18847+ test(2265.48, copy(DT)[, let(L= NULL)], ans)
1884718848# using set()
18848- test(2265.49, set(copy(DT), j = "L", value = NULL), ans)
18849+ test(2265.49, set(copy(DT), j= "L", value= NULL), ans)
1884918850# test doing the same as above, but with multiple columns
18850- DT = data.table(L1 = list("A"), L2 = list("B"), i = 1L)
18851+ DT = data.table(L1= list("A"), L2= list("B"), i= 1L)
1885118852# test removing two list columns by assigning to NULL
1885218853DT$L1 = NULL
1885318854DT$L2 = NULL
1885418855test(2265.50, DT, ans)
18855- DT = data.table(L1 = list("A"), L2 = list("B"), i = 1L)
18856+ DT = data.table(L1= list("A"), L2= list("B"), i= 1L)
1885618857# standard form with := operator
1885718858test(2265.51, copy(DT)[, c("L1", "L2") := NULL], ans)
1885818859# functional form with := operator
18859- test(2265.52, copy(DT)[, `:=`(L1 = NULL, L2 = NULL)], ans)
18860+ test(2265.52, copy(DT)[, `:=`(L1= NULL, L2= NULL)], ans)
1886018861# functional form with 'let' alias
18861- test(2265.53, copy(DT)[, let(L1 = NULL, L2 = NULL)], ans)
18862+ test(2265.53, copy(DT)[, let(L1= NULL, L2= NULL)], ans)
1886218863# using set()
18863- test(2265.54, set(copy(DT), j = c("L1", "L2"), value = NULL), ans)
18864+ test(2265.54, set(copy(DT), j= c("L1", "L2"), value= NULL), ans)
1886418865
1886518866# Removal of a list column in a multi-row data.table, using different assignment methods
18866- DT = data.table(L = list("A", "B"), i = 1L)
18867- ans = data.table(i = c(1L, 1L))
18867+ DT = data.table(L= list("A", "B"), i= 1L)
18868+ ans = data.table(i= c(1L, 1L))
1886818869# test removing a list column by assigning to NULL
1886918870DT$L = NULL
1887018871test(2265.55, DT, ans)
18871- DT = data.table(L = list("A", "B"), i = 1L)
18872+ DT = data.table(L= list("A", "B"), i= 1L)
1887218873# standard form with := operator
1887318874test(2265.56, copy(DT)[, L := NULL], ans)
1887418875# functional form with := operator
18875- test(2265.57, copy(DT)[, `:=`(L = NULL)], ans)
18876+ test(2265.57, copy(DT)[, `:=`(L= NULL)], ans)
1887618877# functional form with 'let' alias
18877- test(2265.58, copy(DT)[, let(L = NULL)], ans)
18878+ test(2265.58, copy(DT)[, let(L= NULL)], ans)
1887818879# using set()
18879- test(2265.59, set(copy(DT), j = "L", value = NULL), ans)
18880+ test(2265.59, set(copy(DT), j= "L", value= NULL), ans)
1888018881# test doing the same as above, but with multiple columns
18881- DT = data.table(L1 = list("A", "B"), L2 = list("B", "C"), i = 1L)
18882+ DT = data.table(L1= list("A", "B"), L2= list("B", "C"), i= 1L)
1888218883# test removing two list columns by assigning to NULL
1888318884DT$L1 = NULL
1888418885DT$L2 = NULL
1888518886test(2265.60, DT, ans)
18886- DT = data.table(L1 = list("A", "B"), L2 = list("B", "C"), i = 1L)
18887+ DT = data.table(L1= list("A", "B"), L2= list("B", "C"), i= 1L)
1888718888# standard form with := operator
1888818889test(2265.61, copy(DT)[, c("L1", "L2") := NULL], ans)
1888918890# functional form with := operator
18890- test(2265.62, copy(DT)[, `:=`(L1 = NULL, L2 = NULL)], ans)
18891+ test(2265.62, copy(DT)[, `:=`(L1= NULL, L2= NULL)], ans)
1889118892# functional form with 'let' alias
18892- test(2265.63, copy(DT)[, let(L1 = NULL, L2 = NULL)], ans)
18893+ test(2265.63, copy(DT)[, let(L1= NULL, L2= NULL)], ans)
1889318894# using set()
18894- test(2265.64, set(copy(DT), j = c("L1", "L2"), value = NULL), ans)
18895+ test(2265.64, set(copy(DT), j= c("L1", "L2"), value= NULL), ans)
1889518896
1889618897# Combining queries (add/remove/replace columns in the same query) for a single-row data.table
18897- DT = data.table(L = list("A"), i = 1L)
18898+ DT = data.table(L= list("A"), i= 1L)
1889818899# test for adding a new empty list column D and removing column L in the same query
18899- ans = data.table(i = 1L, D = list(NULL))
18900+ ans = data.table(i= 1L, D= list(NULL))
1890018901test(2265.65, copy(DT)[, c("L", "D") := list(NULL, list(NULL))], ans)
18901- test(2265.66, copy(DT)[, `:=`(L = NULL, D = list(NULL))], ans)
18902- test(2265.67, copy(DT)[, let(L = NULL, D = list(NULL))], ans)
18903- test(2265.68, set(copy(DT), j = c("L", "D"), value = list(NULL, list(NULL))), ans)
18904- DT = data.table(L = list("A"), i = 1L)
18902+ test(2265.66, copy(DT)[, `:=`(L= NULL, D= list(NULL))], ans)
18903+ test(2265.67, copy(DT)[, let(L= NULL, D= list(NULL))], ans)
18904+ test(2265.68, set(copy(DT), j= c("L", "D"), value= list(NULL, list(NULL))), ans)
18905+ DT = data.table(L= list("A"), i= 1L)
1890518906# test for adding a new empty list column D and replacing column L with empty list in the same query
18906- ans = data.table(L = list(NULL), i = 1L, D = list(NULL))
18907+ ans = data.table(L= list(NULL), i= 1L, D= list(NULL))
1890718908test(2265.69, copy(DT)[, c("L", "D") := list(list(NULL), list(NULL))], ans)
18908- test(2265.70, copy(DT)[, `:=`(L = list(NULL), D = list(NULL))], ans)
18909- test(2265.71, copy(DT)[, let(L = list(NULL), D = list(NULL))], ans)
18910- test(2265.72, set(copy(DT), j = c("L", "D"), value = list(list(NULL), list(NULL))), ans)
18911- DT = data.table(L = list("A"), D = list("B"), i = 1L)
18909+ test(2265.70, copy(DT)[, `:=`(L= list(NULL), D= list(NULL))], ans)
18910+ test(2265.71, copy(DT)[, let(L= list(NULL), D= list(NULL))], ans)
18911+ test(2265.72, set(copy(DT), j= c("L", "D"), value= list(list(NULL), list(NULL))), ans)
18912+ DT = data.table(L= list("A"), D= list("B"), i= 1L)
1891218913# test for replacing column L with an empty list and removing list column D in the same query
18913- ans = data.table(L = list(NULL), i = 1L)
18914+ ans = data.table(L= list(NULL), i= 1L)
1891418915test(2265.73, copy(DT)[, c("L", "D") := list(list(NULL), NULL)], ans)
18915- test(2265.74, copy(DT)[, `:=`(L = list(NULL), D = NULL)], ans)
18916- test(2265.75, copy(DT)[, let(L = list(NULL), D = NULL)], ans)
18917- test(2265.76, set(copy(DT), j = c("L", "D"), value = list(list(NULL), NULL)), ans)
18918- DT = data.table(L = list("A"), D = list("B"), i = 1L)
18916+ test(2265.74, copy(DT)[, `:=`(L= list(NULL), D= NULL)], ans)
18917+ test(2265.75, copy(DT)[, let(L= list(NULL), D= NULL)], ans)
18918+ test(2265.76, set(copy(DT), j= c("L", "D"), value= list(list(NULL), NULL)), ans)
18919+ DT = data.table(L= list("A"), D= list("B"), i= 1L)
1891918920# test for combining add, replace, remove in the same query
18920- ans = data.table(L = list(NULL), i = 1L, E = list(NULL))
18921+ ans = data.table(L= list(NULL), i= 1L, E= list(NULL))
1892118922test(2265.77, copy(DT)[, c("L", "D", "E") := list(list(NULL), NULL, list(NULL))], ans)
18922- test(2265.78, copy(DT)[, `:=`(L = list(NULL), D = NULL, E = list(NULL))], ans)
18923- test(2265.79, copy(DT)[, let(L = list(NULL), D = NULL, E = list(NULL))], ans)
18924- test(2265.80, set(copy(DT), j = c("L", "D", "E"), value = list(list(NULL), NULL, list(NULL))), ans)
18923+ test(2265.78, copy(DT)[, `:=`(L= list(NULL), D= NULL, E= list(NULL))], ans)
18924+ test(2265.79, copy(DT)[, let(L= list(NULL), D= NULL, E= list(NULL))], ans)
18925+ test(2265.80, set(copy(DT), j= c("L", "D", "E"), value= list(list(NULL), NULL, list(NULL))), ans)
0 commit comments