jorisvandenbossche commented on code in PR #41904:
URL: https://github.com/apache/arrow/pull/41904#discussion_r1709010467
##########
python/pyarrow/tests/test_scalars.py:
##########
@@ -102,6 +100,37 @@ def test_basics(value, ty, klass, pickle_module):
assert wr() is None
[email protected]
+def test_basics_np_required(pickle_module):
+ value, ty, klass = np.float16(1.0), pa.float16(), pa.HalfFloatScalar
+ s = pa.scalar(value, type=ty)
Review Comment:
And also, it seems this conversion from numpy scalar to pyarrow scalar is
also covered in the test below (`test_numerics`) ?
##########
python/pyarrow/tests/test_pandas.py:
##########
@@ -2925,23 +2925,23 @@ class TestConvertMisc:
"""
type_pairs = [
- (np.int8, pa.int8()),
- (np.int16, pa.int16()),
- (np.int32, pa.int32()),
- (np.int64, pa.int64()),
- (np.uint8, pa.uint8()),
- (np.uint16, pa.uint16()),
- (np.uint32, pa.uint32()),
- (np.uint64, pa.uint64()),
- (np.float16, pa.float16()),
- (np.float32, pa.float32()),
- (np.float64, pa.float64()),
+ ("int8", pa.int8()),
+ ("int16", pa.int16()),
+ ("int32", pa.int32()),
+ ("int64", pa.int64()),
+ ("uint8", pa.uint8()),
+ ("uint16", pa.uint16()),
+ ("uint32", pa.uint32()),
+ ("uint64", pa.uint64()),
+ ("float16", pa.float16()),
+ ("float32", pa.float32()),
+ ("float64", pa.float64()),
# XXX unsupported
# (np.dtype([('a', 'i2')]), pa.struct([pa.field('a', pa.int16())])),
- (np.object_, pa.string()),
- (np.object_, pa.binary()),
- (np.object_, pa.binary(10)),
- (np.object_, pa.list_(pa.int64())),
+ ("object_", pa.string()),
+ ("object_", pa.binary()),
+ ("object_", pa.binary(10)),
+ ("object_", pa.list_(pa.int64())),
Review Comment:
```suggestion
("object", pa.string()),
("object", pa.binary()),
("object", pa.binary(10)),
("object", pa.list_(pa.int64())),
```
##########
python/pyarrow/tests/test_scalars.py:
##########
@@ -102,6 +100,37 @@ def test_basics(value, ty, klass, pickle_module):
assert wr() is None
[email protected]
+def test_basics_np_required(pickle_module):
+ value, ty, klass = np.float16(1.0), pa.float16(), pa.HalfFloatScalar
+ s = pa.scalar(value, type=ty)
Review Comment:
What we are testing here essentially is that a numpy float scalar (`value`)
can be converted to a pyarrow Scalar with `pa.scalar(..)`. But all the rest of
the test is not specific to that fact that we created it from a numpy scalar,
so I don't think you need to repeat that entirely here (the test above already
covers all those things for HalfFloatScalar), so I think you can simplify the
test here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]