Skip to content

Commit

Permalink
Fix logic for equals expectation; expand primary/secondary independen…
Browse files Browse the repository at this point in the history
…ce test.
  • Loading branch information
pp-mo committed Nov 15, 2023
1 parent 07ed579 commit dca5dce
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions lib/iris/tests/unit/common/metadata/test_CubeMetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,11 @@ def check_splitattrs_testcase(
expected = _ALL_RESULTS[operation_name][primary_key][which]
if operation_name == "equal" and expected:
# Account for the equality cases made `False` by mismatched secondary values.
secondary_1, secondary_2 = secondary_inputs
if (
secondary_1 != "X"
and secondary_2 != "X"
and secondary_1 != secondary_2
):
left, right = secondary_inputs
secondaries_same = left == right or (
check_is_lenient and "X" in (left, right)
)
if not secondaries_same:
expected = False

# Check that actual extracted operation result matches the "expected" one.
Expand Down Expand Up @@ -398,7 +397,15 @@ def test_splitattrs_cases(
)

@pytest.mark.parametrize(
"secondary_values", ["secondaryXX", "secondaryCC", "secondaryCD"]
"secondary_values",
[
"secondaryXX",
"secondaryCX",
"secondaryXC",
"secondaryCC",
"secondaryCD",
]
# NOTE: test CX as well as XC, since primary choices has "AX" but not "XA".
)
def test_splitattrs_global_local_independence(
self,
Expand All @@ -418,10 +425,9 @@ def test_splitattrs_global_local_independence(
Notes
-----
We provide this *separate* test for global/local attribute independence,
parametrized over selected relevant arrangements of the 'secondary' values, and
do not test with reversed order or "local" primary inputs.
This is because matrix testing over *all* relevant factors simply produces too
many possible combinations.
parametrized over selected relevant arrangements of the 'secondary' values.
We *don't* test with reversed order or "local" primary inputs, because matrix
testing over *all* relevant factors produces too many possible combinations.
"""
primary_inputs = primary_values[-2:]
secondary_inputs = secondary_values[-2:]
Expand Down

0 comments on commit dca5dce

Please sign in to comment.