Skip to content

Commit 81468ec

Browse files
Luke Carrollcorinnebosley
authored andcommitted
Removed class iris.fileformats.rules.CoordAndDims (#2791)
* Removed class iris.fileformats.rules.CoordAndDims * Removed code and comment referring to CoordAndDims. * Changed elif to if now all tests pass.
1 parent 9f73e45 commit 81468ec

File tree

1 file changed

+3
-49
lines changed

1 file changed

+3
-49
lines changed

lib/iris/fileformats/rules.py

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -155,50 +155,6 @@ def __init__(self, name, value):
155155
self.value = value
156156

157157

158-
class CoordAndDims(object):
159-
"""
160-
Used within rules to represent a mapping of coordinate to data dimensions.
161-
162-
.. deprecated:: 1.10
163-
164-
"""
165-
def __init__(self, coord, dims=None):
166-
warn_deprecated(
167-
"the `iris.fileformats.rules.CoordAndDims class is deprecated.")
168-
self.coord = coord
169-
if dims is None:
170-
dims = []
171-
if not isinstance(dims, list):
172-
dims = [dims]
173-
self.dims = dims
174-
175-
def add_coord(self, cube):
176-
added = False
177-
178-
# Try to add to dim_coords?
179-
if isinstance(self.coord, iris.coords.DimCoord) and self.dims:
180-
if len(self.dims) > 1:
181-
raise Exception("Only 1 dim allowed for a DimCoord")
182-
183-
# Does the cube already have a coord for this dim?
184-
already_taken = False
185-
for coord, coord_dim in cube._dim_coords_and_dims:
186-
if coord_dim == self.dims[0]:
187-
already_taken = True
188-
break
189-
190-
if not already_taken:
191-
cube.add_dim_coord(self.coord, self.dims[0])
192-
added = True
193-
194-
# If we didn't add it to dim_coords, add it to aux_coords.
195-
if not added:
196-
cube.add_aux_coord(self.coord, self.dims)
197-
198-
def __repr__(self):
199-
return "<CoordAndDims: %r, %r>" % (self.coord.name, self.dims)
200-
201-
202158
class Reference(iris.util._OrderedHashable):
203159
_names = ('name',)
204160
"""
@@ -364,13 +320,11 @@ def _process_action_result(self, obj, cube):
364320

365321
factory = None
366322

367-
# NB. The names such as 'CoordAndDims' and 'CellMethod' are defined by
368-
# the "deferred import" performed by Rule.run_actions() above.
369-
if isinstance(obj, CoordAndDims):
370-
obj.add_coord(cube)
323+
# NB. The names such as 'CellMethod' are defined by the
324+
# "deferred import" performed by Rule.run_actions() above.
371325

372326
#cell methods - not yet implemented
373-
elif isinstance(obj, CellMethod):
327+
if isinstance(obj, CellMethod):
374328
cube.add_cell_method(obj)
375329

376330
elif isinstance(obj, CMAttribute):

0 commit comments

Comments
 (0)