docstr: Make sure the composite distance validation utility allows good
  distances through and catches bad distances.
docstr_tok: ["Make","sure","the","composite","distance","validation","utility","allows","good","distances","through","and","catches","bad","distances","."]
code: def test_composite_dist_validation(self):
      """
      Make sure the composite distance validation utility allows good
      distances through and catches bad distances.
      """
  
      ## A good distance
      try:
          tc.distances._util._validate_composite_distance(self.dist)
      except:
          assert (
              False
          ), "Composite distance validation failed for a good distance."
  
      ## An empty distance
      with self.assertRaises(ValueError):
          tc.distances._util._validate_composite_distance([])
  
      ## A distance not in a list
      with self.assertRaises(TypeError):
          tc.distances._util._validate_composite_distance(
              tuple(self.dist)
          )
  
      ## Empty feature list
      dist = copy.deepcopy(self.dist)
      dist.append([[], "euclidean", 13])
  
      with self.assertRaises(ValueError):
          tc.distances._util._validate_composite_distance(dist)
  
      ## Feature list with non-strings
      dist = copy.deepcopy(self.dist)
      dist.append([["test", 17], "manhattan", 13])
  
      with self.assertRaises(TypeError):
          tc.distances._util._validate_composite_distance(dist)
  
      ## Distance function in the wrong form
      dist = copy.deepcopy(self.dist)
      dist.append([["d"], 17, 13])
  
      with self.assertRaises(ValueError):
          tc.distances._util._validate_composite_distance(dist)
  
      ## Non-existent distance function
      dist = copy.deepcopy(self.dist)
      dist.append([["d"], "haversine", 13])
  
      with self.assertRaises(ValueError):
          tc.distances._util._validate_composite_distance(dist)
  
      ## Weight of the wrong type
      dist = copy.deepcopy(self.dist)
      dist.append([["d"], "euclidean", "a lot"])
  
      with self.assertRaises(ValueError):
          tc.distances._util._validate_composite_distance(dist)
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import copy
  import unittest
  import numpy
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  from collections import Counter
  import sys
label_desc: Use image node_id 2 for calling the DistanceUtilsTest obj's underlying member method code with example usage: obj.test_composite_dist_validation() without return types