Skip to content

Commit 9512b9d

Browse files
nalimilanbkamins
andauthored
Fix levels on Julia 1.7 (#32)
* Fix levels on Julia 1.7 `unique` now returns a range for range inputs, so we cannot update it in place. * Update src/DataAPI.jl Co-authored-by: Bogumił Kamiński <[email protected]> Co-authored-by: Bogumił Kamiński <[email protected]>
1 parent 0bf553d commit 9512b9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/DataAPI.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ actually occur in the data, and does not preserve their order of appearance in `
9292
"""
9393
function levels(x)
9494
T = Base.nonmissingtype(eltype(x))
95-
levs = convert(AbstractArray{T}, filter!(!ismissing, unique(x)))
95+
u = unique(x)
96+
# unique returns its input with copying for ranges
97+
# (and possibly for other types guaranteed to hold unique values)
98+
nmu = (u === x || Base.mightalias(u, x)) ? filter(!ismissing, u) : filter!(!ismissing, u)
99+
levs = convert(AbstractArray{T}, nmu)
96100
try
97101
sort!(levs)
98102
catch

0 commit comments

Comments
 (0)