Пример #1
0
def test_sparsealleles_copyspan():
    a = SparseAlleles(np.array([1,1,1,1,1,1,1], dtype=np.int), refcode=1)
    b = SparseAlleles(np.array([2,2,2,2,2,2,2], dtype=np.int), refcode=1)

    a.copy_span(b, 2, 6)
    assert all(a.todense() == np.array([1,1,2,2,2,2,1]))

    c = SparseAlleles(np.array([1,1,1,1,1,1,1], dtype=np.int), refcode=1)
    a.copy_span(c, 2, 6)
    assert all(a.todense() == np.array([1,1,1,1,1,1,1]))
Пример #2
0
def test_sparsealleles_copyspan():
    a = SparseAlleles(np.array([1, 1, 1, 1, 1, 1, 1], dtype=np.int), refcode=1)
    b = SparseAlleles(np.array([2, 2, 2, 2, 2, 2, 2], dtype=np.int), refcode=1)

    a.copy_span(b, 2, 6)
    assert all(a.todense() == np.array([1, 1, 2, 2, 2, 2, 1]))

    c = SparseAlleles(np.array([1, 1, 1, 1, 1, 1, 1], dtype=np.int), refcode=1)
    a.copy_span(c, 2, 6)
    assert all(a.todense() == np.array([1, 1, 1, 1, 1, 1, 1]))
Пример #3
0
def test_sparsealleles():
    a = SparseAlleles([1,2,3,-1], refcode=1)
    b = SparseAlleles([1,3,2,-1], refcode=1)

    assert a.nmark() == b.nmark() == 4
    assert (a.missing == np.array([False, False, False, True])).all()
    assert (a.missing == b.missing).all()

    # Test todense
    assert (a.todense() == [1, 2, 3, -1]).all()
    assert isinstance(a.todense(), Alleles)

    a = SparseAlleles([0,0,1, 0,-1, 1], refcode=0)
    a[0] = a.missingcode
    assert list(a.missing) == [True, False, False, False, True, False] 
Пример #4
0
def test_sparsealleles():
    a = SparseAlleles([1, 2, 3, -1], refcode=1)
    b = SparseAlleles([1, 3, 2, -1], refcode=1)

    assert a.nmark() == b.nmark() == 4
    assert (a.missing == np.array([False, False, False, True])).all()
    assert (a.missing == b.missing).all()

    # Test todense
    assert (a.todense() == [1, 2, 3, -1]).all()
    assert isinstance(a.todense(), Alleles)

    a = SparseAlleles([0, 0, 1, 0, -1, 1], refcode=0)
    a[0] = a.missingcode
    assert list(a.missing) == [True, False, False, False, True, False]