Coverage for tests/unit/generation/test_neighbors.py: 100%
26 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
3from maze_dataset.generation.generators import get_neighbors_in_bounds
6def test_middle_point():
7 coord = np.array([2, 2])
8 grid_shape = np.array([5, 5])
9 expected_neighbors = np.array([[2, 3], [2, 1], [3, 2], [1, 2]])
10 neighbors = get_neighbors_in_bounds(coord, grid_shape)
11 assert np.array_equal(neighbors, expected_neighbors), (
12 f"{neighbors} != {expected_neighbors}"
13 )
16def test_corner_point():
17 coord = np.array([0, 0])
18 grid_shape = np.array([5, 5])
19 expected_neighbors = np.array([[0, 1], [1, 0]])
20 neighbors = get_neighbors_in_bounds(coord, grid_shape)
21 assert np.array_equal(neighbors, expected_neighbors), (
22 f"{neighbors} != {expected_neighbors}"
23 )
26def test_edge_point():
27 coord = np.array([0, 2])
28 grid_shape = np.array([5, 5])
29 expected_neighbors = np.array([[0, 3], [0, 1], [1, 2]])
30 neighbors = get_neighbors_in_bounds(coord, grid_shape)
31 assert np.array_equal(neighbors, expected_neighbors), (
32 f"{neighbors} != {expected_neighbors}"
33 )
36def test_single_point_grid():
37 coord = np.array([0, 0])
38 grid_shape = np.array([1, 1])
39 expected_neighbors = np.empty((0, 2))
40 neighbors = get_neighbors_in_bounds(coord, grid_shape)
41 assert np.array_equal(neighbors, expected_neighbors), (
42 f"{neighbors} != {expected_neighbors}"
43 )