Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def encode(self, buf):
# normalise input
buf = ensure_contiguous_ndarray(buf)
# do compression
return _bz2.compress(buf, self.level)