code: def test_data_mismatch():
      test_cases_twoway = [
          # Data type mismatch
          ([1, 2, 3], [True, False, True]),
          (
              C(["a", "b", "c"], levels=["c", "b", "a"]),
              C(["a", "b", "c"], levels=["a", "b", "c"]),
          ),
          # column number mismatches
          ([[1], [2], [3]], [[1, 1], [2, 2], [3, 3]]),
          ([[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[1, 1], [2, 2], [3, 3]]),
      ]
      test_cases_oneway = [
          ([1, 2, 3], ["a", "b", "c"]),
          ([1, 2, 3], C(["a", "b", "c"])),
          ([True, False, True], C(["a", "b", "c"])),
          ([True, False, True], ["a", "b", "c"]),
      ]
      setup_predict_only = [
          # This is not an error if both are fed in during make_builders, but it
          # is an error to pass one to make_builders and the other to
          # make_matrices.
          (["a", "b", "c"], ["a", "b", "d"]),
      ]
      termlist = make_termlist(["x"])
  
      def t_incremental(data1, data2):
          def iter_maker():
              yield {"x": data1}
              yield {"x": data2}
  
          try:
              builders = design_matrix_builders(
                  [termlist], iter_maker, 0
              )
              build_design_matrices(builders, {"x": data1})
              build_design_matrices(builders, {"x": data2})
          except PatsyError:
              pass
          else:
              raise AssertionError
  
      def t_setup_predict(data1, data2):
          def iter_maker():
              yield {"x": data1}
  
          builders = design_matrix_builders([termlist], iter_maker, 0)
          pytest.raises(
              PatsyError, build_design_matrices, builders, {"x": data2}
          )
  
      for a, b in test_cases_twoway:
          t_incremental(a, b)
          t_incremental(b, a)
          t_setup_predict(a, b)
          t_setup_predict(b, a)
      for a, b in test_cases_oneway:
          t_incremental(a, b)
          t_setup_predict(a, b)
      for a, b in setup_predict_only:
          t_setup_predict(a, b)
          t_setup_predict(b, a)
  
      pytest.raises(
          PatsyError,
          make_matrix,
          {"x": [1, 2, 3], "y": [1, 2, 3, 4]},
          2,
          [["x"], ["y"]],
      )
  
imports: from __future__ import print_function
  import six
  import numpy
  import pytest
  from patsy import PatsyError
  from patsy.util import atleast_2d_column_default, have_pandas, have_pandas_categorical
  from patsy.desc import Term, INTERCEPT
  from patsy.build import *
  from patsy.categorical import C
  from patsy.user_util import balanced, LookupFactor
  from patsy.design_info import DesignMatrix, DesignInfo
label_desc: Use image node_id 15 for calling a global function with example usage: test_data_mismatch() without return types