code: def test_unary_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
      # Unary dtype constructor that asserts on the argument value
      expected_blah = [None]
  
      def _unary_type_constr(blah):
          self.assertEqual(blah, expected_blah[0])
          expected_blah[0] = None
          return ct.float32
  
      sym.dtype_constr["unary"] = _unary_type_constr
  
      def assertExpectedParse(ds_str, expected):
          # Set the expected value, and call the parser
          expected_blah[0] = expected
          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_blah[0],
              None,
              "The test unary type constructor did not run",
          )
  
      # Integer parameter (positional)
      assertExpectedParse("unary[0]", 0)
      assertExpectedParse("unary[100000]", 100000)
      # String parameter (positional)
      assertExpectedParse('unary["test"]', "test")
      assertExpectedParse("unary['test']", "test")
      assertExpectedParse('unary["\\uc548\\ub155"]', "\uc548\ub155")
      assertExpectedParse('unary["\uc548\ub155"]', "\uc548\ub155")
      # DataShape parameter (positional)
      assertExpectedParse("unary[int8]", ct.DataShape(ct.int8))
      assertExpectedParse("unary[X]", ct.DataShape(ct.TypeVar("X")))
      # Empty list parameter (positional)
      assertExpectedParse("unary[[]]", [])
      # List of integers parameter (positional)
      assertExpectedParse("unary[[0, 3, 12]]", [0, 3, 12])
      # List of strings parameter (positional)
      assertExpectedParse(
          'unary[["test", "one", "two"]]', ["test", "one", "two"]
      )
      # List of datashapes parameter (positional)
      assertExpectedParse(
          "unary[[float64, int8, uint16]]",
          [
              ct.DataShape(ct.float64),
              ct.DataShape(ct.int8),
              ct.DataShape(ct.uint16),
          ],
      )
  
      # Integer parameter (keyword)
      assertExpectedParse("unary[blah=0]", 0)
      assertExpectedParse("unary[blah=100000]", 100000)
      # String parameter (keyword)
      assertExpectedParse('unary[blah="test"]', "test")
      assertExpectedParse("unary[blah='test']", "test")
      assertExpectedParse(
          'unary[blah="\\uc548\\ub155"]', "\uc548\ub155"
      )
      assertExpectedParse('unary[blah="\uc548\ub155"]', "\uc548\ub155")
      # DataShape parameter (keyword)
      assertExpectedParse("unary[blah=int8]", ct.DataShape(ct.int8))
      assertExpectedParse(
          "unary[blah=X]", ct.DataShape(ct.TypeVar("X"))
      )
      # Empty list parameter (keyword)
      assertExpectedParse("unary[blah=[]]", [])
      # List of integers parameter (keyword)
      assertExpectedParse("unary[blah=[0, 3, 12]]", [0, 3, 12])
      # List of strings parameter (keyword)
      assertExpectedParse(
          'unary[blah=["test", "one", "two"]]', ["test", "one", "two"]
      )
      # List of datashapes parameter (keyword)
      assertExpectedParse(
          "unary[blah=[float64, int8, uint16]]",
          [
              ct.DataShape(ct.float64),
              ct.DataShape(ct.int8),
              ct.DataShape(ct.uint16),
          ],
      )
  
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 1 for calling the TestDataShapeParserDTypeConstr obj's underlying member method code with example usage: obj.test_unary_dtype_constr() and returns: ct