code: def test_factor_weights(
      self,
      factor_vals,
      tickers,
      groups,
      demeaned,
      group_adjust,
      equal_weight,
      expected_vals,
  ):
      index = date_range("1/12/2000", periods=len(factor_vals))
      factor = DataFrame(
          index=index, columns=tickers, data=factor_vals
      ).stack()
      factor.index = factor.index.set_names(["date", "asset"])
      factor.name = "factor"
  
      factor_data = DataFrame()
      factor_data["factor"] = factor
      groups = Series(groups)
      factor_data["group"] = Series(
          index=factor.index,
          data=groups[factor.index.get_level_values("asset")].values,
      )
  
      weights = factor_weights(
          factor_data, demeaned, group_adjust, equal_weight
      )
  
      expected = Series(
          data=expected_vals, index=factor_data.index, name="factor"
      )
  
      assert_series_equal(weights, expected)
  
imports: from __future__ import division
  from unittest import TestCase
  from parameterized import parameterized
  from numpy import nan
  from pandas import Series, DataFrame, date_range, MultiIndex, Int64Index, Index, DatetimeIndex, Timedelta
  from pandas.tseries.offsets import BDay, Day, CDay
  from pandas.util.testing import assert_frame_equal, assert_series_equal
  from ..performance import factor_information_coefficient, mean_information_coefficient, mean_return_by_quantile, quantile_turnover, factor_rank_autocorrelation, factor_returns, factor_alpha_beta, cumulative_returns, factor_weights, common_start_returns, average_cumulative_return_by_quantile
  from ..utils import get_forward_returns_columns, get_clean_factor_and_forward_returns
label_desc: Use image node_id 5 for calling the PerformanceTestCase obj's underlying member method code with example usage: obj.test_factor_weights(factor_vals, tickers, groups, demeaned, group_adjust, equal_weight, expected_vals) without return types