Skip to content

Commit c5bc744

Browse files
authored
area weight regrid test fixes (SciTools#4432)
1 parent 0a0cb87 commit c5bc744

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

docs/src/whatsnew/latest.rst

+2
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ This document explains the changes made to Iris for this release
220220
using assertArrayAllClose following :issue:`3993`.
221221
(:pull:`4421`)
222222

223+
#. `@rcomer`_ applied minor fixes to some regridding tests. (:pull:`4432`)
224+
223225
.. comment
224226
Whatsnew author names (@github name) in alphabetical order. Note that,
225227
core dev names are automatically included by the common_links.inc:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright Iris contributors
2+
#
3+
# This file is part of Iris and is released under the LGPL license.
4+
# See COPYING and COPYING.LESSER in the root of the repository for full
5+
# licensing details.
6+
"""Integration tests for the :mod:`iris.analysis` package."""

lib/iris/tests/integration/analysis/test_area_weighted.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
# importing anything else.
1010
import iris.tests as tests # isort:skip
1111

12-
import tempfile
13-
1412
import iris
1513
from iris.analysis import AreaWeighted
1614

@@ -37,8 +35,8 @@ def test_regrid_area_w_lazy(self):
3735
self.assertTrue(self.cube.has_lazy_data())
3836
self.assertTrue(out.has_lazy_data())
3937
# Save the data
40-
with tempfile.TemporaryFile(suffix=".nc") as fp:
41-
iris.save(out, fp)
38+
with self.temp_filename(suffix=".nc") as fname:
39+
iris.save(out, fname)
4240

4341
def test_regrid_area_w_lazy_chunked(self):
4442
# Chunked data makes the regridder run repeatedly
@@ -49,8 +47,8 @@ def test_regrid_area_w_lazy_chunked(self):
4947
self.assertTrue(self.cube.has_lazy_data())
5048
self.assertTrue(out.has_lazy_data())
5149
# Save the data
52-
with tempfile.TemporaryFile(suffix=".nc") as fp:
53-
iris.save(out, fp)
50+
with self.temp_filename(suffix=".nc") as fname:
51+
iris.save(out, fname)
5452

5553
def test_regrid_area_w_real_save(self):
5654
real_cube = self.cube.copy()
@@ -60,17 +58,17 @@ def test_regrid_area_w_real_save(self):
6058
# Realise the data
6159
out.data
6260
# Save the data
63-
with tempfile.TemporaryFile(suffix=".nc") as fp:
64-
iris.save(out, fp)
61+
with self.temp_filename(suffix=".nc") as fname:
62+
iris.save(out, fname)
6563

6664
def test_regrid_area_w_real_start(self):
6765
real_cube = self.cube.copy()
6866
real_cube.data
6967
# Regrid the cube onto the template.
7068
out = real_cube.regrid(self.template_cube, AreaWeighted())
7169
# Save the data
72-
with tempfile.TemporaryFile(suffix=".nc") as fp:
73-
iris.save(out, fp)
70+
with self.temp_filename(suffix=".nc") as fname:
71+
iris.save(out, fname)
7472

7573

7674
if __name__ == "__main__":

0 commit comments

Comments
 (0)