class_docstr: An ndarray subclass for working with arrays of strings.
  
  Factorizes the input array into integers, but overloads equality on strings
  to check against the factor label.
  
  Parameters
  ----------
  values : array-like
      Array of values that can be passed to np.asarray with dtype=object.
  missing_value : str
      Scalar value to treat as 'missing' for operations on ``self``.
  categories : list[str], optional
      List of values to use as categories.  If not supplied, categories will
      be inferred as the unique set of entries in ``values``.
  sort : bool, optional
      Whether to sort categories.  If sort is False and categories is
      supplied, they are left in the order provided.  If sort is False and
      categories is None, categories will be constructed in a random order.
  
  Attributes
  ----------
  categories : ndarray[str]
      An array containing the unique labels of self.
  reverse_categories : dict[str -> int]
      Reverse lookup table for ``categories``. Stores the index in
      ``categories`` at which each entry each unique entry is found.
  missing_value : str or None
      A sentinel missing value with NaN semantics for comparisons.
  
  Notes
  -----
  Consumers should be cautious when passing instances of LabelArray to numpy
  functions.  We attempt to disallow as many meaningless operations as
  possible, but since a LabelArray is just an ndarray of ints with some
  additional metadata, many numpy functions (for example, trigonometric) will
  happily accept a LabelArray and treat its values as though they were
  integers.
  
  In a future change, we may be able to disallow more numerical operations by
  creating a wrapper dtype which doesn't register an implementation for most
  numpy ufuncs. Until that change is made, consumers of LabelArray should
  assume that it is undefined behavior to pass a LabelArray to any numpy
  ufunc that operates on semantically-numerical data.
  
  See Also
  --------
  https://docs.scipy.org/doc/numpy-1.11.0/user/basics.subclassing.html
class_docstr_tok: ["An","ndarray","subclass","for","working","with","arrays","of","strings",".","Factorizes","the","input","array","into","integers",",","but","overloads","equality","on","strings","to","check","against","the","factor","label",".","Parameters","--","--","--","--","--","values",":","array-like","Array","of","values","that","can","be","passed","to","np.asarray","with","dtype=object",".","missing_value",":","str","Scalar","value","to","treat","as","'missing","'","for","operations","on","``","self","``",".","categories",":","list","[","str","]",",","optional","List","of","values","to","use","as","categories",".","If","not","supplied",",","categories","will","be","inferred","as","the","unique","set","of","entries","in","``","values","``",".","sort",":","bool",",","optional","Whether","to","sort","categories",".","If","sort","is","False","and","categories","is","supplied",",","they","are","left","in","the","order","provided",".","If","sort","is","False","and","categories","is","None",",","categories","will","be","constructed","in","a","random","order",".","Attributes","--","--","--","--","--","categories",":","ndarray","[","str","]","An","array","containing","the","unique","labels","of","self",".","reverse_categories",":","dict","[","str","-",">","int","]","Reverse","lookup","table","for","``","categories","``",".","Stores","the","index","in","``","categories","``","at","which","each","entry","each","unique","entry","is","found",".","missing_value",":","str","or","None","A","sentinel","missing","value","with","NaN","semantics","for","comparisons",".","Notes","--","--","-","Consumers","should","be","cautious","when","passing","instances","of","LabelArray","to","numpy","functions",".","We","attempt","to","disallow","as","many","meaningless","operations","as","possible",",","but","since","a","LabelArray","is","just","an","ndarray","of","ints","with","some","additional","metadata",",","many","numpy","functions","(","for","example",",","trigonometric",")","will","happily","accept","a","LabelArray","and","treat","its","values","as","though","they","were","integers",".","In","a","future","change",",","we","may","be","able","to","disallow","more","numerical","operations","by","creating","a","wrapper","dtype","which","does","n't","register","an","implementation","for","most","numpy","ufuncs",".","Until","that","change","is","made",",","consumers","of","LabelArray","should","assume","that","it","is","undefined","behavior","to","pass","a","LabelArray","to","any","numpy","ufunc","that","operates","on","semantically-numerical","data",".","See","Also","--","--","--","--","https",":","\/\/docs.scipy.org\/doc\/numpy-1.11.0\/user\/basics.subclassing.html"]
code: def __new__(cls, values, missing_value, categories=None, sort=True):
      # Numpy's fixed-width string types aren't very efficient. Working with
      # object arrays is faster than bytes or unicode arrays in almost all
      # cases.
      if not is_object(values):
          values = values.astype(object)
  
      if values.flags.f_contiguous:
          ravel_order = "F"
      else:
          ravel_order = "C"
  
      if categories is None:
          codes, categories, reverse_categories = factorize_strings(
              values.ravel(ravel_order),
              missing_value=missing_value,
              sort=sort,
          )
      else:
          (
              codes,
              categories,
              reverse_categories,
          ) = factorize_strings_known_categories(
              values.ravel(ravel_order),
              categories=categories,
              missing_value=missing_value,
              sort=sort,
          )
      categories.setflags(write=False)
  
      return cls.from_codes_and_metadata(
          codes=codes.reshape(values.shape, order=ravel_order),
          categories=categories,
          reverse_categories=reverse_categories,
          missing_value=missing_value,
      )
  
imports: from functools import partial, total_ordering
  from operator import eq, ne
  import re
  import numpy
  from numpy import ndarray
  import pandas
  from toolz import compose
  from zipline.utils.compat import unicode
  from zipline.utils.functional import instance
  from zipline.utils.preprocess import preprocess
  from zipline.utils.sentinel import sentinel
  from zipline.utils.input_validation import coerce, expect_kinds, expect_types, optional
  from zipline.utils.numpy_utils import bool_dtype, unsigned_int_dtype_with_size_in_bytes, is_object, object_dtype
  from zipline.utils.pandas_utils import ignore_pandas_nan_categorical_warning
  from ._factorize import factorize_strings, factorize_strings_known_categories, smallest_uint_that_can_hold
label_desc: Use image node_id 1 for calling the LabelArray obj's underlying member method code with example usage: obj.__new__(cls, values, missing_value, categories, sort) and returns: cls