Skip to content

Commit 67156a5

Browse files
committed
Add additional json test
1 parent a72b1ef commit 67156a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stanio/json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
uj_version = tuple(map(int, json.__version__.split(".")))
88
if uj_version < (5, 5, 0):
9-
raise ImportError("ujson version too old")
9+
raise ImportError("ujson version too old") # pragma: no cover
1010
UJSON_AVAILABLE = True
1111
except:
1212
UJSON_AVAILABLE = False

test/test_json.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,21 @@ def test_tuples(TMPDIR) -> None:
167167
"b": [(1, [2, 3]), (4, [5, 6])],
168168
"c": ((1, np.array([1, 2.0, 3])), (3, np.array([1, 2, 3]))),
169169
"m": {"1": 1, "2": [2, 3]},
170+
"np": np.array([(1, 2, 3)], dtype="i,i,i"),
170171
}
171172
dict_tuple_exp = {
172173
"a": {"1": 1, "2": 2, "3": 3},
173174
"b": [{"1": 1, "2": [2, 3]}, {"1": 4, "2": [5, 6]}],
174175
"c": {"1": {"1": 1, "2": [1, 2.0, 3]}, "2": {"1": 3, "2": [1, 2, 3]}},
175176
"m": {"1": 1, "2": [2, 3]},
177+
"np": [{"1": 1, "2": 2, "3": 3}],
176178
}
177179
file_tuple = os.path.join(TMPDIR, "tuple.json")
178180
write_stan_json(file_tuple, dict_tuples)
179181
compare_before_after(file_tuple, dict_tuples, dict_tuple_exp)
180182

181183

182-
def test_write_vs_dump(TMPDIR):
184+
def test_write_vs_dump(TMPDIR) -> None:
183185
dict_list = {"a": [1.0, 2.0, 3.0]}
184186
file_write = os.path.join(TMPDIR, "write.json")
185187
write_stan_json(file_write, dict_list)

0 commit comments

Comments
 (0)