Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 3bff91c

Browse files
committed
Rename dropna() to dropnull() but keep it
1 parent 67f9aca commit 3bff91c

13 files changed

+47
-47
lines changed

src/DataArrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module DataArrays
2626
DataArray,
2727
DataMatrix,
2828
DataVector,
29+
dropnull,
2930
EachFailNull,
3031
EachDropNull,
3132
EachReplaceNull,

src/abstractdataarray.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ true
4949
Base.isnull(a::AbstractArray{T}, i::Real) where {T} = Null <: T ? isa(a[i], Null) : false # -> Bool
5050

5151
"""
52-
dropna(v::AbstractVector) -> AbstractVector
52+
dropnull(v::AbstractVector) -> AbstractVector
5353
5454
Return a copy of `v` with all `null` elements removed.
5555
5656
# Examples
5757
5858
```jldoctest
59-
julia> dropna(@data [null, 1, null, 2])
59+
julia> dropnull(@data [null, 1, null, 2])
6060
2-element Array{Int64,1}:
6161
1
6262
2
6363
64-
julia> dropna([4, 5, 6])
64+
julia> dropnull([4, 5, 6])
6565
3-element Array{Int64,1}:
6666
4
6767
5
6868
6
6969
```
7070
"""
71-
dropna(v::AbstractVector) = copy(v) # -> AbstractVector
71+
dropnull(v::AbstractVector) = copy(v) # -> AbstractVector
7272

7373
# Iterators
7474
# TODO: Use values()

src/dataarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ function Base.convert{T, N}(::Type{Array}, da::DataArray{T, N}, replacement::Any
242242
return convert(Array{T, N}, da, replacement)
243243
end
244244

245-
dropna(dv::DataVector) = dv.data[.!dv.na] # -> Vector
245+
dropnull(dv::DataVector) = dv.data[.!dv.na] # -> Vector
246246

247247
Base.any(::typeof(isnull), da::DataArray) = any(da.na) # -> Bool
248248
Base.all(::typeof(isnull), da::DataArray) = all(da.na) # -> Bool

src/deprecated.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ end
7777
@deprecate_binding NAtype Null
7878
@deprecate_binding NA null
7979
@deprecate isna isnull
80-
@deprecate dropna(x) collect(Nulls.drop(x))
80+
@deprecate dropna dropnull
8181
@deprecate padna padnull
8282
@deprecate each_failna Nulls.fail
8383
@deprecate each_dropna Nulls.skip
@@ -89,4 +89,3 @@ import SpecialFunctions: digamma, erf, erfc
8989
@deprecate digamma(x::Null) isnull(x) ? null : SpecialFunctions.digamma(x)
9090
@deprecate erf(x::Null) isnull(x) ? null : SpecialFunctions.erf(x)
9191
@deprecate erfc(x::Null) isnull(x) ? null : SpecialFunctions.erfc(x)
92-

src/pooleddataarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ function PooledDataArray(x::PooledDataArray{S,R,N},
372372
end
373373

374374
myunique(x::AbstractVector) = unique(x)
375-
myunique(x::AbstractDataVector) = unique(dropna(x))
375+
myunique(x::AbstractDataVector) = unique(dropnull(x))
376376

377377
"""
378378
setlevels(x::PooledDataArray, newpool::Union{AbstractVector, Dict})
@@ -915,7 +915,7 @@ function Base.convert{T, R, N}(::Type{Array}, pda::PooledDataArray{T, R, N}, rep
915915
return convert(Array{T, N}, pda, replacement)
916916
end
917917

918-
function dropna(pdv::PooledDataVector{T}) where T
918+
function dropnull(pdv::PooledDataVector{T}) where T
919919
n = length(pdv)
920920
res = Array{T}(n)
921921
total = 0

src/statistics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ StatsBase.describe(X::DataVector) = StatsBase.describe(STDOUT, X)
4141
function StatsBase.describe(io::IO, X::AbstractDataVector{T}) where T<:Real
4242
nacount = sum(isnull, X)
4343
pna = 100nacount/length(X)
44-
if pna != 100 # describe will fail if dropna returns an empty vector
45-
describe(io, dropna(X))
44+
if pna != 100 # describe will fail if dropnull returns an empty vector
45+
describe(io, dropnull(X))
4646
else
4747
println(io, "Summary Stats:")
4848
println(io, "Type: $(T)")

test/data.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
# @test isequal(pdvstr .== "two", PooledDataVector[false, false, true, true, null, false, false])
8888

8989
#test_group("DataVector to something else")
90-
@test all(dropna(dvint) .== [1, 2, 4])
90+
@test all(dropnull(dvint) .== [1, 2, 4])
9191
@test all(convert(Vector, dvint, 0) .== [1, 2, 0, 4])
9292
@test all(convert(Vector, dvany, 0) .== [1, 2, 0, 4])
9393
utf8three = convert(String, "three")
@@ -102,19 +102,19 @@
102102
"Union{Nulls.Null, $Int}[1, 2, null, 4]")
103103

104104
#test_group("PooledDataVector to something else")
105-
@test all(dropna(pdvstr) .== ["one", "one", "two", "two", "one", "one"])
105+
@test all(dropnull(pdvstr) .== ["one", "one", "two", "two", "one", "one"])
106106
@test all(convert(Vector, pdvstr, "nine") .== ["one", "one", "two", "two", "nine", "one", "one"])
107107
#@test all([length(i)::Int for i in pdvstr] .== [3, 3, 3, 3, 1, 3, 3])
108108
@test string(pdvstr[1:3]) == "[one, one, two]"
109109

110110
#test_group("DataVector Filter and Replace")
111-
@test isequal(dropna(dvint), [1, 2, 4])
111+
@test isequal(dropnull(dvint), [1, 2, 4])
112112
@test isequal(convert(Vector, dvint, 7), [1, 2, 7, 4])
113-
@test sum(dropna(dvint)) == 7
113+
@test sum(dropnull(dvint)) == 7
114114
@test sum(convert(Vector, dvint, 7)) == 14
115115

116116
#test_group("PooledDataVector Filter and Replace")
117-
@test reduce(string, "", dropna(pdvstr)) == "oneonetwotwooneone"
117+
@test reduce(string, "", dropnull(pdvstr)) == "oneonetwotwooneone"
118118
@test reduce(string, "", convert(Vector, pdvstr, "!")) == "oneonetwotwo!oneone"
119119

120120
#test_group("DataVector assignment")

test/dataarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
x = @data [1, null, -2, 1, null, 4]
4545
@test isequal(unique(x), @data [1, null, -2, 4])
4646
@test isequal(unique(reverse(x)), @data [4, null, 1, -2])
47-
@test isequal(unique(dropna(x)), @data [1, -2, 4])
48-
@test isequal(unique(reverse(dropna(x))), @data [4, 1, -2])
47+
@test isequal(unique(dropnull(x)), @data [1, -2, 4])
48+
@test isequal(unique(reverse(dropnull(x))), @data [4, 1, -2])
4949
@test isequal(levels(x), @data [1, -2, 4])
5050
@test isequal(levels(reverse(x)), @data [4, 1, -2])
5151

test/nas.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
end
5252

5353
dv = DataArray(collect(1:6), fill(false, 6))
54-
a = dropna(dv)
54+
a = dropnull(dv)
5555
@test collect(Nulls.fail(dv)) == a
5656
@test collect(Nulls.skip(dv)) == a
5757
@test collect(Nulls.replace(dv, 4)) == a
@@ -67,7 +67,7 @@
6767
end
6868
end
6969

70-
a = dropna(dv)
70+
a = dropnull(dv)
7171
@test_throws NullException for v in Nulls.fail(dv); end
7272
@test collect(Nulls.skip(dv)) == a
7373
@test collect(Nulls.replace(dv, 4)) == [4, 4, a..., 4]

test/newtests/dataarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ module TestDataArrays
119119
convert(Vector, DataArray([1, 0, 3], [false, true, false]), -1)
120120
convert(Vector, DataArray([1, 2, 3], [false, false, false]), -1)
121121

122-
# dropna(da::DataArray)
123-
dropna(DataArray([1, 0, 3], [false, true, false]))
124-
dropna(DataArray([1, 2, 3], [false, false, false]))
125-
# dropna{T}(da::AbstractDataVector{T})
126-
# dropna(@data([1, null, 3]))
122+
# dropnull(da::DataArray)
123+
dropnull(DataArray([1, 0, 3], [false, true, false]))
124+
dropnull(DataArray([1, 2, 3], [false, false, false]))
125+
# dropnull{T}(da::AbstractDataVector{T})
126+
# dropnull(@data([1, null, 3]))
127127

128128
# Iterators
129129

test/pooleddataarray.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
pcopy = copy(p)
44
@test levels(p) == [1, 8, 9]
55
@test levels(setlevels(p, ["a", "b", "c"])) == ["a", "b", "c"]
6-
@test dropna(setlevels(p, (@data ["a", "b", null]))) == ["b", "a", "a"]
7-
@test dropna(setlevels(p, (@data ["a", "b", "a"]))) == ["a", "a", "b", "a", "a"]
6+
@test dropnull(setlevels(p, (@data ["a", "b", null]))) == ["b", "a", "a"]
7+
@test dropnull(setlevels(p, (@data ["a", "b", "a"]))) == ["a", "a", "b", "a", "a"]
88
@test levels(setlevels(p, (@data ["a", "b", "a"]))) == ["a", "b"]
99
@test levels(setlevels(p, Dict([(1, 111)]))) == [111, 8, 9]
1010
@test levels(setlevels(p, Dict([(1, 111), (8, null)]))) == [111, 9]
1111
@test levels(PooledDataArray(p, [9, 8, 1])) == [9, 8, 1]
1212
@test levels(PooledDataArray(p, [9, 8])) == [9, 8]
13-
@test dropna(PooledDataArray(p, [9, 8])) == [9, 9, 8]
13+
@test dropnull(PooledDataArray(p, [9, 8])) == [9, 9, 8]
1414
@test levels(PooledDataArray(p, levels(p)[[3,2,1]])) == [9,8,1]
1515
v = collect(1:6)
1616
@test isequal(p, reorder(p))
@@ -29,14 +29,14 @@
2929
y = @pdata [1, null, -2, 1, null, 4, null]
3030
@test isequal(unique(y), @pdata [1, null, -2, 4])
3131
@test isequal(unique(reverse(y)), @data [null, 4, 1, -2])
32-
@test isequal(unique(dropna(y)), @data [1, -2, 4])
33-
@test isequal(unique(reverse(dropna(y))), @data [4, 1, -2])
32+
@test isequal(unique(dropnull(y)), @data [1, -2, 4])
33+
@test isequal(unique(reverse(dropnull(y))), @data [4, 1, -2])
3434

3535
z = @pdata ["frank", null, "gertrude", "frank", null, "herbert", null]
3636
@test isequal(unique(z), @pdata ["frank", null, "gertrude", "herbert"])
3737
@test isequal(unique(reverse(z)), @pdata [null, "herbert", "frank", "gertrude"])
38-
@test isequal(unique(dropna(z)), @pdata ["frank", "gertrude", "herbert"])
39-
@test isequal(unique(reverse(dropna(z))), @pdata ["herbert", "frank", "gertrude"])
38+
@test isequal(unique(dropnull(z)), @pdata ["frank", "gertrude", "herbert"])
39+
@test isequal(unique(reverse(dropnull(z))), @pdata ["herbert", "frank", "gertrude"])
4040

4141
# check case where only null occurs in final position
4242
@test isequal(unique(@pdata [1, 2, 1, null]), @pdata [1, 2, null])

test/reduce.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ end
6060
da2 = copy(da)
6161
da2[1:2:end] = null
6262
@test isnull(sum(da2))
63-
@test sum(da2; skipna=true) sum(dropna(da2))
63+
@test sum(da2; skipna=true) sum(dropnull(da2))
6464

6565
da2 = convert(DataArray{BigFloat}, da2)
6666
@test isnull(sum(da2))
67-
@test sum(da2; skipna=true) sum(dropna(da2))
67+
@test sum(da2; skipna=true) sum(dropnull(da2))
6868

6969
da2 = copy(da)
7070
da2[2:2:end] = null
7171
@test isnull(sum(da2))
72-
@test sum(da2; skipna=true) sum(dropna(da2))
72+
@test sum(da2; skipna=true) sum(dropnull(da2))
7373

7474
da2 = convert(DataArray{BigFloat}, da2)
7575
@test isnull(sum(da2))
76-
@test sum(da2; skipna=true) sum(dropna(da2))
76+
@test sum(da2; skipna=true) sum(dropnull(da2))
7777
end
7878

7979
## other reductions
@@ -96,20 +96,20 @@ end
9696
da2 = copy(da)
9797
da2[1:2:end] = null
9898
n > 0 && @test isnull(fn(da2))
99-
@same_behavior fn(da2; skipna=true) fn(dropna(da2))
99+
@same_behavior fn(da2; skipna=true) fn(dropnull(da2))
100100

101101
da2 = convert(DataArray{BigFloat}, da2)
102102
n > 0 && @test isnull(fn(da2))
103-
@same_behavior fn(da2; skipna=true) fn(dropna(da2))
103+
@same_behavior fn(da2; skipna=true) fn(dropnull(da2))
104104

105105
da2 = copy(da)
106106
da2[2:2:end] = null
107107
n > 1 && @test isnull(fn(da2))
108-
@same_behavior fn(da2; skipna=true) fn(dropna(da2))
108+
@same_behavior fn(da2; skipna=true) fn(dropnull(da2))
109109

110110
da2 = convert(DataArray{BigFloat}, da2)
111111
n > 1 && @test isnull(fn(da2))
112-
@same_behavior fn(da2; skipna=true) fn(dropna(da2))
112+
@same_behavior fn(da2; skipna=true) fn(dropnull(da2))
113113
end
114114
end
115115

@@ -140,8 +140,8 @@ end
140140
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(da1.data, weights(da2.data))
141141

142142
da1[1:3:end] = null
143-
@same_behavior mean(da1, weights(da2); skipna=true) mean(dropna(da1), weights(da2.data[(!).(da1.na)]))
144-
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(dropna(da1), weights(da2.data[(!).(da1.na)]))
143+
@same_behavior mean(da1, weights(da2); skipna=true) mean(dropnull(da1), weights(da2.data[(!).(da1.na)]))
144+
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(dropnull(da1), weights(da2.data[(!).(da1.na)]))
145145

146146
da2[1:2:end] = null
147147
keep = .!da1.na .& .!da2.na

test/sort.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
ra = randn(n-nna)
1818
a[.!na] = ra
1919
for da in (DataArray(a, na), PooledDataArray(a, na), (pda = PooledDataArray(a, na); setlevels!(pda, shuffle!(pda.pool))))
20-
@test isequal(sort(da), [DataArray(sort(dropna(da))); DataArray(T, nna)])
21-
@test isequal(sort(da; lt=(x,y)->isless(x,y)), [DataArray(sort(dropna(da))); DataArray(T, nna)])
22-
@test isequal(da[sortperm(da)], [DataArray(sort(dropna(da))); DataArray(T, nna)])
23-
@test isequal(sort(da, rev=true), [DataArray(T, nna); DataArray(sort(dropna(da), rev=true))])
24-
@test isequal(da[sortperm(da, rev=true)], [DataArray(T, nna); DataArray(sort(dropna(da), rev=true))])
20+
@test isequal(sort(da), [DataArray(sort(dropnull(da))); DataArray(T, nna)])
21+
@test isequal(sort(da; lt=(x,y)->isless(x,y)), [DataArray(sort(dropnull(da))); DataArray(T, nna)])
22+
@test isequal(da[sortperm(da)], [DataArray(sort(dropnull(da))); DataArray(T, nna)])
23+
@test isequal(sort(da, rev=true), [DataArray(T, nna); DataArray(sort(dropnull(da), rev=true))])
24+
@test isequal(da[sortperm(da, rev=true)], [DataArray(T, nna); DataArray(sort(dropnull(da), rev=true))])
2525
end
2626
end
2727
end

0 commit comments

Comments
 (0)