Skip to content

Commit 0e24f3b

Browse files
committed
add test for cf.DimensionCoordinate.direction
1 parent e01dbd9 commit 0e24f3b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cf/test/test_DimensionCoordinate.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,30 @@ def test_DimensionCoordinate_anchor(self):
809809
self.assertEqual(e[0].array, d[0].array - 360)
810810

811811

812+
def test_DimensionCoordinate_direction(self):
813+
"""Test DimensionCoordinate.direction"""
814+
d = self.dim.copy()
815+
816+
# Test the use case of
817+
# https://github.com/NCAS-CMS/cf-python/issues/859
818+
#
819+
# Create a coordinate with all equal values
820+
d.data[...] = d[0].array
821+
for i, x in enumerate(d.array):
822+
d.bounds.data[i, :] = x
823+
824+
d._custom["direction"] = None # Force a re-calculation of direction
825+
self.assertTrue(d.direction())
826+
d._custom["direction"] = None
827+
self.assertTrue(d[0].direction())
828+
829+
d.del_bounds()
830+
d._custom["direction"] = None
831+
self.assertTrue(d.direction())
832+
d._custom["direction"] = None
833+
self.assertTrue(d[0].direction())
834+
835+
812836
if __name__ == "__main__":
813837
print("Run date:", datetime.datetime.now())
814838
cf.environment()

0 commit comments

Comments
 (0)