Project-MONAI / MONAILabel

MONAI Label is an intelligent open source image labeling and learning tool.
https://docs.monai.io/projects/label
Apache License 2.0
623 stars 195 forks source link

TestFindContoursd mismatch result when opencv installed #1720

Open KumoLiu opened 4 months ago

KumoLiu commented 4 months ago
_______________________ TestFindContoursd.test_result_0 ________________________

a = (<tests.unit.transform.test_post.TestFindContoursd testMethod=test_result_0>,)
kw = {}

    @wraps(func)
    def standalone_func(*a, **kw):
>       return func(*(a + p.args), **p.kwargs, **kw)

/usr/local/lib/python3.10/dist-packages/parameterized/parameterized.py:620: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/unit/transform/test_post.py:121: in test_result
    self.assertEqual(res["result"]["annotation"]["elements"][0]["contours"], expected_output)
E   AssertionError: Lists differ: [[[1, 2], [2, 1], [3, 2], [2, 3]], [[1, 1], [1, 3], [3, 3], [3, 1]]] != [[[3, 4], [1, 4], [0, 3], [0, 1], [1, 0], [3, 0], [4, 1], [4, 3], [3, 4]]]
E   
E   First differing element 0:
E   [[1, 2], [2, 1], [3, 2], [2, 3]]
E   [[3, 4], [1, 4], [0, 3], [0, 1], [1, 0], [3, 0], [4, 1], [4, 3], [3, 4]]
E   
E   First list contains 1 additional elements.
E   First extra element 1:
E   [[1, 1], [1, 3], [3, 3], [3, 1]]
E   
E   - [[[1, 2], [2, 1], [3, 2], [2, 3]], [[1, 1], [1, 3], [3, 3], [3, 1]]]
E   + [[[3, 4], [1, 4], [0, 3], [0, 1], [1, 0], [3, 0], [4, 1], [4, 3], [3, 4]]]

Need to consider the unittest cover the result when opencv installed.

KumoLiu commented 4 months ago

cc @tangy5 @SachidanandAlle @mingxin-zheng @Nic-Ma

tangy5 commented 3 months ago

Will optimized this unit test, in two cases, with OPENCV, we need additional test case.