Skip to content

Commit f7be0d6

Browse files
gselzerctrueden
authored andcommitted
Differentiate jep conversion from jpype conversion
Jep doesn't bring in Numpy right away, like JPype does. Thus, this conversion will output a Python list, not a Numpy array.
1 parent c6d6fe2 commit f7be0d6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/test_convert.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from os import getcwd
33
from pathlib import Path
44

5+
import numpy as np
56
import pytest
67

78
from scyjava import (
@@ -187,9 +188,16 @@ def testPrimitiveIntArray(self):
187188
for i in range(len(arr)):
188189
arr[i] = i # NB: assign Python int into Java int!
189190
py_arr = to_python(arr)
190-
assert type(py_arr).__name__ == "ndarray"
191+
if mode == Mode.JEP:
192+
assert type(py_arr).__name__ == "list"
193+
# JPype brings in a Numpy dependency from the start.
194+
# This dependency enables the Numpy converters
195+
# Since they take precedence, we'll actually see a ndarray
196+
# output from the conversion.
197+
elif mode == Mode.JPYPE:
198+
assert type(py_arr).__name__ == "ndarray"
191199
# NB: Comparing ndarray vs list results in a list of bools.
192-
assert all(py_arr == [0, 1, 2, 3])
200+
assert np.array_equal(py_arr, [0, 1, 2, 3])
193201

194202
def test2DStringArray(self):
195203
String = jimport("java.lang.String")

0 commit comments

Comments
 (0)