You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2019/08/08 15:30:58 UTC
[arrow] branch master updated: ARROW-6132: [Python] validate result
in ListArray.from_arrays
This is an automated email from the ASF dual-hosted git repository.
apitrou 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 3e6d75b ARROW-6132: [Python] validate result in ListArray.from_arrays
3e6d75b is described below
commit 3e6d75b6db46dba186ed1a91e77ab95ffeb92888
Author: Joris Van den Bossche <jo...@gmail.com>
AuthorDate: Thu Aug 8 17:30:43 2019 +0200
ARROW-6132: [Python] validate result in ListArray.from_arrays
https://issues.apache.org/jira/browse/ARROW-6132
Closes #5029 from jorisvandenbossche/ARROW-6132-from_arrays-check-validity and squashes the following commits:
5fe476eca <Joris Van den Bossche> ARROW-6132: validate result in ListArray.from_arrays
Authored-by: Joris Van den Bossche <jo...@gmail.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
python/pyarrow/array.pxi | 8 ++++++--
python/pyarrow/tests/test_array.py | 6 ++++++
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi
index b93cf10..cd6c190 100644
--- a/python/pyarrow/array.pxi
+++ b/python/pyarrow/array.pxi
@@ -1050,7 +1050,9 @@ cdef class ListArray(Array):
with nogil:
check_status(CListArray.FromArrays(_offsets.ap[0], _values.ap[0],
cpool, &out))
- return pyarrow_wrap_array(out)
+ cdef Array result = pyarrow_wrap_array(out)
+ result.validate()
+ return result
@property
def values(self):
@@ -1102,7 +1104,9 @@ cdef class LargeListArray(Array):
check_status(CLargeListArray.FromArrays(_offsets.ap[0],
_values.ap[0],
cpool, &out))
- return pyarrow_wrap_array(out)
+ cdef Array result = pyarrow_wrap_array(out)
+ result.validate()
+ return result
def flatten(self):
"""
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index 03db7e9..350922f 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -520,6 +520,12 @@ def test_list_from_arrays(list_array_type, list_type_factory):
type=list_type_factory(pa.binary()))
assert result.equals(expected)
+ # raise on invalid array
+ offsets = [1, 3, 10]
+ values = np.arange(5)
+ with pytest.raises(ValueError):
+ list_array_type.from_arrays(offsets, values)
+
def test_union_from_dense():
binary = pa.array([b'a', b'b', b'c', b'd'], type='binary')