code: def test_R_bugs():
      data = balanced(a=2, b=2, c=2)
      data["x"] = np.linspace(0, 1, len(data["a"]))
      # For "1 + a:b", R produces a design matrix with too many columns (5
      # instead of 4), because it can't tell that there is a redundancy between
      # the two terms.
      make_matrix(data, 4, [[], ["a", "b"]])
      # For "0 + a:x + a:b", R produces a design matrix with too few columns (4
      # instead of 6), because it thinks that there is a redundancy which
      # doesn't exist.
      make_matrix(data, 6, [["a", "x"], ["a", "b"]])
      # This can be compared with "0 + a:c + a:b", where the redundancy does
      # exist. Confusingly, adding another categorical factor increases the
      # baseline dimensionality to 8, and then the redundancy reduces it to 6
      # again, so the result is the same as before but for different reasons. (R
      # does get this one right, but we might as well test it.)
      make_matrix(data, 6, [["a", "c"], ["a", "b"]])
  
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 7 for calling a global function with example usage: test_R_bugs() without return types