-
Notifications
You must be signed in to change notification settings - Fork 296
Description
There appear to be a problem with the method used by Iris to determine which coordinates to use to construct new dimensions, and the shape of those dimensions, when merging. It looks like the problem stems from the fact that in order to determine if two scalar coordinates A and B can be 'separated' (can appear on separate dimensions in the new cube), Iris constructs, for each point of A, the set of points of B with which it appears on a cube in the list, and likewise for B -- and thus it ignores duplicates. It then tries to construct a shape for the new cube based on this idea of separability, which causes problems.
For example, consider four scalar cubes each with scalar coordinates A and B with points taken from the following two lists of points:
A = [1, 1, 2, 2]
B = [3, 4, 3, 4]
These four cubes can be merged into a single 2 x 2 cubes with coordinates A=[1,2], B=[3,4] on separate dimensions. To determine the new dimensions, Iris constructs the following dictionaries (called 'indexes' in the code):
IA, B = { 1: set(3, 4), 2: set(3,4) }
IB, A = { 3: set(1, 2), 4: set(1,2) }
That is, for each point in A, the set of points it appears with on a source cube, and likewise for B. It then uses the reasoning I outlined above: it compares the sets in IA, B, sees that they are all the same, and determines that A is separable from B. It does the same for IB, A. It later uses this information when determining the shape of the new cube (2,2).
Now consider six scalar cubes with coordinates based on the following points:
A = [1, 2, 1, 2, 1, 2]
B = [3, 4, 4, 4, 4, 3]
C = [5, 5, 6, 6, 7, 7]
These cubes should merge into a 3 x 2 (or 2 x 3) cube with dimension coordinates C and A (or A and C) respectively, with B as a 3 x 2 auxiliary coordinate spanning both dimensions. But Iris gets things wrong. For coordinates A and B it constructs the same index dictionaries as before (because the sets of A/B point pairs are the same), so Iris determines that A and B are separable, and tries to construct a new dimension for each of them on the result cube (I'm not clear on the logic it uses to determine the shape; in this case it tries to make it (2, 5)), which causes an exception to be raised.
There are various manifestation of the error, but I believe they all stem from the fact that Iris only looks at the set of point pairs for each pair of coordinates.
Metadata
Metadata
Assignees
Type
Projects
Status