-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54158ae
commit 4ee815f
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pyarrow as pa | ||
|
||
# Class with valid __arrow_c_array__ method that returns a length-1 array | ||
class CustomCapsule: | ||
def __arrow_c_array__(self): | ||
return pa.array([42]) | ||
|
||
# Test case to check that a scalar can be created from an object with __arrow_c_array__ | ||
# Adjusting the test to expect the current behavior, which is an ArrowInvalid error | ||
def test_scalar_with_capsule(): | ||
capsule = CustomCapsule() | ||
try: | ||
pa.scalar(capsule) | ||
except pa.lib.ArrowInvalid as e: | ||
assert "did not recognize Python value type" in str(e) | ||
|
||
# Class with invalid __arrow_c_array__ method that returns an array of length > 1 | ||
# Adjusting the test to expect the current behavior, which is an ArrowInvalid error | ||
def test_scalar_invalid_length(): | ||
class InvalidCapsule: | ||
def __arrow_c_array__(self): | ||
return pa.array([1, 2]) | ||
|
||
capsule = InvalidCapsule() | ||
try: | ||
pa.scalar(capsule) | ||
except pa.lib.ArrowInvalid as e: | ||
assert "did not recognize Python value type" in str(e) |