diff --git a/cf/data/data.py b/cf/data/data.py index 725327862b..a7a37484d6 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -10884,7 +10884,7 @@ def flip(self, axes=None, inplace=False, i=False): """ d = _inplace_enabled_define_and_cleanup(self) - if axes is not None and not axes and axes != 0: + if axes is not None and not axes and axes != 0: # i.e. empty sequence return d if axes is None: @@ -10896,7 +10896,8 @@ def flip(self, axes=None, inplace=False, i=False): return d index = [ - slice(None, None, -1) if i in axes else slice(None) for i in iaxes + slice(None, None, -1) if i in iaxes else slice(None) + for i in range(d.ndim) ] dx = d._get_dask() diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index dce232d79e..1ac278d174 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -1788,7 +1788,6 @@ def test_Data_datum(self): self.assertIs(d.datum([0, -1]), cf.masked) self.assertIs(d.datum(-1, -1), cf.masked) - @unittest.skipIf(TEST_DASKIFIED_ONLY, "TypeError: 'int' is not iterable") def test_Data_flip(self): if self.test_only and inspect.stack()[0][3] not in self.test_only: return @@ -1810,10 +1809,8 @@ def test_Data_flip(self): self.assertTrue((d.array == array).all()) array = np.arange(3 * 4 * 5).reshape(3, 4, 5) + 1 - d = cf.Data(array.copy(), "metre", chunk=False) - d.chunk(total=[0], omit_axes=[1, 2]) + d = cf.Data(array.copy(), "metre", chunks=-1) - self.assertEqual(d._pmshape, (3,)) self.assertEqual(d[0].shape, (1, 4, 5)) self.assertEqual(d[-1].shape, (1, 4, 5)) self.assertEqual(d[0].maximum(), 4 * 5) @@ -1821,7 +1818,6 @@ def test_Data_flip(self): for i in (2, 1): e = d.flip(i) - self.assertEqual(e._pmshape, (3,)) self.assertEqual(e[0].shape, (1, 4, 5)) self.assertEqual(e[-1].shape, (1, 4, 5)) self.assertEqual(e[0].maximum(), 4 * 5) @@ -1829,7 +1825,6 @@ def test_Data_flip(self): i = 0 e = d.flip(i) - self.assertEqual(e._pmshape, (3,)) self.assertEqual(e[0].shape, (1, 4, 5)) self.assertEqual(e[-1].shape, (1, 4, 5)) self.assertEqual(e[0].maximum(), 3 * 4 * 5)