Create a MinHash which is the union of the MinHash objects passed as arguments. Args: *mhs: The MinHash objects to be united. The argument list length is variable, but must be at least 2. Returns: datasketch.MinHash: A new union MinHash.
(cls, *mhs)
| 268 | |
| 269 | @classmethod |
| 270 | def union(cls, *mhs): |
| 271 | '''Create a MinHash which is the union of the MinHash objects passed as arguments. |
| 272 | |
| 273 | Args: |
| 274 | *mhs: The MinHash objects to be united. The argument list length is variable, |
| 275 | but must be at least 2. |
| 276 | |
| 277 | Returns: |
| 278 | datasketch.MinHash: A new union MinHash. |
| 279 | ''' |
| 280 | if len(mhs) < 2: |
| 281 | raise ValueError("Cannot union less than 2 MinHash") |
| 282 | num_perm = len(mhs[0]) |
| 283 | seed = mhs[0].seed |
| 284 | if any((seed != m.seed or num_perm != len(m)) for m in mhs): |
| 285 | raise ValueError("The unioning MinHash must have the\ |
| 286 | same seed and number of permutation functions") |
| 287 | hashvalues = np.minimum.reduce([m.hashvalues for m in mhs]) |
| 288 | permutations = mhs[0].permutations |
| 289 | return cls(num_perm=num_perm, seed=seed, hashvalues=hashvalues, |
| 290 | permutations=permutations) |
| 291 | |
| 292 | @classmethod |
| 293 | def bulk(cls, b, **minhash_kwargs): |
no outgoing calls