Skip to content

Commit

Permalink
Add assertions to ensure flipping works
Browse files Browse the repository at this point in the history
  • Loading branch information
nvictus committed Feb 4, 2021
1 parent 9850bd4 commit d181fe5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_create_sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,15 @@ def test_sanitize_pixels():
sanitize_pixels(
bins,
)(chunk.copy())

# one-based bin IDs
out = sanitize_pixels(
bins,
is_one_based=True,
)(chunk.copy())
assert (out['bin1_id'] == chunk['bin1_id'] - 1).all()

# tril action
# tril action: reflect (after swapping bin1, bin2)
tril_chunk = chunk.copy()
tril_chunk['bin2_id'] = chunk['bin1_id']
tril_chunk['bin1_id'] = chunk['bin2_id']
Expand All @@ -240,11 +242,17 @@ def test_sanitize_pixels():
assert len(out) == len(chunk)
assert (out['foo2'] == chunk['foo1']).all()
assert (out['foo1'] == chunk['foo2']).all()
assert (out['bin1_id'] == chunk['bin1_id']).all()
assert (out['bin2_id'] == chunk['bin2_id']).all()

# tril action: drop
out = sanitize_pixels(
bins,
tril_action="drop",
)(tril_chunk.copy())
assert len(out) == 0

# tril action: raise
with pytest.raises(BadInputError):
sanitize_pixels(
bins,
Expand Down

0 comments on commit d181fe5

Please sign in to comment.