Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/pyarrow/array.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ def array(object obj, type=None, mask=None, size=None, from_pandas=None,
raise ValueError("Cannot pass a numpy masked array and "
"specify a mask at the same time")
else:
mask = values.mask
# don't use shrunken masks
mask = None if values.mask is np.ma.nomask else values.mask
values = values.data

if hasattr(values, '__arrow_array__'):
Expand Down
7 changes: 7 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,13 @@ def test_array_from_masked():
pa.array(ma, mask=np.array([True, False, False, False]))


def test_array_from_shrunken_masked():
ma = np.ma.array([0], dtype='int64')
result = pa.array(ma)
expected = pa.array([0], type='int64')
assert expected.equals(result)


def test_array_from_invalid_dim_raises():
msg = "only handle 1-dimensional arrays"
arr2d = np.array([[1, 2, 3], [4, 5, 6]])
Expand Down