code: def test_compute_forward_returns(self):
      dr = date_range(start="2015-1-1", end="2015-1-3")
      prices = DataFrame(
          index=dr, columns=["A", "B"], data=[[1, 1], [1, 2], [2, 1]]
      )
      factor = prices.stack()
  
      fp = compute_forward_returns(factor, prices, periods=[1, 2])
  
      ix = MultiIndex.from_product(
          [dr, ["A", "B"]], names=["date", "asset"]
      )
      expected = DataFrame(index=ix, columns=["1D", "2D"])
      expected["1D"] = [0.0, 1.0, 1.0, -0.5, nan, nan]
      expected["2D"] = [1.0, 0.0, nan, nan, nan, nan]
  
      assert_frame_equal(fp, expected)
  
file_path: alphalens/alphalens/tests/test_utils.py
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, Timedelta, Timestamp, concat
  from pandas.util.testing import assert_frame_equal, assert_series_equal
  from ..utils import get_clean_factor_and_forward_returns, compute_forward_returns, quantize_factor
label_desc: Use image node_id 1 for calling the UtilsTestCase obj's underlying member method code with example usage: obj.test_compute_forward_returns() without return types