class_docstr: Mixin class for Cartesian 2D elements to add basic support for
  SelectionExpr streams.
class_docstr_tok: ["Mixin","class","for","Cartesian","2D","elements","to","add","basic","support","for","SelectionExpr","streams","."]
code: def _get_bounds_selection(self, xdim, ydim, **kwargs):
      from .geom import Rectangles
  
      (x0, x1), xcats, (y0, y1), ycats = self._get_selection(**kwargs)
      xsel = xcats or (x0, x1)
      ysel = ycats or (y0, y1)
  
      bbox = {xdim.name: xsel, ydim.name: ysel}
      index_cols = kwargs.get("index_cols")
      if index_cols:
          selection = self.dataset.clone(
              datatype=["dataframe", "dictionary"]
          ).select(**bbox)
          selection_expr = self._get_index_expr(index_cols, selection)
          region_element = None
      else:
          if xcats:
              xexpr = dim(xdim).isin(xcats)
          else:
              xexpr = (dim(xdim) >= x0) & (dim(xdim) <= x1)
          if ycats:
              yexpr = dim(ydim).isin(ycats)
          else:
              yexpr = (dim(ydim) >= y0) & (dim(ydim) <= y1)
          selection_expr = xexpr & yexpr
          region_element = Rectangles([(x0, y0, x1, y1)])
      return selection_expr, bbox, region_element
  
imports: import sys
  import numpy
  import pandas
  from ..core import Dataset, NdOverlay, util
  from ..streams import Lasso, Selection1D, SelectionXY
  from ..util.transform import dim
  from .annotation import HSpan, VSpan
label_desc: Use image node_id 4 for calling the Selection2DExpr obj's underlying member method code with example usage: obj._get_bounds_selection(xdim, ydim) and returns: selection_expr,  bbox,  region_element