code: def _gen_expectations(
      baseline,
      missing_value,
      adjustments,
      buffer_as_of,
      nrows,
      perspective_offsets,
  ):
      for windowlen, perspective_offset in product(
          valid_window_lengths(nrows), perspective_offsets
      ):
          # How long is an iterator of length-N windows on this buffer?
          # For example, for a window of length 3 on a buffer of length 6, there
          # are four valid windows.
          num_legal_windows = (
              num_windows_of_length_M_on_buffers_of_length_N(
                  windowlen, nrows
              )
          )
  
          # Build the sequence of regions in the underlying buffer we expect to
          # see. For example, with a window length of 3 on a buffer of length 6,
          # we expect to see:
          #  (buffer[0:3], buffer[1:4], buffer[2:5], buffer[3:6])
          #
          slices = [
              slice(i, i + windowlen) for i in range(num_legal_windows)
          ]
  
          # The sequence of perspectives we expect to take on the underlying
          # data. For example, with a window length of 3 and a perspective offset
          # of 1, we expect to see:
          #  (buffer_as_of[3], buffer_as_of[4], buffer_as_of[5], buffer_as_of[5])
          #
          initial_perspective = windowlen + perspective_offset - 1
          perspectives = range(
              initial_perspective,
              initial_perspective + num_legal_windows,
          )
  
          def as_of(p):
              # perspective_offset can push us past the end of the underlying
              # buffer/adjustments. When it does, we should always see the latest
              # version of the buffer.
              if p >= len(buffer_as_of):
                  return buffer_as_of[-1]
              return buffer_as_of[p]
  
          expected_iterator_results = [
              as_of(perspective)[slice_]
              for slice_, perspective in zip(slices, perspectives)
          ]
  
          test_name = "dtype_{}_length_{}_perpective_offset_{}".format(
              baseline.dtype,
              windowlen,
              perspective_offset,
          )
  
          yield AdjustmentCase(
              name=test_name,
              baseline=baseline,
              window_length=windowlen,
              adjustments=adjustments,
              missing_value=missing_value,
              perspective_offset=perspective_offset,
              expected_result=expected_iterator_results,
          )
  
imports: from collections import namedtuple
  from itertools import chain, product
  from string import ascii_lowercase, ascii_uppercase
  from textwrap import dedent
  from unittest import TestCase
  from nose_parameterized import parameterized
  from numpy import arange, array, asarray, dtype, full
  from six.moves import zip_longest
  from toolz import curry
  from zipline.errors import WindowLengthNotPositive, WindowLengthTooLong
  from zipline.lib.adjustment import Boolean1DArrayOverwrite, BooleanOverwrite, Datetime641DArrayOverwrite, Datetime64Overwrite, Float641DArrayOverwrite, Float64Multiply, Float64Overwrite, Int64Overwrite, Object1DArrayOverwrite, ObjectOverwrite
  from zipline.lib.adjusted_array import AdjustedArray
  from zipline.lib.labelarray import LabelArray
  from zipline.testing import check_arrays
  from zipline.testing.predicates import assert_equal
  from zipline.utils.compat import unicode
  from zipline.utils.numpy_utils import coerce_to_dtype, datetime64ns_dtype, default_missing_value_for_dtype, bool_dtype, float64_dtype, int64_dtype, object_dtype
label_desc: Use image node_id 10 for calling a global function with example usage: _gen_expectations(baseline, missing_value, adjustments, buffer_as_of, nrows, perspective_offsets) and returns: buffer_as_of, buffer_as_of