(self, num_perm=128, seed=1,
hashfunc=sha1_hash32,
hashobj=None, # Deprecated.
hashvalues=None, permutations=None)
| 71 | ''' |
| 72 | |
| 73 | def __init__(self, num_perm=128, seed=1, |
| 74 | hashfunc=sha1_hash32, |
| 75 | hashobj=None, # Deprecated. |
| 76 | hashvalues=None, permutations=None): |
| 77 | # print("no") |
| 78 | if hashvalues is not None: |
| 79 | num_perm = len(hashvalues) |
| 80 | if num_perm > _hash_range: |
| 81 | # Because 1) we don't want the size to be too large, and |
| 82 | # 2) we are using 4 bytes to store the size value |
| 83 | raise ValueError("Cannot have more than %d number of\ |
| 84 | permutation functions" % _hash_range) |
| 85 | self.seed = seed |
| 86 | self.num_perm = num_perm |
| 87 | # Check the hash function. |
| 88 | if not callable(hashfunc): |
| 89 | raise ValueError("The hashfunc must be a callable.") |
| 90 | self.hashfunc = hashfunc |
| 91 | # Check for use of hashobj and issue warning. |
| 92 | if hashobj is not None: |
| 93 | warnings.warn("hashobj is deprecated, use hashfunc instead.", |
| 94 | DeprecationWarning) |
| 95 | # Initialize hash values |
| 96 | if hashvalues is not None: |
| 97 | self.hashvalues = self._parse_hashvalues(hashvalues) |
| 98 | else: |
| 99 | self.hashvalues = self._init_hashvalues(num_perm) |
| 100 | # Initalize permutation function parameters |
| 101 | if permutations is not None: |
| 102 | self.permutations = permutations |
| 103 | else: |
| 104 | self.permutations = self._init_permutations(num_perm) |
| 105 | if len(self) != len(self.permutations[0]): |
| 106 | raise ValueError("Numbers of hash values and permutations mismatch") |
| 107 | |
| 108 | def _init_hashvalues(self, num_perm): |
| 109 | return np.ones(num_perm, dtype=np.uint64)*_max_hash |
nothing calls this directly
no test coverage detected