Skip to content

Commit

Permalink
ndarray: implement endof (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin authored and pluskid committed Dec 2, 2017
1 parent 09ee1f4 commit 8a19651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ end

Base.first(x::NDArray) = _first(x)

Base.endof(x::NDArray) = length(x)

"""
slice(arr :: NDArray, start:stop)
Expand Down
8 changes: 8 additions & 0 deletions test/unittest/ndarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ function test_first()
end
end # function test_first

function test_endof()
info("NDArray::endof")
let A = [1 2; 3 4; 5 6], x = mx.NDArray(A)
@test endof(A) == endof(x)
end
end # function test_endof

function test_plus()
dims = rand_dims()
t1, a1 = rand_tensors(dims)
Expand Down Expand Up @@ -789,6 +796,7 @@ end # function test_size()
test_slice()
test_linear_idx()
test_first()
test_endof()
test_plus()
test_minus()
test_mul()
Expand Down

0 comments on commit 8a19651

Please sign in to comment.