code: def subset(data, sel0=None, sel1=None, blen=None, storage=None, create='array',
             **kwargs):
      
  
      # TODO refactor sel0 and sel1 normalization with ndarray.subset
  
      # setup
      storage = _util.get_storage(storage)
      blen = _util.get_blen_array(data, blen)
      length = len(data)
      if sel0 is not None:
          sel0 = np.asanyarray(sel0)
      if sel1 is not None:
          sel1 = np.asanyarray(sel1)
  
      # ensure boolean array for dim 0
      if sel0 is not None and sel0.dtype.kind != 'b':
          # assume indices, convert to boolean condition
          tmp = np.zeros(length, dtype=bool)
          tmp[sel0] = True
          sel0 = tmp
  
      # ensure indices for dim 1
      if sel1 is not None and sel1.dtype.kind == 'b':
          # assume boolean condition, convert to indices
          sel1, = np.nonzero(sel1)
  
      # shortcuts
      if sel0 is None and sel1 is None:
          return copy(data, blen=blen, storage=storage, create=create, **kwargs)
      elif sel1 is None:
          return compress(sel0, data, axis=0, blen=blen, storage=storage,
                          create=create, **kwargs)
      elif sel0 is None:
          return take(data, sel1, axis=1, blen=blen, storage=storage,
                      create=create, **kwargs)
  
      # build output
      sel0_nnz = count_nonzero(sel0)
      out = None
      for i in range(0, length, blen):
          j = min(i+blen, length)
          bsel0 = sel0[i:j]
          # don't access data unless we have to
          if np.any(bsel0):
              block = data[i:j]
              res = _numpy_subset(block, bsel0, sel1)
              if out is None:
                  out = getattr(storage, create)(res, expectedlen=sel0_nnz,
                                                 **kwargs)
              else:
                  out.append(res)
  
      return out
docs: Return selected rows and columns of an array.