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

Fixes for 0.6 #235

Merged
merged 14 commits into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dataarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ end
#'
#' dv = @data [1, 2, NA, 4]
#' v = dropna(dv)
dropna(dv::DataVector) = copy(dv.data[!dv.na]) # -> Vector
dropna(dv::DataVector) = dv.data[.!dv.na] # -> Vector

#' @description
#'
Expand Down
2 changes: 1 addition & 1 deletion src/pooleddataarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ end
function PooledDataArray{T,R<:Integer,N}(d::AbstractArray{T, N},
m::AbstractArray{Bool, N},
r::Type{R} = DEFAULT_POOLED_REF_TYPE)
pool = convert(Array, unique(d[!m]))
pool = convert(Array, unique(d[.!m]))
if method_exists(isless, (T, T))
sort!(pool)
end
Expand Down
2 changes: 0 additions & 2 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ rb = 1:5
@test broadcast!(+, DataArray(Int, 2, 2), [1, 0], [1 4]) == [2 5; 1 4]
@test broadcast!(+, DataArray(Int, 2), [1, 0], [1, 4]) == [2, 4]
@test broadcast!(+, DataArray(Int, 2), [1, 0], 2) == [3, 2]
# @test broadcast!(abs, @data([-1, -2])) == @data([1, 2])
for arr in (identity, as_dataarray, as_pda, as_dataarray_bigfloat, as_pda_bigfloat)
@test broadcast(+, arr(eye(2)), arr([1, 4])) == [2 1; 4 5]
@test broadcast(+, arr(eye(2)), arr([1 4])) == [2 4; 1 5]
Expand Down Expand Up @@ -123,7 +122,6 @@ rt = Base.return_types(broadcast!, (typeof(+), DataArray{Float64, 3}, Array{Floa
@test isequal(broadcast(|, @data([NA, false]), @data([NA true false])), @data([NA true NA; NA true false]))

# Test map!
# @test_throws DimensionMismatch map!(+, DataArray(Float64, 2, 2), @data([1 2]), @data([1 2]))
@test map!(+, DataArray(Float64, 2), @data([1, 2]), @data([1, 2])) == @data([2, 4])
x = @data([-1, -2])
@test map!(abs, x, x) == @data([1, 2])
Expand Down
42 changes: 21 additions & 21 deletions test/datamatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ module TestDataMatrix
b[1, 1] = NA
res = a * b[1:1, :]
@assert all(isna(res[:, 1]))
@assert all(!isna(res[:, 2]))
@assert all(!isna(res[:, 3]))
@assert all(.!(isna(res[:, 2])))
@assert all(.!(isna(res[:, 3])))
res = a * b[2:2, :]
@assert all(!isna(res))
@assert all(.!(isna(res)))

#
# DataMatrix w NA's * DataVector
#

res = b * a
@assert isna(res[1])
@assert !isna(res[2])
@assert !isna(res[3])
@assert .!(isna(res[2]))
@assert .!(isna(res[3]))

#
# DataMatrix * DataMatrix
Expand All @@ -71,11 +71,11 @@ module TestDataMatrix
@assert isna(res[1, 2])
@assert isna(res[1, 3])
@assert isna(res[2, 1])
@assert !isna(res[2, 2])
@assert !isna(res[2, 3])
@assert .!(isna(res[2, 2]))
@assert .!(isna(res[2, 3]))
@assert isna(res[3, 1])
@assert !isna(res[3, 2])
@assert !isna(res[3, 3])
@assert .!(isna(res[3, 2]))
@assert .!(isna(res[3, 3]))

res = b * @data eye(3)
# 3x3 Float64 DataMatrix:
Expand All @@ -85,12 +85,12 @@ module TestDataMatrix
@assert isna(res[1, 1])
@assert isna(res[1, 2])
@assert isna(res[1, 3])
@assert !isna(res[2, 1])
@assert !isna(res[2, 2])
@assert !isna(res[2, 3])
@assert !isna(res[3, 1])
@assert !isna(res[3, 2])
@assert !isna(res[3, 3])
@assert .!(isna(res[2, 1]))
@assert .!(isna(res[2, 2]))
@assert .!(isna(res[2, 3]))
@assert .!(isna(res[3, 1]))
@assert .!(isna(res[3, 2]))
@assert .!(isna(res[3, 3]))

res = (@data eye(3)) * b
# julia> dataeye(3) * b
Expand All @@ -99,14 +99,14 @@ module TestDataMatrix
# NA 1.0 0.0
# NA 0.0 1.0
@assert isna(res[1, 1])
@assert !isna(res[1, 2])
@assert !isna(res[1, 3])
@assert .!(isna(res[1, 2]))
@assert .!(isna(res[1, 3]))
@assert isna(res[2, 1])
@assert !isna(res[2, 2])
@assert !isna(res[2, 3])
@assert .!(isna(res[2, 2]))
@assert .!(isna(res[2, 3]))
@assert isna(res[3, 1])
@assert !isna(res[3, 2])
@assert !isna(res[3, 3])
@assert .!(isna(res[3, 2]))
@assert .!(isna(res[3, 3]))

# Test row operations
dm = @data eye(6, 2)
Expand Down
6 changes: 3 additions & 3 deletions test/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ da2 = DataArray(randn(128))
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(da1.data, weights(da2.data))

da1[1:3:end] = NA
@same_behavior mean(da1, weights(da2); skipna=true) mean(dropna(da1), weights(da2.data[!da1.na]))
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(dropna(da1), weights(da2.data[!da1.na]))
@same_behavior mean(da1, weights(da2); skipna=true) mean(dropna(da1), weights(da2.data[(!).(da1.na)]))
@same_behavior mean(da1, weights(da2.data); skipna=true) mean(dropna(da1), weights(da2.data[(!).(da1.na)]))

da2[1:2:end] = NA
keep = !da1.na .& !da2.na
keep = .!da1.na .& .!da2.na
@test isna(mean(da1, weights(da2)))
@same_behavior mean(da1, weights(da2); skipna=true) mean(da1.data[keep], weights(da2.data[keep]))
end
2 changes: 1 addition & 1 deletion test/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ macro test_da_approx_eq(da1, da2)
v2 = $(esc(da2))
na = isna(v1)
@test na == isna(v2)
defined = !na
defined = (!).(na)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.!na should work here as you've written it elsewhere, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Apparently, this form is required in macros. I tried the other version first.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's... bizarre. Maybe file a Base issue?

if any(defined)
@test isapprox(v1[defined], v2[defined], nans = true)
end
Expand Down
2 changes: 1 addition & 1 deletion test/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ for T in (Float64, BigFloat)
nna = sum(na)
a = Vector{T}(n)
ra = randn(n-nna)
a[!na] = ra
a[.!na] = ra
for da in (DataArray(a, na), PooledDataArray(a, na), (pda = PooledDataArray(a, na); setlevels!(pda, shuffle!(pda.pool))))
@test isequal(sort(da), [DataArray(sort(dropna(da))); DataArray(T, nna)])
@test isequal(sort(da; lt=(x,y)->isless(x,y)), [DataArray(sort(dropna(da))); DataArray(T, nna)])
Expand Down