Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rwood-97 committed Aug 12, 2024
1 parent c38afb1 commit 5c9fc6f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_classify/test_annotations_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@ def test_labels_map(sample_dir):
assert annots.labels_map == {0: "railspace", 1: "no", 2: "building"}


def test_get_label_index(sample_dir):
annots = AnnotationsLoader()
annots.load(
f"{sample_dir}/test_annots.csv",
reset_index=True,
remove_broken=False,
ignore_broken=True,
labels_map={
0: "railspace",
1: "no",
}, # different order vs in the csv
)
assert annots.labels_map == {0: "railspace", 1: "no"}
assert annots._get_label_index("railspace") == 0

# test append
annots.load(
f"{sample_dir}/test_annots_append.csv",
append=True,
remove_broken=False,
ignore_broken=True,
)
assert annots.unique_labels == ["no", "railspace", "building"]
assert annots.labels_map == {0: "railspace", 1: "no", 2: "building"}
assert annots._get_label_index("railspace") == 0
assert annots._get_label_index("building") == 2


@pytest.mark.dependency(name="load_annots_df", scope="session")
def test_load_df(sample_dir):
annots = AnnotationsLoader()
Expand Down

0 comments on commit 5c9fc6f

Please sign in to comment.