Skip to content

Commit

Permalink
Merge pull request #78 from scalableminds/py-assertion-messages
Browse files Browse the repository at this point in the history
python lib: add helpful assertion messages for init
  • Loading branch information
jstriebel authored Aug 2, 2022
2 parents cbe1f12 + f843809 commit 35151af
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions python/wkw/wkw.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,27 @@ def __init__(
):
self.version = version

assert block_len & (block_len - 1) == 0
assert (
block_len & (block_len - 1) == 0
), f"block_len must be a power of two, but is {block_len}"
self.block_len = block_len

assert file_len & (file_len - 1) == 0
assert (
file_len & (file_len - 1) == 0
), f"file_len must be a power of two, but is {file_len}"
self.file_len = file_len

assert block_type in self.VALID_BLOCK_TYPES
assert (
block_type in self.VALID_BLOCK_TYPES
), f"block_type must be one of {self.VALID_BLOCK_TYPES}, but is {block_type}"
self.block_type = block_type

assert voxel_type in self.VALID_VOXEL_TYPES
assert (
voxel_type in self.VALID_VOXEL_TYPES
), f"voxel_type must be one of {self.VALID_VOXEL_TYPES}, but is {voxel_type}"
self.voxel_type = voxel_type

assert num_channels > 0
assert num_channels > 0, f"num_channels must be >0, but is {num_channels}"
self.num_channels = num_channels

@staticmethod
Expand Down

0 comments on commit 35151af

Please sign in to comment.