Skip to content

Commit 421dc5e

Browse files
committed
Guard ArrayValue numpy tests on devdeps
1 parent f05d9a0 commit 421dc5e

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

test/JlWrap.jl

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -314,36 +314,41 @@ end
314314
@test pyjlvalue(y) == [1 2; 3 4]
315315
end
316316
@testset "__array__" begin
317-
np = pyimport("numpy")
317+
devdeps = PythonCall.C.CTX.which == :CondaPkg
318+
if devdeps
319+
np = pyimport("numpy")
318320

319-
numeric = pyjl(Float64[1, 2, 3])
320-
numeric_array = numeric.__array__()
321-
@test pyisinstance(numeric_array, np.ndarray)
322-
@test pyconvert(Vector{Float64}, numeric_array) == [1.0, 2.0, 3.0]
321+
numeric = pyjl(Float64[1, 2, 3])
322+
numeric_array = numeric.__array__()
323+
@test pyisinstance(numeric_array, np.ndarray)
324+
@test pyconvert(Vector{Float64}, numeric_array) == [1.0, 2.0, 3.0]
323325

324-
numeric_no_copy = numeric.__array__(copy=false)
325-
numeric_data = pyjlvalue(numeric)
326-
numeric_data[1] = 42.0
327-
@test pyconvert(Vector{Float64}, numeric_no_copy) == [42.0, 2.0, 3.0]
326+
numeric_no_copy = numeric.__array__(copy=false)
327+
numeric_data = pyjlvalue(numeric)
328+
numeric_data[1] = 42.0
329+
@test pyconvert(Vector{Float64}, numeric_no_copy) == [42.0, 2.0, 3.0]
328330

329-
string_array = pyjl(["a", "b"])
330-
string_result = string_array.__array__()
331-
@test pyisinstance(string_result, np.ndarray)
332-
@test pyconvert(Vector{String}, pybuiltins.list(string_result)) == ["a", "b"]
331+
string_array = pyjl(["a", "b"])
332+
string_result = string_array.__array__()
333+
@test pyisinstance(string_result, np.ndarray)
334+
@test pyconvert(Vector{String}, pybuiltins.list(string_result)) == ["a", "b"]
333335

334-
err = try
335-
string_array.__array__(copy=false)
336-
nothing
337-
catch err
338-
err
336+
err = try
337+
string_array.__array__(copy=false)
338+
nothing
339+
catch err
340+
err
341+
end
342+
@test err !== nothing
343+
@test err isa PythonCall.PyException
344+
@test pyis(err._t, pybuiltins.ValueError)
345+
@test occursin(
346+
"copy=False is not supported when collecting ArrayValue data",
347+
sprint(showerror, err),
348+
)
349+
else
350+
@test_skip devdeps
339351
end
340-
@test err !== nothing
341-
@test err isa PythonCall.PyException
342-
@test pyis(err._t, pybuiltins.ValueError)
343-
@test occursin(
344-
"copy=False is not supported when collecting ArrayValue data",
345-
sprint(showerror, err),
346-
)
347352
end
348353
@testset "array_interface" begin
349354
x = pyjl(Float32[1 2 3; 4 5 6]).__array_interface__

0 commit comments

Comments
 (0)