Skip to content

Commit

Permalink
Using transpose of polygon nodes in add_patch() helper.
Browse files Browse the repository at this point in the history
This means that the `0.7.0` release has broken `Surface.plot()`
and `CurvedPolygon.plot()` so a bugfix release should be done soon.
  • Loading branch information
dhermes committed Feb 13, 2018
1 parent d8ebe56 commit 80bfaaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/bezier/_plot_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def add_patch(ax, color, pts_per_edge, *edges):
# Reset ``color`` in case it was ``None`` and set from color wheel.
color = line.get_color()

path = _path_mod.Path(polygon)
# ``polygon`` is stored Fortran-contiguous with ``x-y`` points in each
# column but ``Path()`` wants ``x-y`` points in each row.
path = _path_mod.Path(polygon.T)
patch = patches.PathPatch(
path, facecolor=color, alpha=0.625)
ax.add_patch(patch)
10 changes: 5 additions & 5 deletions tests/unit/test__plot_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ def _call_function_under_test(ax, color, pts_per_edge, *edges):

return _plot_helpers.add_patch(ax, color, pts_per_edge, *edges)

def _path_val(self, path, expected):
def _path_val(self, path, expected_transpose):
self.assertEqual(path.Path.call_count, 1)
call = path.Path.mock_calls[0]
_, positional, keyword = call
self.assertEqual(keyword, {})
self.assertEqual(len(positional), 1)
self.assertEqual(positional[0], expected)
self.assertEqual(positional[0].T, expected_transpose)

def _plot_check(self, ax, expected, color):
self.assertEqual(ax.plot.call_count, 1)
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_it(self):
[0.0, 1.0, 2.0],
[1.0, 3.0, 6.0],
])
expected, edges = self._get_info(nodes)
expected_transpose, edges = self._get_info(nodes)

# Set-up mocks (quite a lot).
patches = unittest.mock.Mock(spec=['PathPatch'])
Expand All @@ -167,10 +167,10 @@ def test_it(self):
self.assertIsNone(result)

# Verify mocks (quite a lot).
self._path_val(path, expected)
self._path_val(path, expected_transpose)
patches.PathPatch.assert_called_once_with(
path.Path.return_value, facecolor=color, alpha=0.625)
ax.add_patch.assert_called_once_with(
patches.PathPatch.return_value)
line.get_color.assert_called_once_with()
self._plot_check(ax, expected, color)
self._plot_check(ax, expected_transpose, color)

0 comments on commit 80bfaaa

Please sign in to comment.