Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ script:
- >
if [[ ${TEST_TARGET} == 'default' ]]; then
export IRIS_REPO_DIR=${INSTALL_DIR};
python -m iris.tests.runner --default-tests --system-tests --print-failed-images;

@bjlittle bjlittle Oct 16, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retire this testing infrastructure - it's flaky and pre-dates the existing workflow using perceptual image hashing.

If there are graphical failures on travis-ci then the developer will rerun locally, which is an acceptable workflow now that we have the necessary idiff capability and repeatable travis-ci environments locally. So this --print-failed-images capability is really no longer needed... so let's take the opportunity to purge old technical debt 😜

python -m iris.tests.runner --default-tests --system-tests;
fi

- if [[ ${TEST_TARGET} == 'example' ]]; then
python -m iris.tests.runner --example-tests --print-failed-images;
python -m iris.tests.runner --example-tests;
fi

# A call to check "whatsnew" contributions are valid, because the Iris test
Expand Down
7 changes: 3 additions & 4 deletions docs/iris/example_code/Meteorology/COP_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ def main():

# Add the first subplot showing the E1 scenario
plt.subplot(121)
plt.title('HadGEM2 E1 Scenario', fontsize=10)
plt.title('HadGEM2 E1 Scenario', fontsize=10)
iplt.contourf(delta_e1, levels, colors=colors, extend='both')
plt.gca().coastlines()
# get the current axes' subplot for use later on
plt1_ax = plt.gca()

# Add the second subplot showing the A1B scenario
plt.subplot(122)
plt.title('HadGEM2 A1B-Image Scenario', fontsize=10)
plt.title('HadGEM2 A1B-Image Scenario', fontsize=10)
contour_result = iplt.contourf(delta_a1b, levels, colors=colors,
extend='both')
plt.gca().coastlines()
Expand All @@ -131,8 +131,7 @@ def main():
width = left - first_plot_left + width

# Add axes to the figure, to place the colour bar
colorbar_axes = fig.add_axes([first_plot_left, bottom + 0.07,
width, 0.03])
colorbar_axes = fig.add_axes([first_plot_left, 0.18, width, 0.03])

@bjlittle bjlittle Oct 16, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bottom returned from get_position on line +127 now aligns with the actual bottom of the plot axes - this wasn't the case for matplotlib<3.

The fix here is to explicitly set the bottom of the colorbar_axes to align with this example from matplotlib=2.*


# Add the colour bar
cbar = plt.colorbar(contour_result, colorbar_axes,
Expand Down
1 change: 0 additions & 1 deletion docs/iris/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
'sphinx.ext.imgmath',
'sphinx.ext.intersphinx',
'matplotlib.sphinxext.mathmpl',
'matplotlib.sphinxext.only_directives',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a little bit of investigation, I happened across matplotlib/matplotlib#11295...

In a nutshell, ditch the matplotlib custom directives, which have been retired. The impact is simply to switch from matplotlib to the appropriate sphinx directives i.e.,

  • replace .. htmlonly:: -> .. only:: html, and
  • replace .. latexonly:: -> .. only:: latex

'matplotlib.sphinxext.plot_directive',

# better class documentation
Expand Down
4 changes: 2 additions & 2 deletions docs/iris/src/userguide/cube_maths.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ Finally, the cube we have created needs to be given a suitable name::
The result could now be plotted using the guidance provided in the
:doc:`plotting_a_cube` section.

.. htmlonly::
.. only:: html

A very similar example to this can be found in
:doc:`/examples/Meteorology/deriving_phenomena`.

.. latexonly::
.. only:: latex

A very similar example to this can be found in the examples section,
with the title "Deriving Exner Pressure and Air Temperature".
Expand Down
2 changes: 1 addition & 1 deletion docs/iris/src/userguide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fully before experimenting with your own data files.
Much of the content has supplementary links to the reference documentation; you will not need to follow these
links in order to understand the guide but they may serve as a useful reference for future exploration.

.. htmlonly::
.. only:: html

Since later pages depend on earlier ones, try reading this user guide sequentially using the ``next`` and ``previous`` links.

Expand Down
93 changes: 62 additions & 31 deletions lib/iris/tests/results/imagerepo.json

Large diffs are not rendered by default.

45 changes: 2 additions & 43 deletions lib/iris/tests/runner/_runner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2017, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -29,41 +29,6 @@
import sys


def failed_images_html():
"""
Generates HTML which shows the image failures side-by-side
when viewed in a web browser.
"""
from iris.tests.idiff import step_over_diffs

data_uri_template = '<img alt="{alt}" src="data:image/png;base64,{img}">'

def image_as_base64(fname):
with open(fname, "rb") as fh:
return fh.read().encode("base64").replace("\n", "")

html = ['<!DOCTYPE html>', '<html>', '<body>']
rdir = os.path.join(os.path.dirname(__file__), os.path.pardir,
'result_image_comparison')
if not os.access(rdir, os.W_OK):
rdir = os.path.join(os.getcwd(), 'iris_image_test_output')

for expected, actual, diff in step_over_diffs(rdir, 'similar', False):
expected_html = data_uri_template.format(
alt='expected', img=image_as_base64(expected))
actual_html = data_uri_template.format(
alt='actual', img=image_as_base64(actual))
diff_html = data_uri_template.format(
alt='diff', img=image_as_base64(diff))

html.extend([expected, '<br>',
expected_html, actual_html, diff_html,
'<br><hr>'])

html.extend(['</body>', '</html>'])
return '\n'.join(html)


# NOTE: Do not inherit from object as distutils does not like it.
class TestRunner():
"""Run the Iris tests under nose and multiprocessor for performance"""
Expand All @@ -84,12 +49,9 @@ class TestRunner():
('num-processors=', 'p', 'The number of processors used for running '
'the tests.'),
('create-missing', 'm', 'Create missing test result files.'),
('print-failed-images', 'f', 'Print HTML encoded version of failed '
'images.'),
]
boolean_options = ['no-data', 'system-tests', 'stop', 'example-tests',
'default-tests', 'coding-tests', 'create-missing',
'print-failed-images']
'default-tests', 'coding-tests', 'create-missing']

def initialize_options(self):
self.no_data = False
Expand All @@ -100,7 +62,6 @@ def initialize_options(self):
self.coding_tests = False
self.num_processors = None
self.create_missing = False
self.print_failed_images = False

def finalize_options(self):
# These enviroment variables will be propagated to all the
Expand Down Expand Up @@ -185,6 +146,4 @@ def run(self):
# word Mixin.
result &= nose.run(argv=args)
if result is False:
if self.print_failed_images:
print(failed_images_html())
exit(1)
2 changes: 1 addition & 1 deletion requirements/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cartopy
cf-units>=2
cftime
dask[array]>=2 #conda: dask>=2
matplotlib>=2,<3
matplotlib

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that, we still want to enforce proj4<6... for now.

netcdf4
numpy>=1.14
scipy