Skip to content

det_hash

allennlp.common.det_hash

[SOURCE]


CustomDetHash

class CustomDetHash

det_hash_object

class CustomDetHash:
 | ...
 | def det_hash_object(self) -> Any

By default, det_hash() pickles an object, and returns the hash of the pickled representation. Sometimes you want to take control over what goes into that hash. In that case, implement this method. det_hash() will pickle the result of this method instead of the object itself.

If you return None, det_hash() falls back to the original behavior and pickles the object.

DetHashFromInitParams

class DetHashFromInitParams(CustomDetHash)

Add this class as a mixin base class to make sure your class's det_hash is derived exclusively from the parameters passed to init().

det_hash_object

class DetHashFromInitParams(CustomDetHash):
 | ...
 | def det_hash_object(self) -> Any

DetHashWithVersion

class DetHashWithVersion(CustomDetHash)

Add this class as a mixing base class to make sure your class's det_hash can be modified by altering a static VERSION member of your class.

VERSION

class DetHashWithVersion(CustomDetHash):
 | ...
 | VERSION = None

det_hash_object

class DetHashWithVersion(CustomDetHash):
 | ...
 | def det_hash_object(self) -> Any

det_hash

def det_hash(o: Any) -> str

Returns a deterministic hash code of arbitrary Python objects.

If you want to override how we calculate the deterministic hash, derive from the CustomDetHash class and implement det_hash_object().