Skip to content

Commit

Permalink
fixing ExactComparator
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldies committed Jan 17, 2025
1 parent 7c3d66c commit ef1b078
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cvat/apps/dataset_manager/tests/test_rest_api_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import numpy as np
from attr import define, field
from datumaro.components.dataset import Dataset
from datumaro.components.operations import ExactComparator
from datumaro.components.comparator import EqualityComparator
from django.contrib.auth.models import Group, User
from PIL import Image
from rest_framework import status
Expand Down Expand Up @@ -119,10 +119,13 @@ def generate_video_file(filename, width=1280, height=720, duration=1, fps=25, co

def compare_datasets(expected: Dataset, actual: Dataset):
# we need this function to allow for a bit of variation in the rotation attribute
comparator = ExactComparator(ignored_attrs=["rotation"])
_, unmatched, expected_extra, actual_extra, errors = comparator.compare_datasets(
expected, actual
)
comparator = EqualityComparator(ignored_attrs=["rotation"])

output = comparator.compare_datasets(expected, actual)
unmatched = output["mismatches"]
expected_extra = output["a_extra_items"]
actual_extra = output["b_extra_items"]
errors = output["errors"]
assert not unmatched, f"Datasets have unmatched items: {unmatched}"
assert not actual_extra, f"Actual has following extra items: {actual_extra}"
assert not expected_extra, f"Expected has following extra items: {expected_extra}"
Expand Down

0 comments on commit ef1b078

Please sign in to comment.