From 67eb24b9f640cefd91d56a82e13defcacaa3359e Mon Sep 17 00:00:00 2001 From: Daniel Kirkham Date: Mon, 20 Mar 2017 17:03:14 +0000 Subject: [PATCH] Example test fixes --- .../example_code/General/custom_file_loading.py | 4 ++-- docs/iris/src/conf.py | 4 ++-- lib/iris/tests/idiff.py | 13 ++++++++++++- lib/iris/tests/results/imagerepo.json | 12 +++++++----- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/docs/iris/example_code/General/custom_file_loading.py b/docs/iris/example_code/General/custom_file_loading.py index 27f037f06f9..d6fddf84643 100644 --- a/docs/iris/example_code/General/custom_file_loading.py +++ b/docs/iris/example_code/General/custom_file_loading.py @@ -158,8 +158,8 @@ def load_NAME_III(filename): # Cast the x and y grid positions to floats and convert them to # zero based indices (the numbers are 1 based grid positions where # 0.5 represents half a grid point.) - x = float(vals[0]) - 1.5 - y = float(vals[1]) - 1.5 + x = int(float(vals[0]) - 1.5) + y = int(float(vals[1]) - 1.5) # Populate the data arrays (i.e. all columns but the leading 4). for i, data_array in enumerate(data_arrays): diff --git a/docs/iris/src/conf.py b/docs/iris/src/conf.py index 254ef464c0e..b3db19d5150 100644 --- a/docs/iris/src/conf.py +++ b/docs/iris/src/conf.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2010 - 2016, Met Office +# (C) British Crown Copyright 2010 - 2017, Met Office # # This file is part of Iris. # @@ -56,7 +56,7 @@ # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', - 'sphinx.ext.pngmath', + 'sphinx.ext.imgmath', 'sphinx.ext.autosummary', 'sphinx.ext.graphviz', 'sphinx.ext.intersphinx', diff --git a/lib/iris/tests/idiff.py b/lib/iris/tests/idiff.py index e5b39b615e7..79500e98ece 100755 --- a/lib/iris/tests/idiff.py +++ b/lib/iris/tests/idiff.py @@ -41,6 +41,7 @@ import matplotlib.pyplot as plt import matplotlib.image as mimg import matplotlib.testing.compare as mcompare +from matplotlib.testing.exceptions import ImageComparisonFailure import matplotlib.widgets as mwidget import numpy as np import requests @@ -236,7 +237,17 @@ def step_over_diffs(result_dir, action, display=True): # So copy the local file to the exected file to # maintain this helpfulness. shutil.copy(local_fname, expected_fname) - mcompare.compare_images(expected_fname, result_fname, tol=0) + try: + mcompare.compare_images(expected_fname, result_fname, + tol=0) + except Exception as e: + if isinstance(e, ValueError) or \ + isinstance(e, ImageComparisonFailure): + print('Could not compare {}: {}'.format(result_fname, + e.message)) + continue + else: + raise diff_fname = os.path.splitext(result_fname)[0] + _POSTFIX_DIFF args = expected_fname, result_fname, diff_fname if display: diff --git a/lib/iris/tests/results/imagerepo.json b/lib/iris/tests/results/imagerepo.json index 5be04ec300a..202ecbd1d02 100644 --- a/lib/iris/tests/results/imagerepo.json +++ b/lib/iris/tests/results/imagerepo.json @@ -85,12 +85,14 @@ ], "example_tests.test_projections_and_annotations.TestProjectionsAndAnnotations.test_projections_and_annotations.0": [ "https://scitools.github.io/test-iris-imagehash/images/5fa1f298a1580c27336eb3d08d9e4c3ae563a60d931cd3d2728e7939ede4ad03.png", - "https://scitools.github.io/test-iris-imagehash/images/5fa3f298a1580c27336eb3d08d9e4c3aed61a60d931cd3d2728e7939e9e4ad03.png" + "https://scitools.github.io/test-iris-imagehash/images/5fa3f298a1580c27336eb3d08d9e4c3aed61a60d931cd3d2728e7939e9e4ad03.png", + "https://scitools.github.io/test-iris-imagehash/images/5fa17298a1580c27336eb3d08d9e4c3aed63260d931cd3d273ce7939ecc5ad03.png" ], "example_tests.test_projections_and_annotations.TestProjectionsAndAnnotations.test_projections_and_annotations.1": [ "https://scitools.github.io/test-iris-imagehash/images/c7a196b9391c69464ec28cf1b3b55abe63db2549976d9926c9b643982e8da149.png", "https://scitools.github.io/test-iris-imagehash/images/c7a196b9391c694e4ec28cf1b1b55abe63da25499d6c9926d9b643da26c9a149.png", - "https://scitools.github.io/test-iris-imagehash/images/c7a196b9391c69464ec28cf1b3b55abe63db25499d6c9926d9b6439a26c9a149.png" + "https://scitools.github.io/test-iris-imagehash/images/c7a196b9391c69464ec28cf1b3b55abe63db25499d6c9926d9b6439a26c9a149.png", + "https://scitools.github.io/test-iris-imagehash/images/c7a1d699391c694e4ec28cf1b1b55aae69da25499f6d9926db3263da2689a149.png" ], "example_tests.test_rotated_pole_mapping.TestRotatedPoleMapping.test_rotated_pole_mapping.0": [ "https://scitools.github.io/test-iris-imagehash/images/5fa8867ae985c9b5837a7881235f7c2db90c817e7ca0837edea599e4817e7880.png" @@ -710,12 +712,12 @@ "iris.tests.test_quickplot.TestTimeReferenceUnitsLabels.test_not_reference_time_units.0": [ "https://scitools.github.io/test-iris-imagehash/images/415f85e9fefb91e94600bb6f07009be7effa1966ab065b273b009b663b007a04.png", "https://scitools.github.io/test-iris-imagehash/images/411d85e9fefb91e14600bb6707009be7effe1966ab06fb273b009b663f007a04.png", - "https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6f07009be7effe1966ab067b273b009b663b007a04.png", - "https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6707009be7effe1966ab06fb273b00bb263b007a04.png" + "https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6f07009be7effe1966ab067b273b009b663b007a04.png", + "https://scitools.github.io/test-iris-imagehash/images/411f85e9fefb91e14600bb6707009be7effe1966ab06fb273b00bb263b007a04.png" ], "iris.tests.test_quickplot.TestTimeReferenceUnitsLabels.test_reference_time_units.0": [ "https://scitools.github.io/test-iris-imagehash/images/417f8119feebeeff070054bb2b0014a0bb157ba6bb972b46dabf3b0419827b04.png", "https://scitools.github.io/test-iris-imagehash/images/417f8119fefbeeff070054b92b0014a0bb557ba69b95ab46dabf3b0419827b04.png", "https://scitools.github.io/test-iris-imagehash/images/417f8119fefbeeff070054bb2b0014a0bb14fbe69b952b46dabf3b0419827b04.png" ] -} +} \ No newline at end of file