コード例 #1
0
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]))
コード例 #2
0
def test_axis_ticklabels_len_error(ticks, labels):
    """Test error raising when tick labels do not match ticks"""
    axis = Axis()
    axis.ticks = ticks

    with pytest.raises(ValueError):
        axis.ticklabels = labels
コード例 #3
0
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