docstr: Given a Dataset object and a dictionary with dimension keys and
  selection keys (i.e. tuple ranges, slices, sets, lists, or literals)
  return a boolean mask over the rows in the Dataset object that
  have been selected.
docstr_tok: ["Given","a","Dataset","object","and","a","dictionary","with","dimension","keys","and","selection","keys","(","i.e",".","tuple","ranges",",","slices",",","sets",",","lists",",","or","literals",")","return","a","boolean","mask","over","the","rows","in","the","Dataset","object","that","have","been","selected","."]
code: def select_mask(cls, dataset, selection):
      """
      Given a Dataset object and a dictionary with dimension keys and
      selection keys (i.e. tuple ranges, slices, sets, lists, or literals)
      return a boolean mask over the rows in the Dataset object that
      have been selected.
      """
      mask = np.ones(len(dataset), dtype=np.bool_)
      for dim, sel in selection.items():
          if isinstance(sel, tuple):
              sel = slice(*sel)
          arr = cls.values(dataset, dim)
          if util.isdatetime(arr):
              try:
                  sel = util.parse_datetime_selection(sel)
              except Exception:
                  pass
          if isinstance(sel, slice):
              with warnings.catch_warnings():
                  warnings.filterwarnings(
                      "ignore", r"invalid value encountered"
                  )
                  if sel.start is not None:
                      mask &= sel.start <= arr
                  if sel.stop is not None:
                      mask &= arr < sel.stop
          elif isinstance(sel, (set, list)):
              iter_slcs = []
              for ik in sel:
                  with warnings.catch_warnings():
                      warnings.filterwarnings(
                          "ignore", r"invalid value encountered"
                      )
                      iter_slcs.append(arr == ik)
              mask &= np.logical_or.reduce(iter_slcs)
          elif callable(sel):
              mask &= sel(arr)
          else:
              index_mask = arr == sel
              if dataset.ndims == 1 and np.sum(index_mask) == 0:
                  data_index = np.argmin(np.abs(arr - sel))
                  mask = np.zeros(len(dataset), dtype=np.bool_)
                  mask[data_index] = True
              else:
                  mask &= index_mask
      return mask
  
imports: import sys
  import warnings
  import numpy
  import param
  from ..None import util
  from ..element import Element
  from ..ndmapping import NdMapping
  from .util import finite_range
label_desc: Use image node_id 15 for calling the Interface obj's underlying member method code with example usage: obj.select_mask(cls, dataset, selection) and returns: mask