Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Given another Rii instance (engine), merge its PQ-codes (engine.codes)
to this instance. IDs for new PQ-codes are automatically assigned.
For example, if self.N = 100, the IDs of the merged PQ-codes would be 100, 101, ...
The original posting lists of this instance will be kept
maintained; new PQ-codes will be simply added over that.
Thus it might be better to call :func:`reconfigure` after many new codes are merged.
Args:
engine (rii.Rii): Rii instance. engine.fine_quantizer should be
the same as self.fine_quantizer
update_posting_lists (bool or str): True or False or 'auto'. If True, :attr:`posting_lists` will be updated.
This should be True for usual cases.
"""
assert isinstance(engine, Rii)
assert self.fine_quantizer == engine.fine_quantizer, \
"Two engines to be merged must have the same fine quantizer"
if engine.N != 0:
self.impl_cpp.add_codes(engine.codes,
self._resolve_update_posting_lists_flag(update_posting_lists))
if self.verbose:
print("The number of codes: {}".format(self.N))