Skip to content

Commit fd7bccd

Browse files
committed
expand tests to cover dtypes
1 parent e8b3e5a commit fd7bccd

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/test_datasets.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919

2020
@pytest.mark.parametrize("store", stores.keys())
21-
def test_helpers(tmpdir, store):
21+
@pytest.mark.parametrize("dtype", [np.float32, np.uint8, np.uint64])
22+
def test_helpers(tmpdir, store, dtype):
2223
store = tmpdir / store
2324
metadata = MetaDataFormat().parse(
2425
{
@@ -41,7 +42,7 @@ def test_helpers(tmpdir, store):
4142
metadata.units,
4243
shape,
4344
chunk_shape,
44-
dtype=np.float32,
45+
dtype=dtype,
4546
mode="r",
4647
)
4748

@@ -54,7 +55,7 @@ def test_helpers(tmpdir, store):
5455
metadata.units,
5556
shape,
5657
chunk_shape,
57-
dtype=np.float32,
58+
dtype=dtype,
5859
mode="w",
5960
)
6061
assert array.roi == Roi(
@@ -74,7 +75,7 @@ def test_helpers(tmpdir, store):
7475
metadata.units,
7576
shape,
7677
chunk_shape,
77-
dtype=np.float32,
78+
dtype=dtype,
7879
mode="r",
7980
)
8081
assert array.roi == Roi(
@@ -96,7 +97,7 @@ def test_helpers(tmpdir, store):
9697
metadata.units,
9798
chunk_shape,
9899
chunk_shape,
99-
dtype=np.float32,
100+
dtype=dtype,
100101
mode="r",
101102
)
102103

@@ -109,7 +110,7 @@ def test_helpers(tmpdir, store):
109110
metadata.units,
110111
chunk_shape,
111112
chunk_shape,
112-
dtype=np.float32,
113+
dtype=dtype,
113114
mode="w",
114115
)
115116
assert array.roi == Roi(
@@ -129,7 +130,7 @@ def test_helpers(tmpdir, store):
129130
metadata.units,
130131
chunk_shape,
131132
chunk_shape,
132-
dtype=np.float32,
133+
dtype=dtype,
133134
mode="r+",
134135
)
135136
assert array.roi == Roi(
@@ -149,7 +150,7 @@ def test_helpers(tmpdir, store):
149150
metadata.units,
150151
chunk_shape,
151152
chunk_shape,
152-
dtype=np.float32,
153+
dtype=dtype,
153154
mode="a",
154155
)
155156
assert array.roi == Roi(
@@ -162,7 +163,7 @@ def test_helpers(tmpdir, store):
162163

163164
# test prepare_ds with mode "w" overwrites existing array even if compatible
164165
array[:] = 2
165-
assert np.all(np.isclose(array[:], np.ones(chunk_shape) * 2))
166+
assert np.all(np.isclose(array[:], 2))
166167
array = prepare_ds(
167168
store,
168169
metadata.offset,
@@ -171,10 +172,10 @@ def test_helpers(tmpdir, store):
171172
metadata.units,
172173
chunk_shape,
173174
chunk_shape,
174-
dtype=np.float32,
175+
dtype=dtype,
175176
mode="w",
176177
)
177-
assert np.all(np.isclose(array[:], np.ones(chunk_shape) * 0))
178+
assert np.all(np.isclose(array[:], 0))
178179
assert array.roi == Roi(
179180
metadata.offset, metadata.voxel_size * Coordinate(*chunk_shape[-3:])
180181
)

0 commit comments

Comments
 (0)