class_docstr: Unit test class for general utilities. 
class_docstr_tok: ["Unit","test","class","for","general","utilities","."]
docstr: Tests pairwise hamming distances. 
docstr_tok: ["Tests","pairwise","hamming","distances","."]
code: def test_pairwise_hamming_kernel(self):
      """Tests pairwise hamming distances."""
      self.report("Testing hamming distance.")
      # Test 1
      test_data = [  # data 1
          (
              [[4, 5], ["kky", 5], ["s", None]],
              [[2, 5], ["s", None], ["kky", None], ["s", 1]],
              [0.4, 0.6],
              [[1.0, 0.6, 0], [0.6, 1.0, 0], [0, 0, 1.0]],
              [
                  [1, 0, 0, 0],
                  [0, 1, 0.6, 0.4],
                  [0, 0.6, 1, 0],
                  [0, 0.4, 0, 1],
              ],
              [[0.6, 0, 0, 0], [0.6, 0, 0.4, 0], [0, 1, 0.6, 0.4]],
          ),
          # data 2
          (
              [[4, 5, 6], ["kky", 5, "cat"]],
              [[2, 5, 6], ["s", None, "cat"], ["kky", None, 6]],
              None,
              [[1.0, 1 / 3.0], [1 / 3.0, 1]],
              [
                  [1.0, 0, 1 / 3.0],
                  [0, 1, 1 / 3.0],
                  [1 / 3.0, 1 / 3.0, 1],
              ],
              [[2 / 3.0, 0, 1 / 3.0], [1 / 3.0, 1 / 3.0, 1 / 3.0]],
          ),
      ]
      for td in test_data:
          res_00 = np.array(td[-3])
          res_11 = np.array(td[-2])
          res_01 = np.array(td[-1])
          res_10 = res_01.T
          kern_00 = general_utils.pairwise_hamming_kernel(
              td[0], td[0], td[2]
          )
          kern_11 = general_utils.pairwise_hamming_kernel(
              td[1], td[1], td[2]
          )
          kern_01 = general_utils.pairwise_hamming_kernel(
              td[0], td[1], td[2]
          )
          kern_10 = general_utils.pairwise_hamming_kernel(
              td[1], td[0], td[2]
          )
          #       print res_00
          #       print kern_00
          #       print res_11
          #       print kern_11
          #       print res_01
          #       print kern_01
          #       print res_10
          #       print kern_10
          assert np.linalg.norm(res_00 - kern_00) < 1e-5
          assert np.linalg.norm(res_11 - kern_11) < 1e-5
          assert np.linalg.norm(res_01 - kern_01) < 1e-5
          assert np.linalg.norm(res_10 - kern_10) < 1e-5
  
file_path: dragonfly/dragonfly/utils/unittest_general_utils.py
imports: from __future__ import absolute_import
  from __future__ import division
  import numpy
  from .None import general_utils
  from .base_test_class import BaseTestClass, execute_tests
label_desc: Use image node_id 10 for calling the GeneralUtilsTestCase obj's underlying member method code with example usage: obj.test_pairwise_hamming_kernel() without return types