@@ -1586,15 +1586,15 @@ def get_bounds_dim_name(self, key: str) -> str:
1586
1586
assert self ._obj .sizes [bounds_dim ] in [2 , 4 ]
1587
1587
return bounds_dim
1588
1588
1589
- def add_bounds (self , dims : Union [Hashable , Iterable [Hashable ]]):
1589
+ def add_bounds (self , keys : Union [str , Iterable [str ]]):
1590
1590
"""
1591
1591
Returns a new object with bounds variables. The bounds values are guessed assuming
1592
1592
equal spacing on either side of a coordinate label.
1593
1593
1594
1594
Parameters
1595
1595
----------
1596
- dims : Hashable or Iterable[Hashable ]
1597
- Either a single dimension name or a list of dimension names .
1596
+ keys : str or Iterable[str ]
1597
+ Either a single key or a list of keys corresponding to dimensions .
1598
1598
1599
1599
Returns
1600
1600
-------
@@ -1609,12 +1609,16 @@ def add_bounds(self, dims: Union[Hashable, Iterable[Hashable]]):
1609
1609
The bounds variables are automatically named f"{dim}_bounds" where ``dim``
1610
1610
is a dimension name.
1611
1611
"""
1612
- if isinstance (dims , Hashable ):
1613
- dimensions = (dims ,)
1614
- else :
1615
- dimensions = dims
1612
+ if isinstance (keys , str ):
1613
+ keys = [keys ]
1614
+
1615
+ dimensions = set ()
1616
+ for key in keys :
1617
+ dimensions |= set (
1618
+ apply_mapper (_get_dims , self ._obj , key , error = False , default = [key ])
1619
+ )
1616
1620
1617
- bad_dims : Set [Hashable ] = set ( dimensions ) - set (self ._obj .dims )
1621
+ bad_dims : Set [str ] = dimensions - set (self ._obj .dims )
1618
1622
if bad_dims :
1619
1623
raise ValueError (
1620
1624
f"{ bad_dims !r} are not dimensions in the underlying object."
0 commit comments