def block(source): source.check() codeMap = CodeMap('Blockcode') count = 0 blockLength = ceil(bb(len(source))) for symbol in source.sorted(): codeMap.mapSymbol(symbol, _paddedBinary(count, blockLength)) count += 1 return codeMap
def addSymbol(self, symbol): self._symbols.append(symbol) self._entropy -= symbol.proba()*d(bb(symbol.proba()))