def test_xpehh():
    n_variants = 1000
    n_haplotypes = 20
    h1 = np.random.randint(0, 2, size=(n_variants, n_haplotypes),
                           dtype='i1')
    h2 = np.random.randint(0, 2, size=(n_variants, n_haplotypes),
                           dtype='i1')
    pos = np.arange(0, n_variants * 10, 10)

    for use_threads in True, False:
        for min_ehh in 0, 0.05, 0.5:
            for include_edges in True, False:
                score = xpehh(h1, h2, pos, min_ehh=min_ehh,
                              include_edges=include_edges,
                              use_threads=use_threads)
                assert_is_instance(score, np.ndarray)
                eq((n_variants,), score.shape)
                eq(np.dtype('f8'), score.dtype)

    with assert_raises(ValueError):
        xpehh(h1, h2[1:], pos)

    with assert_raises(ValueError):
        xpehh(h1[1:], h2, pos)

    with assert_raises(ValueError):
        xpehh(h1, h2, pos[1:])

    with assert_raises(ValueError):
        xpehh(h1, h2, pos, map_pos=pos[1:])
def test_xpehh_data():
    pos = np.arange(1, hap1.shape[0] + 1)
    expect = -np.log(5.5/1.5)

    for use_threads in True, False:
        for include_edges in True, False:
            score = xpehh(hap1, hap2, pos, include_edges=include_edges,
                          use_threads=use_threads)
            actual = score[9]
            eq(expect, actual)