Browse Source

dataset UT: check PIL version, delete test_callback_2maps

tags/v1.1.0
Cathy Wong 5 years ago
parent
commit
f2b07d907a
2 changed files with 11 additions and 13 deletions
  1. +0
    -8
      tests/ut/python/dataset/test_callbacks.py
  2. +11
    -5
      tests/ut/python/dataset/util.py

+ 0
- 8
tests/ut/python/dataset/test_callbacks.py View File

@@ -217,13 +217,6 @@ def test_callbacks_all_2cbs():
build_test_case_2cbs(4, 4)


def skip_test_callbacks_2maps():
logger.info("test_callbacks_2maps")
# This test case is skipped because in rare cases (25 out 1000) it might fail
build_test_case_2maps(5, 10)
build_test_case_2maps(6, 9)


class MyWaitedCallback(WaitedDSCallback):
def __init__(self, events, step_size=1):
super().__init__(step_size)
@@ -462,7 +455,6 @@ def test_callbacks_one_cb():


if __name__ == '__main__':
skip_test_callbacks_2maps()
test_callbacks_all_2cbs()
test_callbacks_all_methods()
test_callbacks_exceptions()


+ 11
- 5
tests/ut/python/dataset/util.py View File

@@ -21,6 +21,7 @@ from enum import Enum
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import PIL
# import jsbeautifier
import mindspore.dataset as ds
from mindspore import log as logger
@@ -60,13 +61,18 @@ def _compare_to_golden(golden_ref_dir, result_dict):
np.testing.assert_array_equal(test_array, golden_array)


def _compare_to_golden_dict(golden_ref_dir, result_dict):
def _compare_to_golden_dict(golden_ref_dir, result_dict, check_pillow_version=False):
"""
Compare as dictionaries the test result to the golden result
"""
golden_array = np.load(golden_ref_dir, allow_pickle=True)['arr_0']
np.testing.assert_equal(result_dict, dict(golden_array))

# Note: The version of PILLOW that is used in Jenkins CI is compared with below
if (not check_pillow_version or PIL.__version__ == '7.1.2'):
np.testing.assert_equal(result_dict, dict(golden_array))
else:
# Beware: If error, PILLOW version of golden results may be incompatible with current PILLOW version
np.testing.assert_equal(result_dict, dict(golden_array),
'Items are not equal and problem may be due to PILLOW version incompatibility')

def _save_json(filename, parameters, result_dict):
"""
@@ -103,7 +109,7 @@ def save_and_check_dict(data, filename, generate_golden=False):
# Save as the golden result
_save_golden_dict(cur_dir, golden_ref_dir, result_dict)

_compare_to_golden_dict(golden_ref_dir, result_dict)
_compare_to_golden_dict(golden_ref_dir, result_dict, False)

if SAVE_JSON:
# Save result to a json file for inspection
@@ -135,7 +141,7 @@ def save_and_check_md5(data, filename, generate_golden=False):
# Save as the golden result
_save_golden_dict(cur_dir, golden_ref_dir, result_dict)

_compare_to_golden_dict(golden_ref_dir, result_dict)
_compare_to_golden_dict(golden_ref_dir, result_dict, True)


def save_and_check_tuple(data, parameters, filename, generate_golden=False):


Loading…
Cancel
Save