Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean array uses same amount of space as uint8 #2066

Closed
haarisr opened this issue Aug 4, 2024 · 2 comments
Closed

Boolean array uses same amount of space as uint8 #2066

haarisr opened this issue Aug 4, 2024 · 2 comments
Labels
bug Potential issues with the zarr-python library

Comments

@haarisr
Copy link

haarisr commented Aug 4, 2024

Zarr version

2.18.2

Numcodecs version

0.13.0

Python Version

3.12.4

Operating System

linux

Installation

pip

Description

Saving a boolean array to with zarr uses the same amount of space as a uint8

Type               : zarr.core.Array
Data type          : bool
Shape              : (400000, 128, 128)
Chunk shape        : (1, 128, 128)
Order              : C
Read-only          : False
Compressor         : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type         : zarr.storage.DirectoryStore
No. bytes          : 6553600000 (6.1G)
No. bytes stored   : 370
Storage ratio      : 17712432.4
Chunks initialized : 0/400000

Type               : zarr.core.Array
Data type          : uint8
Shape              : (400000, 128, 128)
Chunk shape        : (1, 128, 128)
Order              : C
Read-only          : False
Compressor         : Blosc(cname='lz4', clevel=5, shuffle=SHUFFLE, blocksize=0)
Store type         : zarr.storage.DirectoryStore
No. bytes          : 6553600000 (6.1G)
No. bytes stored   : 366
Storage ratio      : 17906010.9
Chunks initialized : 0/400000

Steps to reproduce

import numpy as np
import zarr

arr = zarr.open_array("./image", shape=(400000,128,128), chunks=(1,128,128), dtype=np.bool_,mode="w")
print(arr.info)

arr = zarr.open_array("./image", shape=(400000,128,128), chunks=(1,128,128), dtype=np.uint8,mode="w")
print(arr.info)

Additional output

No response

@haarisr haarisr added the bug Potential issues with the zarr-python library label Aug 4, 2024
@haarisr haarisr changed the title Boolean array uses same amount of space as uin8 Boolean array uses same amount of space as uint8 Aug 4, 2024
@d-v-b
Copy link
Contributor

d-v-b commented Aug 4, 2024

this is expected, as the boolean data type is 1 byte.

@haarisr
Copy link
Author

haarisr commented Aug 4, 2024

Oh that's interesting thanks

Will close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

2 participants