code: def test_interp_limit_to_ends(self):
      # These test are for issue #10420 -- flow back to beginning.
      s = Series([np.nan, np.nan, 5, 7, 9, np.nan])
  
      expected = Series([5.0, 5.0, 5.0, 7.0, 9.0, np.nan])
      result = s.interpolate(
          method="linear", limit=2, limit_direction="backward"
      )
      tm.assert_series_equal(result, expected)
  
      expected = Series([5.0, 5.0, 5.0, 7.0, 9.0, 9.0])
      result = s.interpolate(
          method="linear", limit=2, limit_direction="both"
      )
      tm.assert_series_equal(result, expected)
  
imports: import numpy
  import pytest
  import pandas.util._test_decorators
  import pandas
  from pandas import Index, MultiIndex, Series, date_range, isna
  import pandas._testing
label_desc: Use image node_id 30 for calling the TestSeriesInterpolateData obj's underlying member method code with example usage: obj.test_interp_limit_to_ends() without return types