示例#1
0
def test_minor_breaks():
    # equidistant breaks
    major = [1, 2, 3, 4]
    limits = [0, 5]
    breaks = minor_breaks()(major, limits)
    npt.assert_array_equal(breaks, [.5, 1.5, 2.5, 3.5, 4.5])
    minor = minor_breaks(3)(major, [2, 3])
    npt.assert_array_equal(minor, [2.25, 2.5, 2.75])

    # More than 1 minor breaks
    breaks = minor_breaks()(major, limits, 3)
    npt.assert_array_equal(breaks, [.25, .5, .75,
                                    1.25, 1.5, 1.75,
                                    2.25, 2.5, 2.75,
                                    3.25, 3.5, 3.75,
                                    4.25, 4.5, 4.75])

    # non-equidistant breaks
    major = [1, 2, 4, 8]
    limits = [0, 10]
    minor = minor_breaks()(major, limits)
    npt.assert_array_equal(minor, [1.5, 3, 6])

    # single major break
    minor = minor_breaks()([2], limits)
    assert len(minor) == 0
示例#2
0
def test_minor_breaks():
    # equidistant breaks
    major = [1, 2, 3, 4]
    limits = [0, 5]
    breaks = minor_breaks()(major, limits)
    npt.assert_array_equal(breaks, [.5, 1.5, 2.5, 3.5, 4.5])
    minor = minor_breaks(3)(major, [2, 3])
    npt.assert_array_equal(minor, [2.25, 2.5, 2.75])

    # More than 1 minor breaks
    breaks = minor_breaks()(major, limits, 3)
    npt.assert_array_equal(breaks, [
        .25, .5, .75, 1.25, 1.5, 1.75, 2.25, 2.5, 2.75, 3.25, 3.5, 3.75, 4.25,
        4.5, 4.75
    ])

    # non-equidistant breaks
    major = [1, 2, 4, 8]
    limits = [0, 10]
    minor = minor_breaks()(major, limits)
    npt.assert_array_equal(minor, [1.5, 3, 6])

    # single major break
    minor = minor_breaks()([2], limits)
    assert len(minor) == 0
def test_pseudo_log_trans():
    p = np.arange(-4, 4)
    pos = [10**int(x) for x in p]
    arr = np.hstack([-np.array(pos[::-1]), pos])
    _test_trans(pseudo_log_trans, arr)
    _test_trans(pseudo_log_trans(base=16), arr)
    _test_trans(pseudo_log_trans(base=10, minor_breaks=minor_breaks(n=5)), arr)
def test_logn_trans():
    log3_trans = log_trans(3)
    _test_trans(log3_trans, arr)

    log4_trans = log_trans(4, domain=(0.1, 100),
                           breaks=mpl_breaks(),
                           minor_breaks=minor_breaks())
    _test_trans(log4_trans, arr)