This repository has been archived by the owner on May 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
nas.jl
75 lines (65 loc) · 3.03 KB
/
nas.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@testset "missings" begin
@testset "any(ismissing, x)" begin
# any(ismissing, a::AbstractArray)
@test any(ismissing, Any[missing, 1])
@test !any(ismissing, [1, 2])
@test !any(ismissing, repeat([1, 2], outer = [1, 2]))
@test !any(ismissing, repeat([1, 2], outer = [1, 2, 2]))
# any(ismissing, da::DataArray)
@test !any(ismissing, DataArray([1, 2], falses(2)))
@test !any(ismissing, DataArray(repeat([1, 2], outer = [1, 2]), falses(2, 2)))
da = DataArray(repeat([1, 2], outer = [1, 2, 2]), falses(2, 2, 2))
@test !any(ismissing, da)
da[2] = missing
@test any(ismissing, da)
# any(ismissing, pda::PooledDataArray)
@test !any(ismissing, PooledDataArray([1, 2], falses(2)))
@test !any(ismissing, PooledDataArray(repeat([1, 2], outer = [1, 2]), falses(2, 2)))
pda = PooledDataArray(repeat([1, 2], outer = [1, 2, 2]), falses(2, 2, 2))
@test !any(ismissing, pda)
pda[2] = missing
@test any(ismissing, pda)
end
@testset "all(ismissing, x)" begin
# all(ismissing, a::AbstractArray)
@test all(ismissing, Any[missing, missing])
@test !all(ismissing, Any[missing, 1])
@test !all(ismissing, [1, 2])
@test !all(ismissing, repeat([1, 2], outer = [1, 2]))
@test !all(ismissing, repeat([1, 2], outer = [1, 2, 2]))
# all(ismissing, da::DataArray)
@test !all(ismissing, DataArray([1, 2], falses(2)))
@test !all(ismissing, DataArray(repeat([1, 2], outer = [1, 2]), falses(2, 2)))
da = DataArray(repeat([1, 2], outer = [1, 2, 2]), falses(2, 2, 2))
da[1] = missing
@test !all(ismissing, da)
da[:] = missing
@test all(ismissing, da)
# all(ismissing, da::PooledDataArray)
@test !all(ismissing, PooledDataArray([1, 2], falses(2)))
@test !all(ismissing, PooledDataArray(repeat([1, 2], outer = [1, 2]), falses(2, 2)))
pda = PooledDataArray(repeat([1, 2], outer = [1, 2, 2]), falses(2, 2, 2))
pda[1] = missing
@test !all(ismissing, pda)
pda[:] = missing
@test all(ismissing, pda)
end
dv = DataArray(collect(1:6), fill(false, 6))
a = dv[.!ismissing.(dv)]
@test collect(Missings.fail(dv)) == a
@test collect(skipmissing(dv)) == a
@test collect(Missings.replace(dv, 4)) == a
dv[[1, 2, end]] = missing
@testset "promotion" for (T1, T2) in ((Int, Float64),
(Dates.Minute, Dates.Second))
@eval begin
@test promote_type($T1, Union{$T2, Missing}) == Union{$T2, Missing}
@test promote_type(Union{$T1, Missing}, $T2) == Union{$T2, Missing}
@test promote_type(Union{$T1, Missing}, Union{$T2, Missing}) == Union{$T2, Missing}
end
end
a = dv[.!ismissing.(dv)]
@test_throws MissingException for v in Missings.fail(dv); end
@test collect(skipmissing(dv)) == a
@test collect(Missings.replace(dv, 4)) == [4, 4, a..., 4]
end