Skip to content

Commit 20ca1bb

Browse files
committed
review actions
1 parent c94d2cd commit 20ca1bb

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ def _filter_compression_calls(patch, compression_kwargs, mismatch=False):
181181
result = []
182182
for call in patch.call_args_list:
183183
kwargs = call.kwargs
184-
if (
185-
all(kwargs.get(k) == v for k, v in compression_kwargs.items())
186-
or mismatch
187-
):
184+
if all(kwargs.get(k) == v for k, v in compression_kwargs.items()):
185+
if not mismatch:
186+
result.append(call.args[0])
187+
elif mismatch:
188188
result.append(call.args[0])
189189
return result
190190

@@ -310,11 +310,11 @@ def test_non_compression__shape(self):
310310
result = self._filter_compression_calls(
311311
patch, compression_kwargs, mismatch=True
312312
)
313-
self.assertEqual(5, len(result))
314-
self.assertEqual(
315-
{cube.name(), aux_coord.name(), anc_coord.name(), "dim0", "dim0_bnds"},
316-
set(result),
317-
)
313+
self.assertEqual(4, len(result))
314+
# the aux coord and ancil variable are not compressed due to shape, and
315+
# the dim coord and its associated bounds are also not compressed
316+
expected = {aux_coord.name(), anc_coord.name(), "dim0", "dim0_bnds"}
317+
self.assertEqual(expected, set(result))
318318

319319
def test_non_compression__dtype(self):
320320
cube = self._simple_cube(">f4")
@@ -344,10 +344,11 @@ def test_non_compression__dtype(self):
344344
result = self._filter_compression_calls(
345345
patch, compression_kwargs, mismatch=True
346346
)
347-
self.assertEqual(4, len(result))
348-
self.assertEqual(
349-
{cube.name(), aux_coord.name(), "dim0", "dim0_bnds"}, set(result)
350-
)
347+
self.assertEqual(3, len(result))
348+
# the aux coord is not compressed due to its string dtype, and
349+
# the dim coord and its associated bounds are also not compressed
350+
expected = {aux_coord.name(), "dim0", "dim0_bnds"}
351+
self.assertEqual(expected, set(result))
351352

352353
def test_least_significant_digit(self):
353354
cube = Cube(

0 commit comments

Comments
 (0)