Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhassell committed Feb 19, 2024
1 parent eb779fb commit 233416e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ version 3.17.0
* Fix bug that caused `cf.Field.del_file_location` to fail when
updating its metdata constructs
(https://github.com/NCAS-CMS/cf-python/issues/707)
* Fix bug that caused incorrect data arrays in some cyclic subspaces
created by `cf.Field.subspace` and `cf.Field.__getitem__`
(https://github.com/NCAS-CMS/cf-python/issues/713)

version 3.16.0
--------------
Expand Down
4 changes: 3 additions & 1 deletion cf/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@ def __getitem__(self, indices):
f"{self.constructs.domain_axis_identity(_)!r} axis"
)

new = new.roll(shift=shift, axis=iaxis)
new = new.roll(axis=iaxis, shift=shift)
else:
new = self.copy()

data = new.data

# ------------------------------------------------------------
# Subspace the field construct's data
# ------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions cf/test/test_Field.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,13 @@ def test_Field__getitem__(self):
with self.assertRaises(IndexError):
f[..., [False] * f.shape[-1]]

# Test with cyclic subspace
f.cyclic("grid_longitude")
g = f[:, -3:-5:1]
self.assertEqual(g.shape, (10, 7))
self.assertTrue(np.allclose(f[:, -3:].array, g[:, :3].array))
self.assertTrue(f[:, :4].equals(g[:, 3:]))

def test_Field__setitem__(self):
f = self.f.copy().squeeze()

Expand Down

0 comments on commit 233416e

Please sign in to comment.