/usr/local/lib/python3.6/site-packages/datasets/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/datasets/__pycache__/keyhash.cpython-36.pyc (3341B)
3
<%Eg @ sd d Z ddlZddlmZ eeeef edddZG dd deZ G d d
d
eZ
G dd dZdS )
a
Hashing function for dataset keys using `hashlib.md5`
Requirements for the hash function:
- Provides a uniformly distributed hash from random space
- Adequately fast speed
- Working with multiple input types (in this case, `str`, `int` or `bytes`)
- Should be platform independent (generates same hash on different OS and systems)
The hashing function provides a unique 128-bit integer hash of the key provided.
The split name is being used here as the hash salt to avoid having same hashes
in different splits due to same keys
N)Union) hash_datareturnc C sL t | tr| S t | tr&| jdd} nt | tr:t| } nt| | jdS )z|
Returns the input hash_data in its bytes form
Args:
hash_data: the hash salt/key to be converted to bytes
\/zutf-8)
isinstancebytesstrreplaceintInvalidKeyErrorencode)r r :/usr/local/lib/python3.6/site-packages/datasets/keyhash.py _as_bytes% s
r c s e Zd ZdZ fddZ ZS )r z6Raises an error when given key is of invalid datatype.c sD d| _ d| dt| | _d| _t j| j | j | j d S )Nz7
FAILURE TO GENERATE DATASET: Invalid key type detectedz
Found Key z of type z-
Keys should be either str, int or bytes type)prefixtypeerr_msgsuffixsuper__init__)selfr ) __class__r r r ? s zInvalidKeyError.__init__)__name__
__module____qualname____doc__r
__classcell__r r )r r r <