Skip to content

Commit

Permalink
Stock (#2212) (#2214)
Browse files Browse the repository at this point in the history
* move stock arrays to test data
  • Loading branch information
marqh authored and pp-mo committed Oct 26, 2016
1 parent 8983e38 commit 64fa25b
Show file tree
Hide file tree
Showing 33 changed files with 98 additions and 24 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ git:
depth: 10000

install:
- export IRIS_TEST_DATA_REF="e8e62ab79a2f8789f01f8dfa9829915984a39b2a"
- export IRIS_TEST_DATA_REF="a754fc977d30fdcdacb820b5a5fabd91056afc7b"
- export IRIS_TEST_DATA_SUFFIX=$(echo "${IRIS_TEST_DATA_REF}" | sed "s/^v//")

# Install miniconda
Expand Down Expand Up @@ -75,9 +75,11 @@ install:
- python -c 'import cartopy; cartopy.io.shapereader.natural_earth()'

# iris test data
- wget -O iris-test-data.zip https://github.com/SciTools/iris-test-data/archive/${IRIS_TEST_DATA_REF}.zip
- unzip -q iris-test-data.zip
- ln -s $(pwd)/iris-test-data-${IRIS_TEST_DATA_SUFFIX} iris-test-data
- if [[ "$TEST_MINIMAL" != true ]]; then
wget -O iris-test-data.zip https://github.com/SciTools/iris-test-data/archive/${IRIS_TEST_DATA_REF}.zip;
unzip -q iris-test-data.zip;
ln -s $(pwd)/iris-test-data-${IRIS_TEST_DATA_SUFFIX} iris-test-data;
fi

# prepare iris build directory
- python setup.py --with-unpack build_ext --include-dirs=${PREFIX}/include --library-dirs=${PREFIX}/lib
Expand Down
5 changes: 4 additions & 1 deletion lib/iris/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ def get_data_path(relative_path):
"""
if not isinstance(relative_path, six.string_types):
relative_path = os.path.join(*relative_path)
data_path = os.path.join(iris.config.TEST_DATA_DIR, relative_path)
test_data_dir = iris.config.TEST_DATA_DIR
if test_data_dir is None:
test_data_dir = ''
data_path = os.path.join(test_data_dir, relative_path)

if _EXPORT_DATAPATHS_FILE is not None:
_EXPORT_DATAPATHS_FILE.write(data_path + '\n')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def _resampled_grid(cube, x_samplefactor, y_samplefactor):
return new_cube


@tests.skip_data
class TestAreaWeightedRegrid(tests.IrisTest):
def setUp(self):
# A cube with a hybrid height derived coordinate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def test_simple_missing_data(self):
[True, False, False, False, True],
[True, True, True, True, True]])

@tests.skip_data
def test_multidimensional(self):
"""
Check valid operation on a multidimensional cube.
Expand Down
3 changes: 3 additions & 0 deletions lib/iris/tests/integration/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import iris.tests.stock as stock


@tests.skip_data
class TestHybridPressure(tests.IrisTest):
def setUp(self):
# Modify stock cube so it is suitable to have a
Expand Down Expand Up @@ -79,6 +80,7 @@ def test_save_load_loop(self):
self.assertEqual(cube, other_cube)


@tests.skip_data
class TestSaveMultipleAuxFactories(tests.IrisTest):
def test_hybrid_height_and_pressure(self):
cube = stock.realistic_4d()
Expand Down Expand Up @@ -306,6 +308,7 @@ def test_unknown_method(self):
shutil.rmtree(temp_dirpath)


@tests.skip_data
class TestCoordSystem(tests.IrisTest):
def test_load_laea_grid(self):
cube = iris.load_cube(
Expand Down
1 change: 1 addition & 0 deletions lib/iris/tests/integration/test_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ def test_time_mean_and_zonal_mean(self):
self.assertEqual(int(field.lbproc), 192)


@tests.skip_data
class TestCallbackLoad(tests.IrisTest):
def setUp(self):
self.pass_name = 'air_potential_temperature'
Expand Down
11 changes: 7 additions & 4 deletions lib/iris/tests/stock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2015, Met Office
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -471,8 +471,9 @@ def realistic_4d():
# >>> arrays.append(theta.data)
# >>> arrays.append(theta.coord('sigma').coord_system.orography.data)
# >>> np.savez('stock_arrays.npz', *arrays)

data_path = os.path.join(os.path.dirname(__file__), 'stock_arrays.npz')
data_path = tests.get_data_path(('stock', 'stock_arrays.npz'))
if not os.path.isfile(data_path):
raise IOError('Test data is not available at {}.'.format(data_path))
r = np.load(data_path)
# sort the arrays based on the order they were originally given. The names given are of the form 'arr_1' or 'arr_10'
_, arrays = zip(*sorted(six.iteritems(r), key=lambda item: int(item[0][4:])))
Expand Down Expand Up @@ -526,7 +527,9 @@ def realistic_4d_no_derived():


def realistic_4d_w_missing_data():
data_path = os.path.join(os.path.dirname(__file__), 'stock_mdi_arrays.npz')
data_path = tests.get_data_path(('stock', 'stock_mdi_arrays.npz'))
if not os.path.isfile(data_path):
raise IOError('Test data is not available at {}.'.format(data_path))
data_archive = np.load(data_path)
data = ma.masked_array(data_archive['arr_0'], mask=data_archive['arr_1'])

Expand Down
Binary file removed lib/iris/tests/stock_arrays.npz
Binary file not shown.
1 change: 1 addition & 0 deletions lib/iris/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ def test_area_weights(self):
self.assertCML(small_cube, ('analysis', 'areaweights_original.cml'),
checksum=False)

@tests.skip_data
class TestAreaWeightGeneration(tests.IrisTest):
def setUp(self):
self.cube = iris.tests.stock.realistic_4d()
Expand Down
1 change: 1 addition & 0 deletions lib/iris/tests/test_analysis_calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@


class TestCubeDelta(tests.IrisTest):
@tests.skip_data
def test_invalid(self):
cube = iris.tests.stock.realistic_4d()
with self.assertRaises(iris.exceptions.CoordinateMultiDimError):
Expand Down
10 changes: 8 additions & 2 deletions lib/iris/tests/test_cdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def test_immutable_auxcoord_dims(self):
dims[0] = 1


@tests.skip_data
class TestStockCubeStringRepresentations(tests.IrisTest):
def setUp(self):
self.cube = iris.tests.stock.realistic_4d()
Expand Down Expand Up @@ -276,10 +277,12 @@ def test_dot_simple_pp(self):
del cube.attributes['my_attribute']

# TODO hybrid height and dot output - relatitionship links
@tests.skip_data
def test_dot_4d(self):
cube = iris.tests.stock.realistic_4d()
self.check_dot(cube, ('file_load', '4d_pp.dot'))

@tests.skip_data
def test_missing_coords(self):
cube = iris.tests.stock.realistic_4d()
cube.remove_coord('time')
Expand All @@ -289,6 +292,7 @@ def test_missing_coords(self):
self.assertString(str(cube),
('cdm', 'str_repr', 'missing_coords_cube.str.txt'))

@tests.skip_data
def test_cubelist_string(self):
cube_list = iris.cube.CubeList([iris.tests.stock.realistic_4d(),
iris.tests.stock.global_pp()])
Expand Down Expand Up @@ -1069,8 +1073,9 @@ def test_multi_d(self):

# Ensure no side effects
self.assertCML(cube, ('cube_collapsed', 'original.cml'))




@tests.skip_data
class TestTrimAttributes(tests.IrisTest):
def test_non_string_attributes(self):
cube = iris.tests.stock.realistic_4d()
Expand Down Expand Up @@ -1155,6 +1160,7 @@ def test_save_and_merge(self):
self.assertEqual(merged_cube.data.fill_value, 123456)


@tests.skip_data
class TestConversionToCoordList(tests.IrisTest):
def test_coord_conversion(self):
cube = iris.tests.stock.realistic_4d()
Expand Down
7 changes: 5 additions & 2 deletions lib/iris/tests/test_constraints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2015, Met Office
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -43,8 +43,11 @@ def workaround_pending_1262(cubes):
cubes[i] = cube[::-1]


@tests.skip_data
class TestSimple(tests.IrisTest):
slices = iris.cube.CubeList(stock.realistic_4d().slices(['grid_latitude', 'grid_longitude']))
def setUp(self):
names = ['grid_latitude', 'grid_longitude']
self.slices = iris.cube.CubeList(stock.realistic_4d().slices(names))

def test_constraints(self):
constraint = iris.Constraint(model_level_number=10)
Expand Down
7 changes: 6 additions & 1 deletion lib/iris/tests/test_coord_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2015, Met Office
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -106,6 +106,7 @@ def test_lazy_shared_data(self):
self._check_shared_data(self.coord)


@tests.skip_data
class TestCoordSlicing(unittest.TestCase):
def setUp(self):
cube = iris.tests.stock.realistic_4d()
Expand Down Expand Up @@ -207,6 +208,7 @@ def test_no_intersection_on_unit(self):
self.a.units = 'kilometer'
self.assertRaises(ValueError, self.a.intersect, self.b)

@tests.skip_data
def test_commutative(self):
cube = iris.tests.stock.realistic_4d()
coord = cube.coord('grid_longitude')
Expand All @@ -232,6 +234,7 @@ def test_complex(self):
self.assertXMLElement(coord, ('coord_api', 'complex.xml'))


@tests.skip_data
class TestCoord_ReprStr_nontime(tests.IrisTest):
def setUp(self):
self.lat = iris.tests.stock.realistic_4d().coord('grid_latitude')[:10]
Expand All @@ -253,6 +256,7 @@ def test_AuxCoord_str(self):
('coord_api', 'str_repr', 'aux_nontime_str.txt'))


@tests.skip_data
class TestCoord_ReprStr_time(tests.IrisTest):
def setUp(self):
self.time = iris.tests.stock.realistic_4d().coord('time')
Expand Down Expand Up @@ -596,6 +600,7 @@ def test_nd_bounds(self):
self.assertCML(pcube, ("coord_api", "nd_bounds.cml"))


@tests.skip_data
class TestGetterSetter(tests.IrisTest):
def test_get_set_points_and_bounds(self):
cube = iris.tests.stock.realistic_4d()
Expand Down
3 changes: 2 additions & 1 deletion lib/iris/tests/test_cube_to_pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ def test_pp_save_rules(self):
self.assertEqual(self.lbproc_from_pp(temp_filename), lbproc)

os.remove(temp_filename)


@tests.skip_data
def test_lbvc(self):
cube = stock.realistic_4d_no_derived()[0, :4, ...]

Expand Down
2 changes: 2 additions & 0 deletions lib/iris/tests/test_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@


@tests.skip_plot
@tests.skip_data
class TestRealistic4d(tests.GraphicsTest):
def setUp(self):
super(TestRealistic4d, self).setUp()
Expand Down Expand Up @@ -160,6 +161,7 @@ def test_bounded_orography(self):
bounds = altitude.bounds


@tests.skip_data
class TestHybridPressure(tests.IrisTest):
def setUp(self):
# Convert the hybrid-height into hybrid-pressure...
Expand Down
3 changes: 2 additions & 1 deletion lib/iris/tests/test_iterate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2015, Met Office
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -40,6 +40,7 @@
from functools import reduce


@tests.skip_data
class TestIterateFunctions(tests.IrisTest):

def setUp(self):
Expand Down
5 changes: 4 additions & 1 deletion lib/iris/tests/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@


@tests.skip_plot
@tests.skip_data
class TestBasic(tests.GraphicsTest):
cube = iris.tests.stock.realistic_4d()
def setUp(self):
super(TestBasic, self).setUp()
self.cube = iris.tests.stock.realistic_4d()

def test_contourf(self):
cube = self.cube[0, 0]
Expand Down
1 change: 1 addition & 0 deletions lib/iris/tests/test_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def test_bad_permissions(self):
os.rmdir(dir_name)


@tests.skip_data
class TestSave(tests.IrisTest):
def test_hybrid(self):
cube = stock.realistic_4d()
Expand Down
4 changes: 4 additions & 0 deletions lib/iris/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import iris.symbols


@tests.skip_data
def simple_cube():
cube = iris.tests.stock.realistic_4d()
cube = cube[:, 0, 0, :]
Expand Down Expand Up @@ -102,6 +103,7 @@ def test_missing_cs(self):


@tests.skip_plot
@tests.skip_data
class TestHybridHeight(tests.GraphicsTest):
def setUp(self):
super(TestHybridHeight, self).setUp()
Expand Down Expand Up @@ -151,6 +153,7 @@ def test_orography(self):


@tests.skip_plot
@tests.skip_data
class Test1dPlotMultiArgs(tests.GraphicsTest):
# tests for iris.plot using multi-argument calling convention

Expand Down Expand Up @@ -367,6 +370,7 @@ def inner(*args, **kwargs):


@cache
@tests.skip_data
def _load_4d_testcube():
# Load example 4d data (TZYX).
test_cube = iris.tests.stock.realistic_4d()
Expand Down
1 change: 1 addition & 0 deletions lib/iris/tests/test_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import iris.tests.stock


@tests.skip_data
class TestSimple(tests.IrisTest):
def test_invalid_coord(self):
cube = iris.tests.stock.realistic_4d()
Expand Down
2 changes: 2 additions & 0 deletions lib/iris/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def test_trim_string_with_no_spaces(self):
'expected value is %s' % (len(result), expected_length))


@tests.skip_data
class TestDescribeDiff(iris.tests.IrisTest):
def test_identical(self):
test_cube_a = stock.realistic_4d()
Expand Down Expand Up @@ -262,6 +263,7 @@ def test_output_file(self):
'incompatible_cubes.str.txt')


@tests.skip_data
class TestAsCompatibleShape(tests.IrisTest):
def test_slice(self):
cube = tests.stock.realistic_4d()
Expand Down
Loading

0 comments on commit 64fa25b

Please sign in to comment.