This is an automated email from the ASF dual-hosted git repository. wesm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push: new 085b44d ARROW-9490: [Python][C++] Bug in pa.array when input mixes int8 with float 085b44d is described below commit 085b44d916cd1266911c05850a2369f30dd1fd65 Author: arw2019 <andrew.r.wiete...@gmail.com> AuthorDate: Sat Aug 22 12:54:05 2020 -0500 ARROW-9490: [Python][C++] Bug in pa.array when input mixes int8 with float Closes #8017 from arw2019/ARROW-9490 Authored-by: arw2019 <andrew.r.wiete...@gmail.com> Signed-off-by: Wes McKinney <w...@apache.org> --- cpp/src/arrow/python/helpers.cc | 2 ++ python/pyarrow/tests/test_convert_builtin.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/python/helpers.cc b/cpp/src/arrow/python/helpers.cc index 852bf76..1845aa1 100644 --- a/cpp/src/arrow/python/helpers.cc +++ b/cpp/src/arrow/python/helpers.cc @@ -328,6 +328,8 @@ Status UnboxIntegerAsInt64(PyObject* obj, int64_t* out) { if (overflow) { return Status::Invalid("PyLong is too large to fit int64"); } + } else if (PyArray_IsScalar(obj, Byte)) { + *out = reinterpret_cast<PyByteScalarObject*>(obj)->obval; } else if (PyArray_IsScalar(obj, UByte)) { *out = reinterpret_cast<PyUByteScalarObject*>(obj)->obval; } else if (PyArray_IsScalar(obj, Short)) { diff --git a/python/pyarrow/tests/test_convert_builtin.py b/python/pyarrow/tests/test_convert_builtin.py index 788675a..f62a941 100644 --- a/python/pyarrow/tests/test_convert_builtin.py +++ b/python/pyarrow/tests/test_convert_builtin.py @@ -390,10 +390,17 @@ def test_broken_integers(seq): def test_numpy_scalars_mixed_type(): + # ARROW-4324 data = [np.int32(10), np.float32(0.5)] arr = pa.array(data) - expected = pa.array([10, 0.5], type='float64') + expected = pa.array([10, 0.5], type="float64") + assert arr.equals(expected) + + # ARROW-9490 + data = [np.int8(10), np.float32(0.5)] + arr = pa.array(data) + expected = pa.array([10, 0.5], type="float32") assert arr.equals(expected)