Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def decode(self, buf, out=None):
# normalise inputs
buf = ensure_contiguous_ndarray(buf)
if out is not None:
out = ensure_contiguous_ndarray(out)
# N.B., bz2 cannot handle ndarray directly because of truth testing issues
buf = memoryview(buf)
# do decompression
dec = _bz2.decompress(buf)
# handle destination - Python standard library bz2 module does not
# support direct decompression into buffer, so we have to copy into
# out if given
return ndarray_copy(dec, out)