docs: def build_agg_vec(agg_vec, **source):
      """ Builds an combined aggregation vector based on various classifications
  
      This function build an aggregation vector based on the order in agg_vec.
      The naming and actual mapping is given in source, either explicitly or by
      pointing to a folder with the mapping.
  
      >>> build_agg_vec(['EU', 'OECD'], path = 'test')
      ['EU', 'EU', 'EU', 'OECD', 'REST', 'REST']
  
      >>> build_agg_vec(['OECD', 'EU'], path = 'test', miss='RoW')
      ['OECD', 'EU', 'OECD', 'OECD', 'RoW', 'RoW']
  
      >>> build_agg_vec(['EU', 'orig_regions'], path = 'test')
      ['EU', 'EU', 'EU', 'reg4', 'reg5', 'reg6']
  
      >>> build_agg_vec(['supreg1', 'other'], path = 'test',
      >>>        other = [None, None, 'other1', 'other1', 'other2', 'other2'])
      ['supreg1', 'supreg1', 'other1', 'other1', 'other2', 'other2']
  
  
      Parameters
      ----------
      agg_vec : list
          A list of sector or regions to which the IOSystem shall be aggregated.
          The order in agg_vec is important:
          If a string was assigned to one specific entry it will not be
          overwritten if it is given in the next vector, e.g.  ['EU', 'OECD']
          would aggregate first into EU and the remaining one into OECD, whereas
          ['OECD', 'EU'] would first aggregate all countries into OECD and than
          the remaining countries into EU.
  
      source : list or string
          Definition of the vectors in agg_vec.  The input vectors (either in the
          file or given as list for the entries in agg_vec) must be as long as
          the desired output with a string for every position which should be
          aggregated and None for position which should not be used.
  
          Special keywords:
  
              - path : Path to a folder with concordance matrices.
                       The files in the folder can have any extension but must be
                       in text format (tab separated) with one entry per row.
                       The last column in the file will be taken as aggregation
                       vectors (other columns can be used for documentation).
                       Values must be given for every entry in the original
                       classification (string None for all values not used) If
                       the same entry is given in source and as text file in
                       path than the one in source will be used.
  
                       Two special path entries are available so far:
  
                       - 'exio2'
                         Concordance matrices for EXIOBASE 2.0
                       - 'test'
                         Concordance matrices for the test IO system
  
                       If a entry is not found in source and no path is given
                       the current directory will be searched for the definition.
  
              - miss : Entry to use for missing values, default: 'REST'
  
      Returns
      -------
      list (aggregation vector)
  
      """
  
      # build a dict with aggregation vectors in source and folder
      if type(agg_vec) is str:
          agg_vec = [agg_vec]
      agg_dict = dict()
      for entry in agg_vec:
          try:
              agg_dict[entry] = source[entry]
          except KeyError:
              folder = source.get('path', './')
              folder = os.path.join(PYMRIO_PATH[folder], 'concordance')
              for file in os.listdir(folder):
                  if entry == os.path.splitext(file)[0]:
                      _tmp = np.genfromtxt(os.path.join(folder, file), dtype=str)
                      if _tmp.ndim == 1:
                          agg_dict[entry] = [None if ee == 'None'
                                             else ee for ee in _tmp.tolist()]
                      else:
                          agg_dict[entry] = [None if ee == 'None'
                                             else ee
                                             for ee in _tmp[:, -1].tolist()]
                      break
              else:
                  logging.error(
                          'Aggregation vector -- {} -- not found'
                          .format(str(entry)))
  
      # build the summary aggregation vector
      def _rep(ll, ii, vv): ll[ii] = vv
      miss_val = source.get('miss', 'REST')
  
      vec_list = [agg_dict[ee] for ee in agg_vec]
      out = [None, ] * len(vec_list[0])
      for currvec in vec_list:
          if len(currvec) != len(out):
              logging.warn('Inconsistent vector length')
          [_rep(out, ind, val) for ind, val in
           enumerate(currvec) if not out[ind]]
  
      [_rep(out, ind, miss_val) for ind, val in enumerate(out) if not val]
  
      return out