11import numpy as np
2- import pytest
32
43from scyjava import is_jarray , jarray , to_python
54from scyjava .config import Mode , mode
@@ -47,9 +46,6 @@ def assert_array_conversion_works(jarr, expected):
4746 assert_array_conversion_works (jints , deltas )
4847
4948 def test_jarray2d_to_python (self ):
50- if mode is Mode .JEP :
51- pytest .skip ("Jep doesn't support 2-d arrays" )
52-
5349 nums = [
5450 [1.2 , 3.4 , 5.6 ],
5551 [7.8 , 9.1 , 2.3 ],
@@ -69,7 +65,9 @@ def test_jarray2d_to_python(self):
6965 pdoubles = to_python (jdoubles )
7066
7167 if mode == Mode .JEP :
72- raise RuntimeError ("Not supported" )
68+ assert isinstance (pdoubles , list )
69+ assert all (isinstance (v , list ) for v in pdoubles )
70+ assert len (nums ) == len (pdoubles )
7371
7472 elif mode == Mode .JPYPE :
7573 assert isinstance (pdoubles , np .ndarray )
@@ -81,9 +79,6 @@ def test_jarray2d_to_python(self):
8179 assert nums [i ][j ] == pdoubles [i ][j ]
8280
8381 def test_jarray2d_to_python_updates (self ):
84- if mode is Mode .JEP :
85- pytest .skip ("Jep doesn't support 2-d arrays" )
86-
8782 nums_init = [
8883 [1.2 , 3.4 , 5.6 ],
8984 [7.8 , 9.1 , 2.3 ],
@@ -105,9 +100,15 @@ def test_jarray2d_to_python_updates(self):
105100
106101 # assert narr initial state
107102 pdoubles = to_python (jdoubles )
108- assert isinstance (pdoubles , np .ndarray )
109- assert np .float64 == pdoubles .dtype
110- assert (5 , 3 ) == pdoubles .shape
103+ if mode == Mode .JEP :
104+ assert isinstance (pdoubles , list )
105+ assert isinstance (pdoubles [0 ][0 ], float )
106+ assert len (pdoubles ) == 5
107+ assert len (pdoubles [0 ]) == 3
108+ elif mode == Mode .JPYPE :
109+ assert isinstance (pdoubles , np .ndarray )
110+ assert np .float64 == pdoubles .dtype
111+ assert (5 , 3 ) == pdoubles .shape
111112 for i in range (len (nums_init )):
112113 for j in range (len (nums_init [i ])):
113114 assert nums_init [i ][j ] == pdoubles [i ][j ]
@@ -119,9 +120,15 @@ def test_jarray2d_to_python_updates(self):
119120
120121 # assert narr delta state
121122 pdoubles = to_python (jdoubles )
122- assert isinstance (pdoubles , np .ndarray )
123- assert np .float64 == pdoubles .dtype
124- assert (5 , 3 ) == pdoubles .shape
123+ if mode == Mode .JEP :
124+ assert isinstance (pdoubles , list )
125+ assert isinstance (pdoubles [0 ][0 ], float )
126+ assert len (pdoubles ) == 5
127+ assert len (pdoubles [0 ]) == 3
128+ elif mode == Mode .JPYPE :
129+ assert isinstance (pdoubles , np .ndarray )
130+ assert np .float64 == pdoubles .dtype
131+ assert (5 , 3 ) == pdoubles .shape
125132 for i in range (len (nums_delta )):
126133 for j in range (len (nums_delta [i ])):
127134 assert nums_delta [i ][j ] == pdoubles [i ][j ]
0 commit comments