From 6a232bc4a5e4c732a126371e0b18e31bdbfadac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Tue, 11 Dec 2018 09:52:12 +0100 Subject: [PATCH] add deleteat! (#176) --- src/array.jl | 2 ++ test/13_arraycommon.jl | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/array.jl b/src/array.jl index d6c3e5e5..89582140 100644 --- a/src/array.jl +++ b/src/array.jl @@ -790,3 +790,5 @@ end refs(A::CategoricalArray) = A.refs pool(A::CategoricalArray) = A.pool + +Base.deleteat!(A::CategoricalArray, inds) = (deleteat!(A.refs, inds); A) diff --git a/test/13_arraycommon.jl b/test/13_arraycommon.jl index 2f0422f9..a937012e 100644 --- a/test/13_arraycommon.jl +++ b/test/13_arraycommon.jl @@ -1094,4 +1094,13 @@ end end end +@testset "deleteat!" begin + x = ['a':'z';] + y = categorical(x) + deleteat!(x, [1, 3]) + deleteat!(y, [1, 3]) + @test x == y + @test levels(y) == 'a':'z' +end + end