Skip to content

Commit 976f286

Browse files
committed
Test tuple dtype conversion
1 parent 26752ec commit 976f286

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_decorators.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ def identity(arr):
141141
assert result.dtype == np.uint8
142142
assert result.shape == arr.shape
143143

144+
def test_numpy_decorator_tuple_dtype_conversion(self):
145+
"""Test tuple output dtype conversion applies to main output only."""
146+
from arraybridge.decorators import numpy
147+
148+
@numpy
149+
def to_float_with_meta(arr):
150+
return arr.astype(np.float32), {"meta": "ok"}
151+
152+
arr = np.array([0, 127, 255], dtype=np.uint8)
153+
result = to_float_with_meta(arr)
154+
155+
assert isinstance(result, tuple)
156+
assert result[0].dtype == np.uint8
157+
assert result[0].shape == arr.shape
158+
assert result[1]["meta"] == "ok"
159+
144160
def test_cupy_decorator_exists(self):
145161
"""Test that cupy decorator is available."""
146162
from arraybridge.decorators import cupy

0 commit comments

Comments
 (0)