code: def test_map_never_increases_code_storage_size(self):
      # This tests a pathological case where a user maps an impure function
      # that returns a different label on every invocation, which in a naive
      # implementation could cause us to need to **increase** the size of our
      # codes after a map.
      #
      # This doesn't happen, however, because we guarantee that the user's
      # mapping function will be called on each unique category exactly once,
      # which means we can never increase the number of categories in the
      # LabelArray after mapping.
  
      # Using all but one of the categories so that we still fit in a uint8
      # with an extra category for None as a missing value.
      categories = self.create_categories(8, plus_one=False)[:-1]
  
      larger_categories = self.create_categories(16, plus_one=False)
  
      # Double the length of the categories so that we have to increase the
      # required size after our map.
      categories_twice = categories + categories
  
      arr = LabelArray(categories_twice, missing_value=None)
      assert_equal(arr.itemsize, 1)
  
      gen_unique_categories = iter(larger_categories)
  
      def new_string_every_time(c):
          # Return a new unique category every time so that every result is
          # different.
          return next(gen_unique_categories)
  
      result = arr.map(new_string_every_time)
  
      # Result should still be of size 1.
      assert_equal(result.itemsize, 1)
  
      # Result should be the first `len(categories)` entries from the larger
      # categories, repeated twice.
      expected = LabelArray(
          larger_categories[: len(categories)] * 2,
          missing_value=None,
      )
      assert_equal(result.as_string_array(), expected.as_string_array())
  
imports: from itertools import product
  from operator import eq, ne
  import warnings
  import numpy
  from toolz import take
  from catalyst.lib.labelarray import LabelArray
  from catalyst.testing import check_arrays, parameter_space, CatalystTestCase
  from catalyst.testing.predicates import assert_equal
  from catalyst.utils.compat import unicode
label_desc: Use image node_id 19 for calling the LabelArrayTestCase obj's underlying member method code with example usage: obj.test_map_never_increases_code_storage_size() and returns: next