code: def test_binary_dtype_constr(self):
      # Create a symbol table with no types in it, so we can
      # make some isolated type constructors for testing
      sym = datashape.TypeSymbolTable(bare=True)
      # A limited set of dtypes for testing
      sym.dtype["int8"] = ct.int8
      sym.dtype["uint16"] = ct.uint16
      sym.dtype["float64"] = ct.float64
      # TypeVar type constructor
      sym.dtype_constr["typevar"] = ct.TypeVar
      # Binary dtype constructor that asserts on the argument values
      expected_arg = [None, None]
  
      def _binary_type_constr(a, b):
          self.assertEqual(a, expected_arg[0])
          self.assertEqual(b, expected_arg[1])
          expected_arg[0] = None
          expected_arg[1] = None
          return ct.float32
  
      sym.dtype_constr["binary"] = _binary_type_constr
  
      def assertExpectedParse(ds_str, expected_a, expected_b):
          # Set the expected value, and call the parser
          expected_arg[0] = expected_a
          expected_arg[1] = expected_b
          self.assertEqual(parse(ds_str, sym), ct.DataShape(ct.float32))
          # Make sure the expected value was actually run by
          # check that it reset the expected value to None
          self.assertEqual(
              expected_arg,
              [None, None],
              "The test binary type constructor did not run",
          )
  
      # Positional args
      assertExpectedParse("binary[1, 0]", 1, 0)
      assertExpectedParse('binary[0, "test"]', 0, "test")
      assertExpectedParse(
          'binary[int8, "test"]', ct.DataShape(ct.int8), "test"
      )
      assertExpectedParse('binary[[1,3,5], "test"]', [1, 3, 5], "test")
      # Positional and keyword args
      assertExpectedParse("binary[0, b=1]", 0, 1)
      assertExpectedParse(
          'binary["test", b=A]', "test", ct.DataShape(ct.TypeVar("A"))
      )
      assertExpectedParse(
          "binary[[3, 6], b=int8]", [3, 6], ct.DataShape(ct.int8)
      )
      assertExpectedParse(
          'binary[Arg, b=["x", "test"]]',
          ct.DataShape(ct.TypeVar("Arg")),
          ["x", "test"],
      )
      # Keyword args
      assertExpectedParse("binary[a=1, b=0]", 1, 0)
      assertExpectedParse(
          'binary[a=[int8, A, uint16], b="x"]',
          [
              ct.DataShape(ct.int8),
              ct.DataShape(ct.TypeVar("A")),
              ct.DataShape(ct.uint16),
          ],
          "x",
      )
  
imports: from __future__ import absolute_import, division, print_function
  import unittest
  import pytest
  from datashader import datashape
  from datashader.datashape.util.testing import assert_dshape_equal
  from datashader.datashape.parser import parse
  from datashader.datashape import coretypes
  from datashader.datashape import DataShapeSyntaxError
label_desc: Use image node_id 2 for calling the TestDataShapeParserDTypeConstr obj's underlying member method code with example usage: obj.test_binary_dtype_constr() and returns: ct