docstr: Test that categories are inferred in sorted order if they're not
  explicitly passed.
docstr_tok: ["Test","that","categories","are","inferred","in","sorted","order","if","they","'re","not","explicitly","passed","."]
code: def test_infer_categories(self):
      """
      Test that categories are inferred in sorted order if they're not
      explicitly passed.
      """
      arr1d = LabelArray(self.strs, missing_value="")
      codes1d = arr1d.as_int_array()
      self.assertEqual(arr1d.shape, self.strs.shape)
      self.assertEqual(arr1d.shape, codes1d.shape)
  
      categories = arr1d.categories
      unique_rowvalues = set(self.rowvalues)
  
      # There should be an entry in categories for each unique row value, and
      # each integer stored in the data array should be an index into
      # categories.
      self.assertEqual(list(categories), sorted(set(self.rowvalues)))
      self.assertEqual(
          set(codes1d.ravel()), set(range(len(unique_rowvalues)))
      )
      for idx, value in enumerate(arr1d.categories):
          check_arrays(
              self.strs == value,
              arr1d.as_int_array() == idx,
          )
  
      # It should be equivalent to pass the same set of categories manually.
      arr1d_explicit_categories = LabelArray(
          self.strs,
          missing_value="",
          categories=arr1d.categories,
      )
      check_arrays(arr1d, arr1d_explicit_categories)
  
      for shape in (9, 3), (3, 9), (3, 3, 3):
          strs2d = self.strs.reshape(shape)
          arr2d = LabelArray(strs2d, missing_value="")
          codes2d = arr2d.as_int_array()
  
          self.assertEqual(arr2d.shape, shape)
          check_arrays(arr2d.categories, categories)
  
          for idx, value in enumerate(arr2d.categories):
              check_arrays(strs2d == value, codes2d == idx)
  
imports: from itertools import product
  from operator import eq, ne
  import warnings
  import numpy
  from toolz import take
  from zipline.lib.labelarray import LabelArray
  from zipline.testing import check_arrays, parameter_space, ZiplineTestCase
  from zipline.testing.predicates import assert_equal
  from zipline.utils.compat import unicode
label_desc: Use image node_id 10 for calling the LabelArrayTestCase obj's underlying member method code with example usage: obj.test_infer_categories() without return types