code: def _gen_overwrite_adjustment_cases(dtype):
      """
      Generate test cases for overwrite adjustments.
  
      The algorithm used here is the same as the one used above for
      multiplicative adjustments.  The only difference is the semantics of how
      the adjustments are expected to modify the arrays.
  
      This is parameterized on `make_input` and `make_expected_output` functions,
      which take 2-D lists of values and transform them into desired input/output
      arrays. We do this so that we can easily test both vanilla numpy ndarrays
      and our own LabelArray class for strings.
      """
      adjustment_type = {
          float64_dtype: Float64Overwrite,
          datetime64ns_dtype: Datetime64Overwrite,
          int64_dtype: Int64Overwrite,
          bytes_dtype: ObjectOverwrite,
          unicode_dtype: ObjectOverwrite,
          object_dtype: ObjectOverwrite,
      }[dtype]
      make_expected_dtype = as_dtype(dtype)
      missing_value = default_missing_value_for_dtype(
          datetime64ns_dtype
      )
  
      if dtype == object_dtype:
          # When we're testing object dtypes, we expect to have strings, but
          # coerce_to_dtype(object, 3) just gives 3 as a Python integer.
          def make_overwrite_value(dtype, value):
              return str(value)
  
      else:
          make_overwrite_value = coerce_to_dtype
  
      adjustments = {}
      buffer_as_of = [None] * 6
      baseline = make_expected_dtype(
          [
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
          ]
      )
  
      buffer_as_of[0] = make_expected_dtype(
          [
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
          ]
      )
  
      # Note that row indices are inclusive!
      adjustments[1] = [
          adjustment_type(0, 0, 0, 0, make_overwrite_value(dtype, 1)),
      ]
      buffer_as_of[1] = make_expected_dtype(
          [
              [1, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
          ]
      )
  
      # No adjustment at index 2.
      buffer_as_of[2] = buffer_as_of[1]
  
      adjustments[3] = [
          adjustment_type(1, 2, 1, 1, make_overwrite_value(dtype, 3)),
          adjustment_type(0, 1, 0, 0, make_overwrite_value(dtype, 4)),
      ]
      buffer_as_of[3] = make_expected_dtype(
          [
              [4, 2, 2],
              [4, 3, 2],
              [2, 3, 2],
              [2, 2, 2],
              [2, 2, 2],
              [2, 2, 2],
          ]
      )
  
      adjustments[4] = [
          adjustment_type(0, 3, 2, 2, make_overwrite_value(dtype, 5))
      ]
      buffer_as_of[4] = make_expected_dtype(
          [
              [4, 2, 5],
              [4, 3, 5],
              [2, 3, 5],
              [2, 2, 5],
              [2, 2, 2],
              [2, 2, 2],
          ]
      )
  
      adjustments[5] = [
          adjustment_type(0, 4, 1, 1, make_overwrite_value(dtype, 6)),
          adjustment_type(2, 2, 2, 2, make_overwrite_value(dtype, 7)),
      ]
      buffer_as_of[5] = make_expected_dtype(
          [
              [4, 6, 5],
              [4, 6, 5],
              [2, 6, 7],
              [2, 6, 5],
              [2, 6, 2],
              [2, 2, 2],
          ]
      )
  
      return _gen_expectations(
          baseline,
          missing_value,
          adjustments,
          buffer_as_of,
          nrows=6,
          perspective_offsets=(0, 1),
      )
  
imports: from collections import namedtuple
  from itertools import chain, product
  from textwrap import dedent
  from unittest import TestCase
  from nose_parameterized import parameterized
  from numpy import arange, array, asarray, dtype, full, where
  from six.moves import zip_longest
  from toolz import curry
  from catalyst.errors import WindowLengthNotPositive, WindowLengthTooLong
  from catalyst.lib.adjustment import Datetime64Overwrite, Datetime641DArrayOverwrite, Float64Multiply, Float64Overwrite, Float641DArrayOverwrite, Int64Overwrite, ObjectOverwrite
  from catalyst.lib.adjusted_array import AdjustedArray, NOMASK
  from catalyst.lib.labelarray import LabelArray
  from catalyst.testing import check_arrays, parameter_space
  from catalyst.utils.compat import unicode
  from catalyst.utils.numpy_utils import coerce_to_dtype, datetime64ns_dtype, default_missing_value_for_dtype, float64_dtype, int64_dtype, object_dtype
label_desc: Use image node_id 8 for calling a global function with example usage: _gen_overwrite_adjustment_cases(dtype) and returns: _gen_expectations, str