@@ -27,3 +27,45 @@ def test_direct_store_access(store, array_type):
27
27
# Notice, GDSStore always returns a cupy array
28
28
assert type (b ) is cupy .ndarray
29
29
cupy .testing .assert_array_equal (a , b )
30
+
31
+
32
+ def test_array (store ):
33
+ """Test Zarr array"""
34
+
35
+ pytest .importorskip (
36
+ "zarr.cupy" ,
37
+ reason = (
38
+ "To use Zarr arrays with GDS directly, Zarr needs CuPy support: "
39
+ "<https://github.com/zarr-developers/zarr-python/pull/934>"
40
+ ),
41
+ )
42
+
43
+ a = cupy .arange (100 )
44
+ z = zarr .array (
45
+ a , chunks = 10 , compressor = None , store = store , meta_array = cupy .empty (())
46
+ )
47
+ assert a .shape == z .shape
48
+ assert a .dtype == z .dtype
49
+ assert isinstance (a , type (z [:]))
50
+ cupy .testing .assert_array_equal (a , z [:])
51
+
52
+
53
+ def test_group (store ):
54
+ """Test Zarr group"""
55
+
56
+ pytest .importorskip (
57
+ "zarr.cupy" ,
58
+ reason = (
59
+ "To use Zarr arrays with GDS directly, Zarr needs CuPy support: "
60
+ "<https://github.com/zarr-developers/zarr-python/pull/934>"
61
+ ),
62
+ )
63
+
64
+ g = zarr .open_group (store , meta_array = cupy .empty (()))
65
+ g .ones ("data" , shape = (10 , 11 ), dtype = int , compressor = None )
66
+ a = g ["data" ]
67
+ assert a .shape == (10 , 11 )
68
+ assert a .dtype == int
69
+ assert isinstance (a , zarr .Array )
70
+ assert isinstance (a [:], cupy .ndarray )
71
+ assert (a [:] == 1 ).all ()
0 commit comments