docs: def roller(timestamps, contract_dates, get_weights, **kwargs):
      """
      Calculate weight allocations to tradeable instruments for generic futures
      at a set of timestamps for a given root generic.
  
      Paramters
      ---------
      timestamps: iterable
          Sorted iterable of of pandas.Timestamps to calculate weights for
      contract_dates: pandas.Series
          Series with index of tradeable contract names and pandas.Timestamps
          representing the last date of the roll as values, sorted by values.
          Index must be unique and values must be strictly monotonic.
      get_weights: function
          A function which takes in a timestamp, contract_dates, validate_inputs
          and **kwargs. Returns a list of tuples consisting of the generic
          instrument name, the tradeable contract as a string, the weight on this
          contract as a float and the date as a pandas.Timestamp.
      kwargs: keyword arguments
          Arguements to pass to get_weights
  
      Return
      ------
      A pandas.DataFrame with columns representing generics and a MultiIndex of
      date and contract. Values represent weights on tradeables for each generic.
  
      Examples
      --------
      >>> import pandas as pd
      >>> import mapping.mappings as mappings
      >>> cols = pd.MultiIndex.from_product([["CL1", "CL2"], ['front', 'back']])
      >>> idx = [-2, -1, 0]
      >>> trans = pd.DataFrame([[1.0, 0.0, 1.0, 0.0], [0.5, 0.5, 0.5, 0.5],
      ...                       [0.0, 1.0, 0.0, 1.0]], index=idx, columns=cols)
      >>> contract_dates = pd.Series([pd.Timestamp('2016-10-20'),
      ...                             pd.Timestamp('2016-11-21'),
      ...                             pd.Timestamp('2016-12-20')],
      ...                            index=['CLX16', 'CLZ16', 'CLF17'])
      >>> ts = pd.DatetimeIndex([pd.Timestamp('2016-10-18'),
      ...                        pd.Timestamp('2016-10-19'),
      ...                        pd.Timestamp('2016-10-19')])
      >>> wts = mappings.roller(ts, contract_dates, mappings.static_transition,
      ...                       transition=trans)
      """
      timestamps = sorted(timestamps)
      contract_dates = contract_dates.sort_values()
      _check_contract_dates(contract_dates)
      weights = []
      # for loop speedup only validate inputs the first function call to
      # get_weights()
      validate_inputs = True
      ts = timestamps[0]
      weights.extend(get_weights(ts, contract_dates,
                                 validate_inputs=validate_inputs, **kwargs))
      validate_inputs = False
      for ts in timestamps[1:]:
          weights.extend(get_weights(ts, contract_dates,
                                     validate_inputs=validate_inputs, **kwargs))
  
      weights = aggregate_weights(weights)
      return weights