Skip to content

Commit

Permalink
Added specific test for array attribute handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Dec 20, 2024
1 parent e841ec2 commit e30e5d8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/iris/tests/unit/util/test_equalise_cubes.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,40 @@ def test_operation_in_groups(self, usage):
# Assert result
assert [cube.metadata for cube in results] == expected_metadatas

def test_array_attributes(self, usage):
# Array content is worth a special test because it breaks dictionary equality.
a1 = np.array([4.1, 5.2, 6.3])
a2 = np.array([1, 2])
a3 = np.array([1, 3])
test_cubes = [
_cube(longname="a", v1=a1, v2=a2),
_cube(longname="a", v1=a1, v2=a3),
_cube(longname="b", v1=a1, v2=a2),
_cube(longname="b", v1=a1, v2=a2),
]
kwargs, expected_metadatas = _usage_common(
usage, "equalise_attributes", test_cubes
)

# Calculate expected results
if usage != "off":
# result cube metadata should all be the same, with no varname
result_cubes = [
_cube(longname="a", v1=a1),
_cube(longname="a", v1=a1),
_cube(longname="b", v1=a1, v2=a2),
_cube(longname="b", v1=a1, v2=a2),
]
expected_metadatas = [cube.metadata for cube in result_cubes]
if usage == "scrambled":
_scramble(expected_metadatas)

# Apply operation
results = equalise_cubes(test_cubes, **kwargs)

# Assert result
assert [cube.metadata for cube in results] == expected_metadatas


class TestUnifyTimeUnits(WarnChecked):
# Test the 'unify_time_units' operation.
Expand Down

0 comments on commit e30e5d8

Please sign in to comment.