Skip to content

Coord.is_contiguous() assumes too much #423

@pelson

Description

@pelson

The is_contiguous method assumes that the lower bound is in index 0, but when you reverse a coordinate, it is usually in index 1. Because of this:

>>> from iris.coords import DimCoord
>>> c = DimCoord(tuple(range(10)), 'latitude')
>>> c.is_contiguous()
False
>>> c.guess_bounds()
>>> c.is_contiguous()
True
>>> c[::-1].is_contiguous()
False
>>> c[::-1].bounds         
array([[ 8.5,  9.5],
       [ 7.5,  8.5],
       [ 6.5,  7.5],
       [ 5.5,  6.5],
       [ 4.5,  5.5],
       [ 3.5,  4.5],
       [ 2.5,  3.5],
       [ 1.5,  2.5],
       [ 0.5,  1.5],
       [-0.5,  0.5]])

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions