Skip to content

Commit 74402b0

Browse files
author
Christopher Doris
committed
unit tests for juliaarray
1 parent bedb3b2 commit 74402b0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/runtests.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,39 @@ end
912912
@test @pyv `~$xi == $(pyjl(-2))`::Bool
913913
end
914914

915+
@testset "juliaarray" begin
916+
js = fill(1)
917+
jv = [1,2,3]
918+
jm = [1 2; 3 4]
919+
xs = pyjl(js)
920+
xv = pyjl(jv)
921+
xm = pyjl(jm)
922+
@test @pyv `$xs[()] == 1`::Bool
923+
@test @pyv `$xv[0] == 1`::Bool
924+
@test @pyv `$xv[1] == 2`::Bool
925+
@test @pyv `$xv[-1] == 3`::Bool
926+
@test @pyv `$xv[-3] == 1`::Bool
927+
@test @pyv `$xm[0,0] == 1`::Bool
928+
@test @pyv `$xm[1,-1] == 4`::Bool
929+
@py `$xm[0,0] = 0`
930+
@test jm[1,1] == 0
931+
@py `del $xv[1]`::Bool
932+
@test jv == [1,3]
933+
@test @pyv `$xs.ndim == 0`::Bool
934+
@test @pyv `$xv.ndim == 1`::Bool
935+
@test @pyv `$xm.ndim == 2`::Bool
936+
@test @pyv `$xs.shape == ()`::Bool
937+
@test @pyv `$xv.shape == (2,)`::Bool
938+
@test @pyv `$xm.shape == (2,2)`::Bool
939+
xm2 = @pyv `$xm.copy()`
940+
@py `$xm2[0,0] = 99`
941+
@test @pyv `$xm[0,0] == 0`::Bool
942+
@test @pyv `$xm2[0,0] == 99`::Bool
943+
xmv = @pyv `$xm.reshape(4)`
944+
@test @pyv `$xmv.shape == (4,)`::Bool
945+
@test @pyv `list($xmv) == [0,3,2,4]`::Bool
946+
end
947+
915948
@testset "juliaio" begin
916949
for value in Any[stdin, stdout, IOBuffer()]
917950
@test @pyv `type($(pyjl(value))).__name__ == "BufferedIOValue"`::Bool

0 commit comments

Comments
 (0)