def hash_array(vals, encoding='<STR_LIT:utf8>', hash_key=None, categorize=True):
if not hasattr(vals, '<STR_LIT>'):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>dtype = vals.dtype<EOL>if hash_key is None:<EOL><INDENT>hash_key = _default_hash_key<EOL><DEDENT>if is_categorical_dtype(dtype):<EOL><INDENT>return _hash_categorical(vals, encoding, hash_key)<EOL><DEDENT>elif is_extension_array_dtype(dtype):<EOL><INDENT>vals, _ = vals._values_for_factorize()<EOL>dtype = vals.dtype<EOL><DEDENT>if np.issubdtype(dtype, np.complex128):<EOL><INDENT>return hash_array(vals.real) + <NUM_LIT> * hash_array(vals.imag)<EOL><DEDENT>elif isinstance(dtype, np.bool):<EOL><INDENT>vals = vals.astype('<STR_LIT>')<EOL><DEDENT>elif issubclass(dtype.type, (np.datetime64, np.timedelta64)):<EOL><INDENT>vals = vals.view('<STR_LIT>').astype('<STR_LIT>', copy=False)<EOL><DEDENT>elif issubclass(dtype.type, np.number) and dtype.itemsize <= <NUM_LIT:8>:<EOL><INDENT>vals = vals.view('<STR_LIT>'.format(vals.dtype.itemsize)).astype('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if categorize:<EOL><INDENT>from pandas import factorize, Categorical, Index<EOL>codes, categories = factorize(vals, sort=False)<EOL>cat = Categorical(codes, Index(categories),<EOL>ordered=False, fastpath=True)<EOL>return _hash_categorical(cat, encoding, hash_key)<EOL><DEDENT>try:<EOL><INDENT>vals = hashing.hash_object_array(vals, hash_key, encoding)<EOL><DEDENT>except TypeError:<EOL><INDENT>vals = hashing.hash_object_array(vals.astype(str).astype(object),<EOL>hash_key, encoding)<EOL><DEDENT><DEDENT>vals ^= vals >> <NUM_LIT:30><EOL>vals *= np.uint64(<NUM_LIT>)<EOL>vals ^= vals >> <NUM_LIT><EOL>vals *= np.uint64(<NUM_LIT>)<EOL>vals ^= vals >> <NUM_LIT><EOL>return vals<EOL>
Given a 1d array, return an array of deterministic integers.

.. versionadded:: 0.19.2

Parameters
----------
vals : ndarray, Categorical
encoding : string, default 'utf8'
    encoding for data & key when strings
hash_key : string key to encode, default to _default_hash_key
categorize : bool, default True
    Whether to first categorize object arrays before hashing. This is more
    efficient when the array contains duplicate values.

    .. versionadded:: 0.20.0

Returns
-------
1d uint64 numpy array of hash values, same length as the vals