File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
812836if __name__ == "__main__" :
813837 print ("Run date:" , datetime .datetime .now ())
814838 cf .environment ()
You can’t perform that action at this time.
0 commit comments