Skip to content

Commit

Permalink
test added for is_sorted function
Browse files Browse the repository at this point in the history
  • Loading branch information
smitkadvani committed Jan 19, 2024
1 parent cf4c9da commit 2a23cd1
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/test_core_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,24 @@ def test_is_sorted():
view_df, view_df=view_df, view_name_col="fruit", df_view_col="fruit"
)

## testing for non-standard column names
view_df = pd.DataFrame(
[
["chrX", 1, 8, "oranges"],
["chrX", 8, 20, "grapefruit"],
["chr1", 0, 10, "apples"],
],
columns=["CHROM", "START", "END", "FRUIT"],
)

assert is_sorted(
view_df, view_df=view_df, view_name_col="FRUIT", df_view_col="FRUIT", cols=["CHROM", "START", "END"], cols_view=["CHROM", "START", "END"]
)

with pytest.raises(ValueError):
# cols and view_cols are not passed as an arguments
is_sorted(view_df, view_df=view_df)

df = pd.DataFrame(
[
["chr1", 0, 10, "+"],
Expand All @@ -452,6 +470,14 @@ def test_is_sorted():

assert not is_sorted(df)

view_df = pd.DataFrame(
[
["chrX", 1, 8, "oranges"],
["chrX", 8, 20, "grapefruit"],
["chr1", 0, 10, "apples"],
],
columns=["chrom", "start", "end", "fruit"],
)
bfs = sort_bedframe(df, view_df=view_df, view_name_col="fruit")

assert is_sorted(bfs, view_df=view_df, view_name_col="fruit")
Expand All @@ -461,4 +487,5 @@ def test_is_sorted():

if __name__ == "__main__":
test_is_covering()
test_is_tiling()
test_is_tiling()
test_is_sorted()

0 comments on commit 2a23cd1

Please sign in to comment.