code: def get_multiplier(weights, root_generic_multiplier):
      if len(root_generic_multiplier) > 1 and not isinstance(weights, dict):
          raise ValueError("For multiple generic instruments weights must be a "
                           "dictionary")
      mults = []
      intrs = []
      for ast, multiplier in root_generic_multiplier.iteritems():
          if isinstance(weights, dict):
              weights_ast = weights[ast].index
          else:
              weights_ast = weights.index
          mults.extend(np.repeat(multiplier, len(weights_ast)))
          intrs.extend(weights_ast)
      imults = pd.Series(mults, intrs)
      imults = imults.sort_index()
      return imults