Ensure get_dimension does not match Dimensions with mismatching spec
@@ -961,8 +961,18 @@ class Dimensioned(LabelledData):
raise KeyError("Dimension %r not found" % dimension)
else:
return default
+
+ if isinstance(dimension, Dimension):
+ dims = [d for d in all_dims if dimension == d]
+ if strict and not dims:
+ raise KeyError("Dimension %r not found." % dimension)
+ elif dims:
+ return dims[0]
+ else:
+ return None
+ else:
dimension = dimension_name(dimension)
- name_map = {dim.name: dim for dim in all_dims}
+ name_map = {dim.spec: dim for dim in all_dims}
name_map.update({dim.label: dim for dim in all_dims})
name_map.update({util.dimension_sanitizer(dim.name): dim for dim in all_dims})
if strict and dimension not in name_map:
