Repository: activeloopai/Hub
File: deeplake/core/compression.py (Python)

Code before:
    if compression is None:
        return array.tobytes()

    compr_type = get_compression_type(compression)

    if compr_type == BYTE_COMPRESSION:
        return compress_bytes(array.tobytes(), compression)
    elif compr_type == AUDIO_COMPRESSION:
        raise NotImplementedError(
            "In order to store audio data, you should use `deeplake.read(path_to_file)`. Compressing raw data is not yet supported."
        )
    elif compr_type == VIDEO_COMPRESSION:
        raise NotImplementedError(
            "In order to store video data, you should use `deeplake.read(path_to_file)`. Compressing raw data is not yet supported."
        )
    elif compr_type == POINT_CLOUD_COMPRESSION:
        raise NotImplementedError(
            "In order to store point cloud data, you should use `deeplake.read(path_to_file)`. Compressing raw data is not yet supported."
        )
    elif compr_type == MESH_COMPRESSION:
        raise NotImplementedError(
            "In order to store mesh data, you should use `deeplake.read(path_to_file)`. Compressing raw data is not yet supported."
        )
    elif compr_type == NIFTI_COMPRESSION:
        raise NotImplementedError(
            "In order to store nifti data, you should use `deeplake.read(path_to_file)` or use a None compression. "
            "Compressing raw data is not yet supported."
        )
    if compression == "apng":
        return _compress_apng(array)
    try:
        img = to_image(array)
        out = BytesIO()
        out._close = out.close  # type: ignore
        out.close = (  # type: ignore
            lambda: None
        )  # sgi save handler will try to close the stream (see https://github.com/python-pillow/Pillow/pull/5645)
        kwargs = {"sizes": [img.size]} if compression == "ico" else {}
        img.save(out, compression, **kwargs)
        out.seek(0)
        compressed_bytes = out.read()
        out._close()  # type: ignore
        return compressed_bytes
    except (TypeError, OSError) as e:
        raise SampleCompressionError(array.shape, compression, str(e))


def decompress_array(
    buffer: Union[bytes, memoryview, str],
    shape: Optional[Tuple[int, ...]] = None,
    dtype: Optional[str] = None,

Review comment (suggestion):
```suggestion
            "In order to store nifti data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None."
```
Also, we should probably do this for the other exceptions here too

Code after:
    if compression is None:
        return array.tobytes()

    compr_type = get_compression_type(compression)

    if compr_type == BYTE_COMPRESSION:
        return compress_bytes(array.tobytes(), compression)
    elif compr_type == AUDIO_COMPRESSION:
        raise NotImplementedError(
            "In order to store audio data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None. "
            "Compressing raw data is not yet supported."
        )
    elif compr_type == VIDEO_COMPRESSION:
        raise NotImplementedError(
            "In order to store video data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None. "
            "Compressing raw data is not yet supported."
        )
    elif compr_type == POINT_CLOUD_COMPRESSION:
        raise NotImplementedError(
            "In order to store point cloud data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None. "
            "Compressing raw data is not yet supported."
        )
    elif compr_type == MESH_COMPRESSION:
        raise NotImplementedError(
            "In order to store mesh data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None. "
            "Compressing raw data is not yet supported."
        )
    elif compr_type == NIFTI_COMPRESSION:
        raise NotImplementedError(
            "In order to store nifti data, you should use `deeplake.read(path_to_file)` or specify sample_compression=None. "
            "Compressing raw data is not yet supported."
        )
    if compression == "apng":
        return _compress_apng(array)
    try:
        img = to_image(array)
        out = BytesIO()
        out._close = out.close  # type: ignore
        out.close = (  # type: ignore
            lambda: None
        )  # sgi save handler will try to close the stream (see https://github.com/python-pillow/Pillow/pull/5645)
        kwargs = {"sizes": [img.size]} if compression == "ico" else {}
        img.save(out, compression, **kwargs)
        out.seek(0)
        compressed_bytes = out.read()
        out._close()  # type: ignore
        return compressed_bytes
    except (TypeError, OSError) as e:
        raise SampleCompressionError(array.shape, compression, str(e))