code: def test_minute_splits_and_mergers(self):
      # self.SPLIT_ASSET and self.MERGER_ASSET had splits/mergers
      # on 1/6 and 1/7
  
      jan5 = pd.Timestamp("2015-01-05", tz="UTC")
  
      # the assets' close column starts at 2 on the first minute of
      # 1/5, then goes up one per minute forever
  
      for asset in [self.SPLIT_ASSET, self.MERGER_ASSET]:
          # before any of the adjustments, last 10 minutes of jan 5
          equity_cal = self.trading_calendars[Equity]
          window1 = self.data_portal.get_history_window(
              [asset],
              equity_cal.open_and_close_for_session(jan5)[1],
              10,
              "1m",
              "close",
              "minute",
          )[asset]
  
          np.testing.assert_array_equal(
              np.array(range(8380, 8390)), window1
          )
  
          # straddling the first event - begins with the last 5 equity
          # minutes on 2015-01-05, ends with the first 5 on
          # 2015-01-06.
          window2_start = pd.Timestamp("2015-01-05 20:56", tz="UTC")
          window2_end = pd.Timestamp("2015-01-06 14:35", tz="UTC")
          window2_count = len(
              self.trading_calendar.minutes_in_range(
                  window2_start,
                  window2_end,
              )
          )
          window2 = self.data_portal.get_history_window(
              [asset],
              pd.Timestamp("2015-01-06 14:35", tz="UTC"),
              window2_count,
              "1m",
              "close",
              "minute",
          )[asset]
  
          # five minutes from 1/5 should be halved
          np.testing.assert_array_equal(
              [2096.25, 2096.5, 2096.75, 2097, 2097.25],
              window2[:5],
          )
          # Split occurs. The value of the thousands place should
          # match.
          np.testing.assert_array_equal(
              [2000, 2001, 2002, 2003, 2004],
              window2[-5:],
          )
  
          # straddling both events! on the equities calendar this is 5
          # minutes of 1/7, 390 of 1/6, and 5 minutes of 1/5.
          window3_start = pd.Timestamp("2015-01-05 20:56", tz="UTC")
          window3_end = pd.Timestamp("2015-01-07 14:35", tz="UTC")
          window3_minutes = self.trading_calendar.minutes_in_range(
              window3_start,
              window3_end,
          )
          window3_count = len(window3_minutes)
          window3 = self.data_portal.get_history_window(
              [asset],
              pd.Timestamp("2015-01-07 14:35", tz="UTC"),
              window3_count,
              "1m",
              "close",
              "minute",
          )[asset]
  
          # first five minutes should be 4385-4390, but eigthed
          np.testing.assert_array_equal(
              [1048.125, 1048.25, 1048.375, 1048.5, 1048.625],
              window3[0:5],
          )
  
          # next 390 minutes (the 2015-01-06 session) should be
          # 2000-2390, but halved
          middle_day_open_i = window3_minutes.searchsorted(
              pd.Timestamp("2015-01-06 14:31", tz="UTC")
          )
          middle_day_close_i = window3_minutes.searchsorted(
              pd.Timestamp("2015-01-06 21:00", tz="UTC")
          )
          np.testing.assert_array_equal(
              np.array(range(2000, 2390), dtype="float64") / 2,
              window3[middle_day_open_i : middle_day_close_i + 1],
          )
  
          # final 5 minutes should be 1000-1004
          np.testing.assert_array_equal(range(1000, 1005), window3[-5:])
  
          # after last event
          window4 = self.data_portal.get_history_window(
              [asset],
              pd.Timestamp("2015-01-07 14:40", tz="UTC"),
              5,
              "1m",
              "close",
              "minute",
          )[asset]
  
          # should not be adjusted, should be 1005 to 1009
          np.testing.assert_array_equal(range(1005, 1010), window4)
  
imports: from textwrap import dedent
  from nose_parameterized import parameterized
  import numpy
  from numpy import nan
  import pandas
  from six import iteritems
  from catalyst import TradingAlgorithm
  from catalyst._protocol import handle_non_market_minutes, BarData
  from catalyst.assets import Asset, Equity
  from catalyst.errors import HistoryInInitialize, HistoryWindowStartsBeforeData
  from catalyst.finance.trading import SimulationParameters
  from catalyst.finance.asset_restrictions import NoRestrictions
  from catalyst.testing import create_minute_df_for_asset, str_to_seconds, MockDailyBarReader
  from catalyst.testing.fixtures import WithCreateBarData, WithDataPortal, CatalystTestCase, alias
label_desc: Use image node_id 9 for calling the MinuteEquityHistoryTestCase obj's underlying member method code with example usage: obj.test_minute_splits_and_mergers() without return types