Skip to content

Commit

Permalink
Condition image property fix (#1329)
Browse files Browse the repository at this point in the history
* fix_cond

* fix_cond
  • Loading branch information
JKL98ISR committed Apr 26, 2022
1 parent bac0043 commit 79d705a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def condition(result: t.Dict[str, float]) -> ConditionResult:
if len(failed_properties) > 0:
failed_properties = ';\n'.join(f'{p}={d:.2f}' for p, d in failed_properties)
return ConditionResult(
False,
ConditionCategory.FAIL,
'Earth Mover\'s Distance is above the threshold '
f'for the next properties:\n{failed_properties}'
)
Expand Down
40 changes: 28 additions & 12 deletions tests/vision/checks/distribution/image_property_drift_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
instance_of,
all_of,
calling,
matches_regexp,
raises,
has_property,
has_properties,
Expand All @@ -24,6 +25,7 @@
)

from deepchecks.core import CheckResult
from deepchecks.core.condition import ConditionCategory
from deepchecks.core.errors import DeepchecksValueError, DeepchecksNotImplementedError
from deepchecks.vision.datasets.classification.mnist import MNISTData
from deepchecks.vision.utils.image_properties import default_image_properties
Expand Down Expand Up @@ -92,18 +94,32 @@ def test_image_property_drift_condition(coco_train_visiondata, coco_test_visiond
))


# def contains_failed_condition():
# condition_assertion = has_properties({
# 'is_pass': equal_to(False),
# 'details': matches(
# r'Earth Mover\'s Distance is above the threshold '
# r'for the next properties\:\n.*'
# )
# })
# return has_property(
# 'conditions_results',
# contains_exactly(condition_assertion)
# )
def test_image_property_drift_fail_condition(coco_train_visiondata, coco_test_visiondata, device):
result = (
ImagePropertyDrift()
.add_condition_drift_score_not_greater_than(0)
.run(coco_train_visiondata, coco_test_visiondata, device=device)
)

assert_that(result, all_of(
is_correct_image_property_drift_result(),
contains_failed_condition()
))


def contains_failed_condition():
condition_assertion = has_properties({
'is_pass': equal_to(False),
'category': equal_to(ConditionCategory.FAIL),
'details': matches_regexp(
r'Earth Mover\'s Distance is above the threshold '
r'for the next properties\:\n.*'
)
})
return has_property(
'conditions_results',
contains_exactly(condition_assertion)
)


def contains_passed_condition():
Expand Down

0 comments on commit 79d705a

Please sign in to comment.