Skip to content

Commit

Permalink
add roundtrip serialization test for List[List[Dict[int, np.ndarray]]]
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolmgreaves committed Mar 9, 2022
1 parent 5fe5007 commit ac4379e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_custom_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,24 @@ def check(*, actual, expected):

_roundtrip(mnt, custom_serialize, custom_deserialize, check)
_roundtrip(mdc, custom_serialize, custom_deserialize, check)


def test_nested_array_dict_int_keys(custom_serialize, custom_deserialize):
N = 4
M = 3

def check(*, actual, expected):
assert isinstance(actual, type(expected))
assert len(actual) == N
for xs in actual:
assert len(xs) == M
for i, arr in xs.items():
assert isinstance(i, int)
_check_array_like(actual=arr, expected=np.ones(i))

m: List[List[Dict[int, np.ndarray]]] = [[
[{i:np.ones(i) for i in range(M)]
for _ in range(N)
]]

_roundtrip(m, custom_serialize, custom_deserialize, check)

0 comments on commit ac4379e

Please sign in to comment.