Skip to content

Commit

Permalink
define equality with other arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashi Gowda committed Aug 2, 2017
1 parent 8f7f2b1 commit ef70d95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/array/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,11 @@ end
function distribute(x::AbstractVector, n::Vector)
distribute(x, DomainBlocks((1,), n))
end

function Base.:(==){T,S,N}(x::ArrayOp{T,N}, y::AbstractArray{S,N})
collect(x) == y
end

function Base.:(==){T,S,N}(x::AbstractArray{T,N}, y::ArrayOp{S,N})
return collect(x) == y
end
6 changes: 3 additions & 3 deletions test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ end
@testset "distributing an array" begin
function test_dist(X)
X1 = Distribute(Blocks(10, 20), X)
@test collect(X1) == X
@test X1 == X
Xc = compute(X1)
@test chunks(Xc) |> size == (10, 5)
@test domainchunks(Xc) |> size == (10, 5)
@test map(x->size(x) == (10, 20), domainchunks(Xc)) |> all
end
x = [1 2; 3 4]
@test collect(Distribute(Blocks(1,1), x)) == x
@test Distribute(Blocks(1,1), x) == x
#test_dist(rand(100, 100))
#test_dist(sprand(100, 100, 0.1))
end
Expand All @@ -47,7 +47,7 @@ end
function test_transpose(X)
x, y = size(X)
X1 = Distribute(Blocks(10, 20), X)
@test collect(X1') == X'
@test X1' == X'
Xc = compute(X1')
@test chunks(Xc) |> size == (div(y, 20), div(x,10))
@test domainchunks(Xc) |> size == (div(y, 20), div(x, 10))
Expand Down

0 comments on commit ef70d95

Please sign in to comment.