You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2016/03/28 18:38:19 UTC
arrow git commit: ARROW-80: Handle len call for pre-init arrays
Repository: arrow
Updated Branches:
refs/heads/master 1fd0668a1 -> ecadd0bcb
ARROW-80: Handle len call for pre-init arrays
Author: Uwe L. Korn <uw...@xhochy.com>
Closes #45 from xhochy/arrow-80 and squashes the following commits:
d9a1160 [Uwe L. Korn] Add unit test for repr on pre-init Array
6208d7d [Uwe L. Korn] ARROW-80: Handle len call for pre-init arrays
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/ecadd0bc
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/ecadd0bc
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/ecadd0bc
Branch: refs/heads/master
Commit: ecadd0bcb9f022a5067826ed564f513ffd0c578e
Parents: 1fd0668
Author: Uwe L. Korn <uw...@xhochy.com>
Authored: Mon Mar 28 09:38:13 2016 -0700
Committer: Wes McKinney <we...@apache.org>
Committed: Mon Mar 28 09:38:13 2016 -0700
----------------------------------------------------------------------
python/pyarrow/array.pyx | 5 ++++-
python/pyarrow/tests/test_array.py | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/ecadd0bc/python/pyarrow/array.pyx
----------------------------------------------------------------------
diff --git a/python/pyarrow/array.pyx b/python/pyarrow/array.pyx
index 88770cd..155c965 100644
--- a/python/pyarrow/array.pyx
+++ b/python/pyarrow/array.pyx
@@ -67,7 +67,10 @@ cdef class Array:
return '{0}\n{1}'.format(type_format, values)
def __len__(self):
- return self.sp_array.get().length()
+ if self.sp_array.get():
+ return self.sp_array.get().length()
+ else:
+ return 0
def isnull(self):
raise NotImplemented
http://git-wip-us.apache.org/repos/asf/arrow/blob/ecadd0bc/python/pyarrow/tests/test_array.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py
index 36aaaa4..d608f81 100644
--- a/python/pyarrow/tests/test_array.py
+++ b/python/pyarrow/tests/test_array.py
@@ -22,6 +22,10 @@ import pyarrow.formatting as fmt
class TestArrayAPI(unittest.TestCase):
+ def test_repr_on_pre_init_array(self):
+ arr = pyarrow.array.Array()
+ assert len(repr(arr)) > 0
+
def test_getitem_NA(self):
arr = pyarrow.from_pylist([1, None, 2])
assert arr[1] is pyarrow.NA