From 0ab3ac2d51341cdcf4c43c7d5053280618293704 Mon Sep 17 00:00:00 2001 From: NatLee Date: Sat, 25 Jan 2025 17:42:41 +0800 Subject: [PATCH] [fix] avoid problem of precision in float --- tests/test_analyze.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_analyze.py b/tests/test_analyze.py index 46d4d16..a36acc5 100644 --- a/tests/test_analyze.py +++ b/tests/test_analyze.py @@ -171,8 +171,9 @@ def test_batch_detect_age_for_multiple_faces(): results = Age.ApparentAgeClient().predict(imgs) # Check there are two ages detected assert len(results) == 2 - # Check two faces ages are the same - assert np.array_equal(results[0], results[1]) + # Check two faces ages are the same in integer format(e.g. 23.6 -> 23) + # Must use int() to compare because of max float precision issue in different platforms + assert np.array_equal(int(results[0]), int(results[1])) logger.info("✅ test batch detect age for multiple faces done") def test_batch_detect_emotion_for_multiple_faces():