Skip to content

Commit

Permalink
bind items iterator for sets in gather
Browse files Browse the repository at this point in the history
Otherwise we get an overload resolution issue in the calling scope,
because `items` for `HashSet` won't be defined.
  • Loading branch information
Vindaar committed Sep 28, 2022
1 parent f6efa85 commit 5d3d7e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/datamancer/dataframe.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,9 @@ proc gather*[C: ColumnLike](df: DataTable[C], cols: varargs[string],
doAssert dfRes["Class", string] == ["A", "A", "A", "B", "B", "B", "C", "C", "C"].toTensor
doAssert dfRes["Num", int] == [1, 8, 0, 3, 4, 0, 5, 7, 2].toTensor

# bind `sets.items` so we do not need to export `sets`
bind sets.items

result = C.newDataTable(df.ncols)
let remainCols = getKeys(df).toHashSet.difference(cols.toHashSet)
let newLen = cols.len * df.len
Expand All @@ -2170,7 +2173,8 @@ proc gather*[C: ColumnLike](df: DataTable[C], cols: varargs[string],
result.asgn(key, toColumn keyTensor)
result.asgn(value, toColumn valTensor)
# For remainder of columns, just use something like `repeat`!, `stack`, `concat`
for rem in remainCols:
# Note: explicit `items` call necessary, otherwise our `bind` does not work
for rem in items(remainCols):
withNativeDtype(df[rem]): ## XXX: this might convert to colObject?
let col = df[rem].toTensor(dtype)
var fullCol = newTensorUninit[dtype](newLen)
Expand Down

0 comments on commit 5d3d7e8

Please sign in to comment.