Skip to content

Commit

Permalink
raise an error in case of a 'Non-fixed width type'
Browse files Browse the repository at this point in the history
  • Loading branch information
llama90 committed May 17, 2024
1 parent 4baf617 commit da10983
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyarrow/tests/test_extension_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def test_ext_type_bit_width():
# Test for non fixed-size binary types
ty = LabelType()
with pytest.raises(ValueError, match="Non-fixed width type"):
_ = ty.byte_width
_ = ty.bit_width


def test_ext_type_as_py():
Expand Down
4 changes: 4 additions & 0 deletions python/pyarrow/types.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -1524,13 +1524,17 @@ cdef class BaseExtensionType(DataType):
"""
The byte width of the extension type.
"""
if self.ext_type.byte_width() == -1:
raise ValueError("Non-fixed width type")
return self.ext_type.byte_width()

@property
def bit_width(self):
"""
The bit width of the extension type.
"""
if self.ext_type.bit_width() == -1:
raise ValueError("Non-fixed width type")
return self.ext_type.bit_width()

def wrap_array(self, storage):
Expand Down

0 comments on commit da10983

Please sign in to comment.