Skip to content

Commit 7ad1707

Browse files
committed
Update spade
1 parent 0635369 commit 7ad1707

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/data_morph/shapes/points/spade.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class Spade(PointCollection):
3030
"""
3131

3232
def __init__(self, dataset: Dataset) -> None:
33-
_, xmax = dataset.data_bounds.x_bounds
34-
x_shift, y_shift = dataset.data_bounds.center
33+
data_bounds = dataset.data_bounds
34+
(_, xmax) = data_bounds.x_bounds
35+
x_shift, y_shift = data_bounds.center
3536

3637
# upside-down heart
3738
heart_points = self._get_inverted_heart(dataset, y_shift)
@@ -43,7 +44,7 @@ def __init__(self, dataset: Dataset) -> None:
4344
x = np.concatenate((heart_points[:, 0], base_x), axis=0)
4445
y = np.concatenate((heart_points[:, 1], base_y), axis=0)
4546

46-
super().__init__(*np.stack([x, y], axis=1))
47+
super().__init__(*self._center(np.stack([x, y], axis=1), data_bounds))
4748

4849
@staticmethod
4950
def _get_inverted_heart(dataset: Dataset, y_shift: Number) -> np.ndarray:

tests/shapes/points/test_spade.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ class TestSpade(PointsModuleTestBase):
1212

1313
shape_name = 'spade'
1414
distance_test_cases = (
15-
((19.97189615, 75.43271708), 0),
16-
((23.75, 55), 0),
17-
((11.42685318, 59.11304904), 0),
18-
((20, 75), 0.2037185),
19-
((0, 0), 57.350348),
20-
((10, 80), 10.968080),
15+
((19.818701, 60.065370), 0),
16+
((23.750000, 55.532859), 0),
17+
((20.067229, 60.463689), 0),
18+
((18.935968, 58.467606), 0),
19+
((20, 75), 0.5335993101603015),
20+
((0, 0), 57.861566654807596),
21+
((10, 80), 11.404000978114487),
2122
)

0 commit comments

Comments
 (0)