Skip to content

Commit 8b5b3f1

Browse files
committed
Some buffer coverage
1 parent 76f7560 commit 8b5b3f1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/zarr/core/buffer/gpu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Buffer(core.Buffer):
5252

5353
def __init__(self, array_like: ArrayLike) -> None:
5454
if cp is None:
55-
raise ImportError(
55+
raise ImportError( # pragma: no cover
5656
"Cannot use zarr.buffer.gpu.Buffer without cupy. Please install cupy."
5757
)
5858

@@ -141,7 +141,7 @@ class NDBuffer(core.NDBuffer):
141141

142142
def __init__(self, array: NDArrayLike) -> None:
143143
if cp is None:
144-
raise ImportError(
144+
raise ImportError( # pragma: no cover
145145
"Cannot use zarr.buffer.gpu.NDBuffer without cupy. Please install cupy."
146146
)
147147

tests/test_buffer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ def test_numpy_buffer_prototype() -> None:
186186
ndbuffer.as_scalar()
187187

188188

189+
@gpu_test
190+
def test_gpu_buffer_raises() -> None:
191+
import cupy as cp
192+
193+
arr = cp.empty((10, 10), dtype="B")
194+
with pytest.raises(ValueError, match="array_like: only 1-dim allowed"):
195+
gpu.Buffer(arr)
196+
197+
arr = cp.arange(12, dtype="int32")
198+
with pytest.raises(ValueError, match="array_like: only byte dtype allowed"):
199+
gpu.Buffer(arr)
200+
201+
189202
@gpu_test
190203
def test_gpu_buffer_prototype() -> None:
191204
buffer = gpu.buffer_prototype.buffer.create_zero_length()

0 commit comments

Comments
 (0)