Skip to content

Commit 0f66a86

Browse files
committed
bug fix
1 parent d851d07 commit 0f66a86

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/abstractdataset/selection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Select columns of `ds` based on `args...`. `args` can be any column selector: co
114114
115115
It modifies the data set in-place. See [`select`](@ref) if a copy of selected columns is desired.
116116
"""
117-
function select!(ds, @nospecialize(args...))
117+
function select!(ds::Dataset, @nospecialize(args...))
118118
selected_cols_all = normalize_select(index(ds), args...)
119119
selected_cols = setdiff!(selected_cols_all[1], selected_cols_all[2])
120120
unwanted_cols = setdiff(1:ncol(ds), selected_cols)

src/byrow/row_functions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,8 @@ end
11421142
function row_join(ds::AbstractDataset, cols = :; threads = true, delim::AbstractString = ",", last::AbstractString = "")
11431143
colsidx = multiple_getindex(index(ds), cols)
11441144

1145-
max_line_size = maximum(byrow(ds, sum, colsidx, by = y->length(__STRING(y)), threads = threads))
1146-
max_line_size += length(delim)*(length(colsidx)) + length(last)+1
1145+
max_line_size = maximum(byrow(ds, sum, colsidx, by = y->ncodeunits(__STRING(y)), threads = threads))
1146+
max_line_size += ncodeunits(delim)*(length(colsidx)) + ncodeunits(last)+1
11471147
init0 = Matrix{UInt8}(undef, max_line_size, nrow(ds))
11481148
curr_pos = ones(Int, nrow(ds))
11491149

src/byrow/util.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ end
145145

146146

147147
function write_vals!(a, pos, x::AbstractString)
148-
needed_space = length(x)
148+
needed_space = ncodeunits(x)
149149
available_space = length(a)-pos+1
150150
needed_space > available_space && throw(ArgumentError("not enough space in buffer to write value into it"))
151151
z = Base.CodeUnits(x)
152-
for i in 1:length(x)
152+
for i in 1:ncodeunits(x)
153153
a[i+pos-1] =z[i]
154154
end
155-
pos+length(x)
155+
pos+ncodeunits(x)
156156
end
157157

158158

src/dataset/modify.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ end
254254
function normalize_modify!(outidx::Index, idx, arg::AbstractVector)
255255
res = Any[]
256256
for i in 1:length(arg)
257-
_res = normalize_modify!(outidx::Index, idx::Index, arg[i])
257+
_res = normalize_modify!(outidx::Index, idx, arg[i])
258258
if _res isa AbstractVector
259259
for j in 1:length(_res)
260260
push!(res, _res[j])

test/byrow.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@
335335

336336
ds = Dataset(x = [1,10], x2 = ["A", "BC"], x3 = [2.0,4.54])
337337
@test byrow(ds, join, :, delim = "--", last = "-") == ["1--A-2.0", "10--BC-4.54"]
338+
339+
340+
ds = Dataset(x = ["α1", "β∘1"], y = [1,2], z = [1.4,5.6])
341+
@test byrow(ds, join, :) == ["α111.4", "β∘125.6"]
342+
@test byrow(ds, join, :, delim = ",") == ["α1,1,1.4", "β∘1,2,5.6"]
343+
@test byrow(ds, join, :, delim = ":×:") == ["α1:×:1:×:1.4", "β∘1:×:2:×:5.6"]
338344
end
339345

340346
@testset "cum*/! - sort/!" begin

0 commit comments

Comments
 (0)