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]
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]
def test_sparsealleles_emptylike(): a = SparseAlleles([1,2,3,4]) e = a.empty_like() assert ((not e.container.any()) and (e.refcode == a.refcode) and (a.nmark() == e.nmark()))
def test_sparsealleles_emptylike(): a = SparseAlleles([1, 2, 3, 4]) e = a.empty_like() assert ((not e.container.any()) and (e.refcode == a.refcode) and (a.nmark() == e.nmark()))