Skip to content

Commit

Permalink
Refactor using numpy arrays as expected results
Browse files Browse the repository at this point in the history
  • Loading branch information
szhan committed Jun 15, 2023
1 parent 3a48611 commit cb56acf
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/test_compare_vcfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def test_both_biallelic_same_alleles_same_order():
ds1 = make_test_case()
ds2 = ds1.copy(deep=True)
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
expected = np.array([
[[0, 1], [1, 0]],
[[1, 0], [0, 1]],
]
])
assert np.array_equal(actual, expected)


Expand All @@ -85,10 +85,10 @@ def test_both_biallelic_same_alleles_different_order():
ds2.variant_allele[i] = xr.DataArray(np.flip(ds2.variant_allele[i]))
ds2.call_genotype[i] = xr.DataArray(np.where(ds2.call_genotype[i] == 0, 1, 0))
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
expected = np.array([
[[0, 1], [1, 0]],
[[1, 0], [0, 1]],
]
])
assert np.array_equal(actual, expected)


Expand All @@ -102,17 +102,17 @@ def test_biallelic_monoallelic():
ds2.call_genotype[i] = xr.DataArray(np.zeros_like(ds2.call_genotype[i]))
# Subtest 1
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
expected = np.array([
[[1, 1], [1, 1]],
[[2, 2], [2, 2]],
]
])
assert np.array_equal(actual, expected)
# Subtest 2
actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = [
expected = np.array([
[[1, 0], [0, 1]],
[[2, 1], [1, 2]],
]
])
assert np.array_equal(actual, expected)


Expand All @@ -127,17 +127,17 @@ def test_both_biallelic_different_alleles():
ds2.call_genotype[1] = xr.DataArray(data=[[0, 1], [1, 0]])
# Subtest 1
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
expected = np.array([
[[1, 2], [2, 1]],
[[2, 3], [3, 2]],
]
])
assert np.array_equal(actual, expected)
# Subtest 2
actual = compare_vcfs.remap_genotypes(ds2, ds1)
expected = [
expected = np.array([
[[2, 0], [0, 2]],
[[3, 2], [2, 3]],
]
])
assert np.array_equal(actual, expected)


Expand All @@ -156,10 +156,10 @@ def test_both_monoallelic():
ds2.variant_allele[1] = xr.DataArray([b'G', b''])
ds2.call_genotype[1] = xr.DataArray(data=np.zeros_like(ds2.call_genotype[1]))
actual = compare_vcfs.remap_genotypes(ds1, ds2)
expected = [
expected = np.array([
[[0, 0], [0, 0]],
[[1, 1], [1, 1]],
]
])
assert np.array_equal(actual, expected)


Expand Down

0 comments on commit cb56acf

Please sign in to comment.