Coverage for tests/unit/generation/test_bool_array_from_string.py: 100%
15 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-24 00:33 -0600
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-24 00:33 -0600
1import numpy as np
2import pytest
3from numpy.testing import assert_array_equal
5from maze_dataset.utils import bool_array_from_string
8def test_bool_array_from_string():
9 connection_list = bool_array_from_string(
10 """
11 TTF TFF TFF
12 TFT FFT FFF
13 """,
14 shape=[2, 3, 3],
15 )
17 expected = np.array(
18 [
19 [[True, True, False], [True, False, False], [True, False, False]],
20 [[True, False, True], [False, False, True], [False, False, False]],
21 ],
22 )
24 assert_array_equal(expected, connection_list)
27def test_bool_array_from_string_wrong_shape():
28 with pytest.raises(ValueError): # noqa: PT011
29 bool_array_from_string("TF TF TF F", shape=[2, 2, 2])
32def test_bool_array_from_string_custom_symbol():
33 actual = bool_array_from_string(
34 """
35 x x x
36 x _ x
37 x x x
38 """,
39 shape=[3, 3],
40 true_symbol="_",
41 )
43 expected = [[False, False, False], [False, True, False], [False, False, False]]
45 assert_array_equal(expected, actual)