-
Notifications
You must be signed in to change notification settings - Fork 297
Closed
Labels
Description
🐛 Bug Report
When a CubeList can be concatenated along two different axes, concatenate_cube will error before a cube can be returned
How To Reproduce
import numpy as np
from iris.cube import Cube, CubeList
from iris.coords import DimCoord
lat = DimCoord(np.arange(20), standard_name="latitude")
lon = DimCoord(np.arange(20), standard_name="longitude")
cube = Cube(np.zeros([20, 20]))
cube.add_dim_coord(lat, 0)
cube.add_dim_coord(lon, 1)
cube_quarters = CubeList([cube[:10, :10], cube[:10, 10:], cube[10:, :10], cube[10:, 10:]])
print(cube_quarters.concatenate()) # contains a single cube
print(cube_quarters.concatenate_cube()) # errors
Expected behaviour
A single cube should be returned here.
Additional context
I believe this is happening due to the fact that concatenate happens iteratively here:
Lines 647 to 650 in 0228c64
# Perform concatenation until we've reached an equilibrium. | |
count = len(concatenated_cubes) | |
if count != 1 and count != len(cubes): | |
concatenated_cubes = concatenate(concatenated_cubes) |
However, an error is thrown if any of these iterations fails to return a single cube. It would be better if an error could be held onto and thrown only after the last iteration.