Skip to content

Commit 18ae8aa

Browse files
committed
parametrized test_write_dx()
1 parent 84368d4 commit 18ae8aa

1 file changed

Lines changed: 17 additions & 38 deletions

File tree

gridData/tests/test_dx.py

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@ def test_read_dx():
2222
assert_equal(g.origin, np.array([20.1, 3., -10.]))
2323

2424

25-
def _test_write_dx(tmpdir, counts=100, ndim=3, nptype="float32", dxtype="float"):
25+
@pytest.mark.parametrize("nptype,dxtype", [
26+
("float16", "float"),
27+
("float32", "float"),
28+
("float64", "double"),
29+
("int64", "int"),
30+
("int32", "int"),
31+
("uint32", "unsigned int"),
32+
("uint64", "unsigned int"),
33+
("int16", "short"),
34+
("uint16", "unsigned short"),
35+
("int8", "signed byte"),
36+
("uint8", "byte"),
37+
])
38+
def test_write_dx(tmpdir, nptype, dxtype, counts=100, ndim=3):
39+
# conversion from numpy array to DX file
40+
2641
h, edges = np.histogramdd(np.random.random((counts, ndim)), bins=10)
2742
g = Grid(h, edges)
2843

@@ -51,42 +66,6 @@ def _test_write_dx(tmpdir, counts=100, ndim=3, nptype="float32", dxtype="float")
5166

5267
assert_equal(out_dxtype, dxtype)
5368

54-
55-
# conversion from numpy array to DX file
56-
57-
def test_write_dx_float_float16(tmpdir, nptype="float16", dxtype="float"):
58-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
59-
60-
def test_write_dx_float_float32(tmpdir, nptype="float32", dxtype="float"):
61-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
62-
63-
def test_write_dx_double_float64(tmpdir, nptype="float64", dxtype="double"):
64-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
65-
66-
def test_write_dx_int_int64(tmpdir, nptype="int64", dxtype="int"):
67-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
68-
69-
def test_write_dx_int_int32(tmpdir, nptype="int32", dxtype="int"):
70-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
71-
72-
def test_write_dx_unsigned_int_uint32(tmpdir, nptype="uint32", dxtype="unsigned int"):
73-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
74-
75-
def test_write_dx_unsigned_int_uint64(tmpdir, nptype="uint64", dxtype="unsigned int"):
76-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
77-
78-
def test_write_dx_short_int16(tmpdir, nptype="int16", dxtype="short"):
79-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
80-
81-
def test_write_dx_unsigned_short_uint16(tmpdir, nptype="uint16", dxtype="unsigned short"):
82-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
83-
84-
def test_write_dx_signed_byte(tmpdir, nptype="int8", dxtype="signed byte"):
85-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
86-
87-
def test_write_dx_byte(tmpdir, nptype="uint8", dxtype="byte"):
88-
return _test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
89-
9069
def test_write_dx_ValueError(tmpdir, nptype="longdouble", dxtype="unknown"):
9170
with pytest.raises(ValueError):
92-
_test_write_dx(tmpdir, nptype=nptype, dxtype=dxtype)
71+
test_write_dx(tmpdir, nptype, dxtype)

0 commit comments

Comments
 (0)