class_docstr: Module stitches histograms by date
docstr: Add delta hist to hist_basis at time-value
  
  :param hbasis: basis histogram with time-axis
  :param hdelta_list: delta histogram without time-axis
  :param time_bin_idx: list of time-value at which to insert hdeltas into hbasis
  :param str mode: options for histogram stitching: "add" or "replace". default is "add".
  :return: stitched hbasis histogram
docstr_tok: ["Add","delta","hist","to","hist_basis","at","time-value",":","param","hbasis",":","basis","histogram","with","time-axis",":","param","hdelta_list",":","delta","histogram","without","time-axis",":","param","time_bin_idx",":","list","of","time-value","at","which","to","insert","hdeltas","into","hbasis",":","param","str","mode",":","options","for","histogram","stitching",":","``","add","''","or","``","replace","''",".","default","is","``","add","''",".",":","return",":","stitched","hbasis","histogram"]
code: def _insert_hists(self, hbasis, hdelta_list, time_bin_idx, mode):
      """Add delta hist to hist_basis at time-value
  
      :param hbasis: basis histogram with time-axis
      :param hdelta_list: delta histogram without time-axis
      :param time_bin_idx: list of time-value at which to insert hdeltas into hbasis
      :param str mode: options for histogram stitching: "add" or "replace". default is "add".
      :return: stitched hbasis histogram
      """
      # basic checks on time-values
      if len(hdelta_list) != len(time_bin_idx) or len(hdelta_list) == 0:
          raise ValueError(
              "hdelta_list and time_bin_idx should be filled and same size."
          )
      dts = [type(tv) for tv in time_bin_idx]
      if not dts.count(dts[0]) == len(dts):
          raise TypeError(
              f"time_bin_idxs have inconsistent datatypes: {dts}"
          )
      if not isinstance(time_bin_idx[0], (str, int, np.integer)):
          raise TypeError(
              "time_bin_idxs should be an (ordered) string or integer."
          )
  
      # consistency checks on histogram definitions
      if not hasattr(hbasis, "bins"):
          raise ValueError(
              "basis histogram does not have bins attribute. cannot insert."
          )
      if len(hbasis.bins) > 0:
          hbk0 = list(hbasis.bins.values())[0]
          assert_similar_hists([hbk0, *hdelta_list])
      else:
          assert_similar_hists(hdelta_list)
  
      # check consistency of hbasis and time-value type
      if isinstance(time_bin_idx[0], str):
          if not isinstance(hbasis, hg.Categorize):
              raise TypeError(
                  "hbasis does not accept string time-values."
              )
      elif isinstance(
          time_bin_idx[0], (int, np.integer)
      ) and not isinstance(hbasis, hg.SparselyBin):
          raise TypeError("hbasis does not accept integer time-values.")
  
      # stitch all the hdeltas into hbasis
      hsum = hbasis.copy()
  
      for tv, hdelta in zip(time_bin_idx, hdelta_list):
          if tv in hsum.bins:
              # replace or sum?
              hbt = hsum.bins[tv]
              hbt_entries = hbt.entries
              if mode == "replace":
                  hsum.bins[tv] = hdelta
                  hsum.entries += hdelta.entries - hbt_entries
              else:
                  hsum.bins[tv] += hdelta
                  hsum.entries += hdelta.entries
          else:
              # insert at time_bin_idx
              hsum.bins[tv] = hdelta
              hsum.entries += hdelta.entries
  
      return hsum
  
file_path: popmon/popmon/stitching/hist_stitcher.py
imports: import histogrammar
  import numpy
  from popmon.analysis.hist_numpy import assert_similar_hists
  from popmon.base import Module
label_desc: Use image node_id 7 for calling the HistStitcher obj's underlying member method code with example usage: obj._insert_hists(hbasis, hdelta_list, time_bin_idx, mode) and returns: hsum