Exemplo n.º 1
0
 def test_plot_defaults(self, new_axis_mock):
     ax = unittest.mock.Mock(spec=["plot"])
     new_axis_mock.return_value = ax
     nodes = np.asfortranarray([[0.0, 1.0], [1.0, 3.0]])
     curve = self._make_one(nodes, 1, copy=False)
     num_pts = 2  # This value is crucial for the plot call.
     result = curve.plot(num_pts)
     self.assertIs(result, ax)
     # Verify mocks.
     new_axis_mock.assert_called_once_with()
     # Check the call to ax.plot(). We can't assert_any_call()
     # since == breaks on NumPy arrays.
     self.assertEqual(ax.plot.call_count, 1)
     call = ax.plot.mock_calls[0]
     utils.check_plot_call(self, call, nodes, color=None, alpha=None)
Exemplo n.º 2
0
 def test_plot_explicit(self, new_axis_mock):
     nodes = np.asfortranarray([[0.0, 1.0], [0.0, 1.0]])
     curve = self._make_one(nodes, 1, copy=False)
     num_pts = 2  # This value is crucial for the plot call.
     ax = unittest.mock.Mock(spec=["plot"])
     color = (0.75, 1.0, 1.0)
     alpha = 0.625
     result = curve.plot(num_pts, color=color, alpha=alpha, ax=ax)
     self.assertIs(result, ax)
     # Verify mocks.
     new_axis_mock.assert_not_called()
     # Check the call to ax.plot(). We can't assert_any_call()
     # since == breaks on NumPy arrays.
     self.assertEqual(ax.plot.call_count, 1)
     call = ax.plot.mock_calls[0]
     utils.check_plot_call(self, call, nodes, color=color, alpha=alpha)
Exemplo n.º 3
0
 def test_plot_explicit(self, add_patch_mock, new_axis_mock):
     ax = unittest.mock.Mock(spec=["plot"])
     color = (0.5, 0.5, 0.5)
     curve = self._make_one(self.UNIT_TRIANGLE, 1, copy=False)
     pts_per_edge = 16
     result = curve.plot(pts_per_edge, color=color, ax=ax, with_nodes=True)
     self.assertIs(result, ax)
     # Verify mocks.
     new_axis_mock.assert_not_called()
     add_patch_mock.assert_called_once_with(ax, color, pts_per_edge,
                                            *curve._edges)
     # Check the call to ax.plot(). We can't assert_any_call()
     # since == breaks on NumPy arrays.
     self.assertEqual(ax.plot.call_count, 1)
     call = ax.plot.mock_calls[0]
     utils.check_plot_call(
         self,
         call,
         self.UNIT_TRIANGLE,
         color="black",
         marker="o",
         linestyle="None",
     )
Exemplo n.º 4
0
 def _plot_check(self, ax, expected, color):
     self.assertEqual(ax.plot.call_count, 1)
     call = ax.plot.mock_calls[0]
     utils.check_plot_call(self, call, expected, color=color)