Skip to content
4 changes: 2 additions & 2 deletions hexy/hexy.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_spiral(center, radius_start=1, radius_end=2):
return np.array(hex_area)


def get_hex_line(hex_start, hex_end):
def get_hex_line(hex_start, hex_end): # TODO start and end seems to not be commutative, why ?
"""
Get hexes on line from hex_start to hex_end.
:param hex_start: The hex where the line starts.
Expand All @@ -124,7 +124,7 @@ def get_hex_line(hex_start, hex_end):
"""
hex_distance = get_cube_distance(hex_start, hex_end)
if hex_distance < 1:
return np.array([hex_start])
return np.array([hex_start.copy()])

# Set up linear system to compute linearly interpolated cube points
bottom_row = np.array([i / hex_distance for i in np.arange(hex_distance)])
Expand Down
Empty file added test/test_base_map.py
Empty file.
10 changes: 8 additions & 2 deletions test/test_hex_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ def test_get_hex_line():
start = np.array([-3, 3, 0])
end = np.array([1, 1, -2])
print(hx.get_hex_line(start, end))
print(expected);
print(expected)
assert(np.array_equal(
hx.get_hex_line(start, end),
expected));
expected))
# testing one hex line special case
one_hex_line = hx.get_hex_line(start, start)
assert len(one_hex_line) == 1
assert(np.array_equal(one_hex_line[0], start))
assert id(start) != id(one_hex_line)


if __name__ == "__main__":
test_get_hex_line()
8 changes: 4 additions & 4 deletions test/test_rounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ def test_cube_round():
test_coords = np.array([
[1.1, -1.4, 0.3],
[3.3, 2.3, -5.4],
]);
])

expected_coords = np.array([
[1, -1, 0],
[3, 2, -5],
]);
])

assert(np.array_equal(hx.cube_round(test_coords), expected_coords))

def test_axial_round():
test_coords = np.array([
[1.1, -1.4],
[3.3, 2.3],
]);
])

expected_coords = np.array([
[1, -1],
[3, 2],
]);
])

assert(np.array_equal(hx.axial_round(test_coords), expected_coords))
16 changes: 0 additions & 16 deletions test/test_selections.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ def test_get_spiral():
_assert_np_array_equal(actual_array, expected_array)


def test_get_spiral():
start_radius = 2
end_radius = 4
expected = []
for r in range(start_radius, end_radius + 1):
expected += _get_linear_combinations(hx.W, hx.NW, r) + \
_get_linear_combinations(hx.NW, hx.NE, r) + \
_get_linear_combinations(hx.NE, hx.E, r) + \
_get_linear_combinations(hx.E, hx.SE, r) + \
_get_linear_combinations(hx.SE, hx.SW, r) + \
_get_linear_combinations(hx.SW, hx.W, r)

actual_array = hx.get_spiral([0, 0, 0], start_radius, end_radius)
expected_array = np.array(expected)
_assert_np_array_equal(actual_array, expected_array)


def test_get_disk():
expected = [[0, 0, 0]]
Expand Down