def test_axis_limit_set_updates_ticks(): axis = Axis(display_length=80) axis.limits = (0, 300) np.testing.assert_array_equal(axis.ticks, np.array([0, 50, 100, 150, 200, 250, 300])) axis.limits = (50, 80) np.testing.assert_array_equal(axis.ticks, np.array([50, 55, 60, 65, 70, 75, 80]))
def test_axis_ticks(limits, n_ticks, expected_ticks): """Test axis ticks generation""" axis = Axis(display_length=80) axis.limits = limits axis.nticks = n_ticks np.testing.assert_array_equal(axis.ticks, expected_ticks)
def test_axis_transform(x, expected_display_x): """Test axis transform from plot to display coordinates""" axis = Axis(display_length=80) axis.limits = (0, 100) display_x = axis.fit_transform(x) np.testing.assert_array_equal(display_x, expected_display_x)
def test_axis_display_ticks(limits, ticks, expected_tick_labels): """Test axis ticks generation""" axis = Axis(display_length=80) axis.limits = limits axis.ticks = ticks tick_labels = list(axis.generate_display_ticks()) assert tick_labels == expected_tick_labels
def test_axis_ticks_set_updates_ticklabels(): axis = Axis() axis.limits = (0, 1) axis.ticks = (0.0, 0.3, 1.0) np.testing.assert_array_equal(axis.ticklabels, np.array([0.0, 0.3, 1.0])) axis.ticks = (0.0, 0.2) np.testing.assert_array_equal(axis.ticklabels, np.array([0.0, 0.2]))
def test_axis_nticks_set_updates_ticks(): axis = Axis() axis.limits = (0, 1) axis.nticks = 2 np.testing.assert_array_equal(axis.ticks, np.array([0.0, 1.0])) axis.nticks = 3 np.testing.assert_array_equal(axis.ticks, np.array([0.0, 0.5, 1.0])) axis.nticks = 5 np.testing.assert_array_equal(axis.ticks, np.array([0.0, 0.25, 0.5, 0.75, 1.0]))