Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

Commit 27e3c13

Browse files
committed
fix: is_jax_available added for tests
Signed-off-by: agaraman0 <agaraman0@gmail.com>
1 parent 420ec42 commit 27e3c13

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

tests/units/array/stack/test_array_stacked_jax.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Optional, Union
22

3-
import jax.numpy as jnp
43
import pytest
54

65
from docarray import BaseDoc, DocList
@@ -14,6 +13,11 @@
1413
NdArray,
1514
VideoTensor,
1615
)
16+
from docarray.utils._internal.misc import is_jax_available
17+
18+
jax_available = is_jax_available()
19+
if jax_available:
20+
import jax.numpy as jnp
1721

1822

1923
@pytest.fixture()

tests/units/computation_backends/jax_backend/test_basics.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from docarray.computation.jax_backend import JaxCompBackend
1111
from docarray.typing import JaxArray
12-
jax.config.update("jax_enable_x64", True)
12+
13+
jax.config.update("jax_enable_x64", True)
1314

1415

1516
@pytest.mark.parametrize(
@@ -26,7 +27,6 @@ def test_n_dim(shape, result):
2627
assert JaxCompBackend.n_dim(array) == result
2728

2829

29-
@pytest.mark.tensorflow
3030
@pytest.mark.parametrize(
3131
'shape,result',
3232
[
@@ -42,14 +42,12 @@ def test_shape(shape, result):
4242
assert type(shape) == tuple
4343

4444

45-
@pytest.mark.tensorflow
4645
def test_to_device():
4746
array = JaxArray(jnp.zeros((3)))
4847
array = JaxCompBackend.to_device(array, 'cpu')
4948
assert array.tensor.device().platform.endswith('cpu')
5049

5150

52-
@pytest.mark.tensorflow
5351
@pytest.mark.parametrize(
5452
'dtype,result_type',
5553
[
@@ -64,34 +62,29 @@ def test_dtype(dtype, result_type):
6462
assert JaxCompBackend.dtype(array) == result_type
6563

6664

67-
@pytest.mark.tensorflow
6865
def test_empty():
6966
array = JaxCompBackend.empty((10, 3))
7067
assert array.tensor.shape == (10, 3)
7168

7269

73-
@pytest.mark.tensorflow
7470
def test_empty_dtype():
7571
tf_tensor = JaxCompBackend.empty((10, 3), dtype=jnp.int32)
7672
assert tf_tensor.tensor.shape == (10, 3)
7773
assert tf_tensor.tensor.dtype == jnp.int32
7874

7975

80-
@pytest.mark.tensorflow
8176
def test_empty_device():
8277
tensor = JaxCompBackend.empty((10, 3), device='cpu')
8378
assert tensor.tensor.shape == (10, 3)
8479
assert tensor.tensor.device().platform.endswith('cpu')
8580

8681

87-
@pytest.mark.tensorflow
8882
def test_squeeze():
8983
tensor = JaxArray(jnp.zeros(shape=(1, 1, 3, 1)))
9084
squeezed = JaxCompBackend.squeeze(tensor)
9185
assert squeezed.tensor.shape == (3,)
9286

9387

94-
@pytest.mark.tensorflow
9588
@pytest.mark.parametrize(
9689
'data_input,t_range,x_range,data_result',
9790
[
@@ -123,14 +116,12 @@ def test_minmax_normalize(data_input, t_range, x_range, data_result):
123116
assert jnp.allclose(output.tensor, jnp.array(data_result))
124117

125118

126-
@pytest.mark.tensorflow
127119
def test_reshape():
128120
tensor = JaxArray(jnp.zeros((3, 224, 224)))
129121
reshaped = JaxCompBackend.reshape(tensor, (224, 224, 3))
130122
assert reshaped.tensor.shape == (224, 224, 3)
131123

132124

133-
@pytest.mark.tensorflow
134125
def test_stack():
135126
t0 = JaxArray(jnp.zeros((3, 224, 224)))
136127
t1 = JaxArray(jnp.ones((3, 224, 224)))

0 commit comments

Comments
 (0)