Skip to content

Commit e0d2a2a

Browse files
committed
bugfix
1 parent 57ee0a7 commit e0d2a2a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/abstractdataset/selection.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
function normalize_select(idx, @nospecialize(cols...))
2-
selected_cols = Int[]
2+
selected_cols = [Int[], Int[]]
33
for i in 1:length(cols)
44
normalize_select!(selected_cols, idx, cols[i])
55
end
66
unique!(selected_cols)
77
end
88
function normalize_select!(selected_cols, idx, cols::ColumnIndex)
9-
push!(selected_cols, idx[cols])
9+
push!(selected_cols[1], idx[cols])
1010
end
1111

1212
function normalize_select!(selected_cols, idx, cols::MultiColumnIndex)
1313
colsidx = idx[cols]
1414
for i in 1:length(colsidx)
15-
push!(selected_cols, colsidx[i])
15+
push!(selected_cols[1], colsidx[i])
16+
end
17+
if cols isa Not
18+
colsidxnot = idx[cols.skip]
19+
for i in 1:length(colsidxnot)
20+
push!(selected_cols[2], colsidxnot[i])
21+
end
1622
end
1723
end
1824

1925
# sell and sell! will replace select and select!
2026
# Dataset shouldn't support copycols since it causes modifying a data set without telling other alias data sets
2127
function select(ds::Dataset, @nospecialize(args...))
22-
selected_cols = normalize_select(index(ds), args...)
28+
selected_cols_all = normalize_select(index(ds), args...)
29+
selected_cols = setdiff!(selected_cols_all[1], selected_cols_all[2])
2330
res = AbstractVector[]
2431

2532
for j in 1:length(selected_cols)
@@ -56,7 +63,8 @@ function select(ds::Dataset, @nospecialize(args...))
5663
end
5764

5865
function select!(ds, @nospecialize(args...))
59-
selected_cols = normalize_select(index(ds), args...)
66+
selected_cols_all = normalize_select(index(ds), args...)
67+
selected_cols = setdiff!(selected_cols_all[1], selected_cols_all[2])
6068
unwanted_cols = setdiff(1:ncol(ds), selected_cols)
6169
sort!(unwanted_cols, rev = true)
6270

0 commit comments

Comments
 (0)