Skip to content

Commit ef70d95

Browse files
author
Shashi Gowda
committed
define equality with other arrays
1 parent 8f7f2b1 commit ef70d95

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Diff for: src/array/darray.jl

+8
Original file line numberDiff line numberDiff line change
@@ -344,3 +344,11 @@ end
344344
function distribute(x::AbstractVector, n::Vector)
345345
distribute(x, DomainBlocks((1,), n))
346346
end
347+
348+
function Base.:(==){T,S,N}(x::ArrayOp{T,N}, y::AbstractArray{S,N})
349+
collect(x) == y
350+
end
351+
352+
function Base.:(==){T,S,N}(x::AbstractArray{T,N}, y::ArrayOp{S,N})
353+
return collect(x) == y
354+
end

Diff for: test/array.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ end
3131
@testset "distributing an array" begin
3232
function test_dist(X)
3333
X1 = Distribute(Blocks(10, 20), X)
34-
@test collect(X1) == X
34+
@test X1 == X
3535
Xc = compute(X1)
3636
@test chunks(Xc) |> size == (10, 5)
3737
@test domainchunks(Xc) |> size == (10, 5)
3838
@test map(x->size(x) == (10, 20), domainchunks(Xc)) |> all
3939
end
4040
x = [1 2; 3 4]
41-
@test collect(Distribute(Blocks(1,1), x)) == x
41+
@test Distribute(Blocks(1,1), x) == x
4242
#test_dist(rand(100, 100))
4343
#test_dist(sprand(100, 100, 0.1))
4444
end
@@ -47,7 +47,7 @@ end
4747
function test_transpose(X)
4848
x, y = size(X)
4949
X1 = Distribute(Blocks(10, 20), X)
50-
@test collect(X1') == X'
50+
@test X1' == X'
5151
Xc = compute(X1')
5252
@test chunks(Xc) |> size == (div(y, 20), div(x,10))
5353
@test domainchunks(Xc) |> size == (div(y, 20), div(x, 10))

0 commit comments

Comments
 (0)