Skip to content

Commit 4715ad5

Browse files
committed
Functioning backstop: merge can pass-through dataless, but not actually merge them.
1 parent c4165a9 commit 4715ad5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/iris/_merge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,8 +1305,8 @@ def register(self, cube, error_on_mismatch=False):
13051305
this :class:`ProtoCube`.
13061306
13071307
"""
1308-
if cube.is_dataless():
1309-
raise iris.exceptions.DatalessError("merge")
1308+
# if cube.is_dataless():
1309+
# raise iris.exceptions.DatalessError("merge")
13101310
cube_signature = self._cube_signature
13111311
other = self._build_signature(cube)
13121312
match = cube_signature.match(other, error_on_mismatch)

lib/iris/tests/integration/merge/test_dataless.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ def _testcube(self, z=1, name="this", dataless=False):
1515
# Create a testcube with a scalar Z coord, for merge testing.
1616
cube = Cube(
1717
[1, 2, 3],
18+
long_name=name,
1819
dim_coords_and_dims=[(DimCoord([0.0, 1.0, 2], long_name="x"), 0)],
1920
aux_coords_and_dims=[(AuxCoord([z], long_name="z"), ())],
2021
)
2122
if dataless:
2223
cube.data = None
2324
return cube
2425

25-
def test_general_nomerge(self):
26-
# Check that normal merge works OK with dataless cubes included
26+
def test_mixed_passthrough(self):
27+
# Check that normal merge can handle dataless alongside dataful cubes.
2728
cubes = CubeList(
2829
[
2930
self._testcube(name="this", dataless=False),
@@ -34,17 +35,19 @@ def test_general_nomerge(self):
3435
assert len(result) == 2
3536
cube1, cube2 = [result.extract_cube(name) for name in ("this", "that")]
3637
assert not cube1.is_dataless()
37-
assert cube1.is_dataless()
38+
assert cube2.is_dataless()
3839

3940
def test_dataless_merge(self):
40-
# Check that dataless cubes can be merged correctly.
41+
# Check that dataless cubes can be merged.
4142
cubes = CubeList(
4243
[
4344
self._testcube(z=1, dataless=True),
4445
self._testcube(z=2, dataless=True),
4546
]
4647
)
47-
cube = cubes.merge_cube()
48+
cubes = cubes.merge()
49+
assert len(cubes) == 2
50+
(cube, cube2) = cubes
4851
assert cube.is_dataless()
4952
assert np.all(cube.coord("z").points == [1, 2])
5053

0 commit comments

Comments
 (0)