Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,18 @@ def coord_dims(self, coord):
The :class:`iris.coords.Coord` instance to look for.

"""
target_defn = coord._as_defn()

### Search by coord definition first
# Search for existing coordinate (object) on the cube, faster lookup
# than equality - makes no functional difference.
matches = [(dim,) for coord_, dim in self._dim_coords_and_dims if
coord_ is coord]
if not matches:
matches = [dims for coord_, dims in self._aux_coords_and_dims if
coord_ is coord]
if matches:
return matches[0]

## Search by coord definition (slow)
target_defn = coord._as_defn()
# Search dim coords first
matches = [(dim,) for coord_, dim in self._dim_coords_and_dims if
coord_._as_defn() == target_defn]
Expand Down