# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

import numpy as np
import pytest

import pyarrow as pa
import pyarrow.compute


all_array_types = [
    ('bool', [True, False, False, True, True]),
    ('uint8', np.arange(5)),
    ('int8', np.arange(5)),
    ('uint16', np.arange(5)),
    ('int16', np.arange(5)),
    ('uint32', np.arange(5)),
    ('int32', np.arange(5)),
    ('uint64', np.arange(5, 10)),
    ('int64', np.arange(5, 10)),
    ('float', np.arange(0, 0.5, 0.1)),
    ('double', np.arange(0, 0.5, 0.1)),
    ('string', ['a', 'b', None, 'ddd', 'ee']),
    ('binary', [b'a', b'b', b'c', b'ddd', b'ee']),
    (pa.binary(3), [b'abc', b'bcd', b'cde', b'def', b'efg']),
    (pa.list_(pa.int8()), [[1, 2], [3, 4], [5, 6], None, [9, 16]]),
    (pa.large_list(pa.int16()), [[1], [2, 3, 4], [5, 6], None, [9, 16]]),
    (pa.struct([('a', pa.int8()), ('b', pa.int8())]), [
     {'a': 1, 'b': 2}, None, {'a': 3, 'b': 4}, None, {'a': 5, 'b': 6}]),
]


numerical_arrow_types = [
    pa.int8(),
    pa.int16(),
    pa.int64(),
    pa.uint8(),
    pa.uint16(),
    pa.uint64(),
    pa.float32(),
    pa.float64()
]


@pytest.mark.parametrize('arrow_type', numerical_arrow_types)
def test_sum_array(arrow_type):
    arr = pa.array([1, 2, 3, 4], type=arrow_type)
    assert arr.sum() == 10
    assert pa.compute.sum(arr) == 10

    arr = pa.array([], type=arrow_type)
    assert arr.sum() == None  # noqa: E711
    assert pa.compute.sum(arr) == None  # noqa: E711


@pytest.mark.parametrize('arrow_type', numerical_arrow_types)
def test_sum_chunked_array(arrow_type):
    arr = pa.chunked_array([pa.array([1, 2, 3, 4], type=arrow_type)])
    assert pa.compute.sum(arr) == 10

    arr = pa.chunked_array([
        pa.array([1, 2], type=arrow_type), pa.array([3, 4], type=arrow_type)
    ])
    assert pa.compute.sum(arr) == 10

    arr = pa.chunked_array([
        pa.array([1, 2], type=arrow_type),
        pa.array([], type=arrow_type),
        pa.array([3, 4], type=arrow_type)
    ])
    assert pa.compute.sum(arr) == 10

    arr = pa.chunked_array((), type=arrow_type)
    print(arr, type(arr))
    assert arr.num_chunks == 0
    assert pa.compute.sum(arr) == None  # noqa: E711


@pytest.mark.parametrize(('ty', 'values'), all_array_types)
def test_take(ty, values):
    arr = pa.array(values, type=ty)
    for indices_type in [pa.int8(), pa.int64()]:
        indices = pa.array([0, 4, 2, None], type=indices_type)
        result = arr.take(indices)
        result.validate()
        expected = pa.array([values[0], values[4], values[2], None], type=ty)
        assert result.equals(expected)

        # empty indices
        indices = pa.array([], type=indices_type)
        result = arr.take(indices)
        result.validate()
        expected = pa.array([], type=ty)
        assert result.equals(expected)

    indices = pa.array([2, 5])
    with pytest.raises(IndexError):
        arr.take(indices)

    indices = pa.array([2, -1])
    with pytest.raises(IndexError):
        arr.take(indices)


def test_take_indices_types():
    arr = pa.array(range(5))

    for indices_type in ['uint8', 'int8', 'uint16', 'int16',
                         'uint32', 'int32', 'uint64', 'int64']:
        indices = pa.array([0, 4, 2, None], type=indices_type)
        result = arr.take(indices)
        result.validate()
        expected = pa.array([0, 4, 2, None])
        assert result.equals(expected)

    for indices_type in [pa.float32(), pa.float64()]:
        indices = pa.array([0, 4, 2], type=indices_type)
        with pytest.raises(NotImplementedError):
            arr.take(indices)


@pytest.mark.parametrize('ordered', [False, True])
def test_take_dictionary(ordered):
    arr = pa.DictionaryArray.from_arrays([0, 1, 2, 0, 1, 2], ['a', 'b', 'c'],
                                         ordered=ordered)
    result = arr.take(pa.array([0, 1, 3]))
    result.validate()
    assert result.to_pylist() == ['a', 'b', 'a']
    assert result.dictionary.to_pylist() == ['a', 'b', 'c']
    assert result.type.ordered is ordered


@pytest.mark.parametrize(('ty', 'values'), all_array_types)
def test_filter(ty, values):
    arr = pa.array(values, type=ty)

    mask = pa.array([True, False, False, True, None])
    result = arr.filter(mask, null_selection_behavior='drop')
    result.validate()
    assert result.equals(pa.array([values[0], values[3]], type=ty))
    result = arr.filter(mask, null_selection_behavior='emit_null')
    result.validate()
    assert result.equals(pa.array([values[0], values[3], None], type=ty))

    # non-boolean dtype
    mask = pa.array([0, 1, 0, 1, 0])
    with pytest.raises(NotImplementedError):
        arr.filter(mask)

    # wrong length
    mask = pa.array([True, False, True])
    with pytest.raises(ValueError, match="must all be the same length"):
        arr.filter(mask)


def test_filter_chunked_array():
    arr = pa.chunked_array([["a", None], ["c", "d", "e"]])
    expected_drop = pa.chunked_array([["a"], ["e"]])
    expected_null = pa.chunked_array([["a"], [None, "e"]])

    for mask in [
        # mask is array
        pa.array([True, False, None, False, True]),
        # mask is chunked array
        pa.chunked_array([[True, False, None], [False, True]]),
        # mask is python object
        [True, False, None, False, True]
    ]:
        result = arr.filter(mask)
        assert result.equals(expected_drop)
        result = arr.filter(mask, null_selection_behavior="emit_null")
        assert result.equals(expected_null)


def test_filter_record_batch():
    batch = pa.record_batch(
        [pa.array(["a", None, "c", "d", "e"])], names=["a'"])

    # mask is array
    mask = pa.array([True, False, None, False, True])
    result = batch.filter(mask)
    expected = pa.record_batch([pa.array(["a", "e"])], names=["a'"])
    assert result.equals(expected)

    result = batch.filter(mask, null_selection_behavior="emit_null")
    expected = pa.record_batch([pa.array(["a", None, "e"])], names=["a'"])
    assert result.equals(expected)


def test_filter_table():
    table = pa.table([pa.array(["a", None, "c", "d", "e"])], names=["a"])
    expected_drop = pa.table([pa.array(["a", "e"])], names=["a"])
    expected_null = pa.table([pa.array(["a", None, "e"])], names=["a"])

    for mask in [
        # mask is array
        pa.array([True, False, None, False, True]),
        # mask is chunked array
        pa.chunked_array([[True, False], [None, False, True]]),
        # mask is python object
        [True, False, None, False, True]
    ]:
        result = table.filter(mask)
        assert result.equals(expected_drop)
        result = table.filter(mask, null_selection_behavior="emit_null")
        assert result.equals(expected_null)


def test_filter_errors():
    arr = pa.chunked_array([["a", None], ["c", "d", "e"]])
    batch = pa.record_batch(
        [pa.array(["a", None, "c", "d", "e"])], names=["a'"])
    table = pa.table([pa.array(["a", None, "c", "d", "e"])], names=["a"])

    for obj in [arr, batch, table]:
        # non-boolean dtype
        mask = pa.array([0, 1, 0, 1, 0])
        with pytest.raises(NotImplementedError):
            obj.filter(mask)

        # wrong length
        mask = pa.array([True, False, True])
        with pytest.raises(pa.ArrowInvalid,
                           match="must all be the same length"):
            obj.filter(mask)


@pytest.mark.parametrize("typ", ["array", "chunked_array"])
def test_compare_array(typ):
    if typ == "array":
        def con(values): return pa.array(values)
    else:
        def con(values): return pa.chunked_array([values])

    arr1 = con([1, 2, 3, 4, None])
    arr2 = con([1, 1, 4, None, 4])

    result = arr1 == arr2
    assert result.equals(con([True, False, False, None, None]))

    result = arr1 != arr2
    assert result.equals(con([False, True, True, None, None]))

    result = arr1 < arr2
    assert result.equals(con([False, False, True, None, None]))

    result = arr1 <= arr2
    assert result.equals(con([True, False, True, None, None]))

    result = arr1 > arr2
    assert result.equals(con([False, True, False, None, None]))

    result = arr1 >= arr2
    assert result.equals(con([True, True, False, None, None]))


@pytest.mark.parametrize("typ", ["array", "chunked_array"])
def test_compare_scalar(typ):
    if typ == "array":
        def con(values): return pa.array(values)
    else:
        def con(values): return pa.chunked_array([values])

    arr = con([1, 2, 3, None])
    # TODO this is a hacky way to construct a scalar ..
    scalar = pa.array([2]).sum()

    result = arr == scalar
    assert result.equals(con([False, True, False, None]))

    result = arr != scalar
    assert result.equals(con([True, False, True, None]))

    result = arr < scalar
    assert result.equals(con([True, False, False, None]))

    result = arr <= scalar
    assert result.equals(con([True, True, False, None]))

    result = arr > scalar
    assert result.equals(con([False, False, True, None]))

    result = arr >= scalar
    assert result.equals(con([False, True, True, None]))


def test_compare_chunked_array_mixed():
    arr = pa.array([1, 2, 3, 4, None])
    arr_chunked = pa.chunked_array([[1, 2, 3], [4, None]])
    arr_chunked2 = pa.chunked_array([[1, 2], [3, 4, None]])

    expected = pa.chunked_array([[True, True, True, True, None]])

    for result in [
        arr == arr_chunked,
        arr_chunked == arr,
        arr_chunked == arr_chunked2,
    ]:
        assert result.equals(expected)


def test_arithmetic_add():
    left = pa.array([1, 2, 3, 4, 5])
    right = pa.array([0, -1, 1, 2, 3])
    result = pa.compute.add(left, right)
    expected = pa.array([1, 1, 4, 6, 8])
    assert result.equals(expected)


def test_arithmetic_subtract():
    left = pa.array([1, 2, 3, 4, 5])
    right = pa.array([0, -1, 1, 2, 3])
    result = pa.compute.subtract(left, right)
    expected = pa.array([1, 3, 2, 2, 2])
    assert result.equals(expected)


def test_arithmetic_multiply():
    left = pa.array([1, 2, 3, 4, 5])
    right = pa.array([0, -1, 1, 2, 3])
    result = pa.compute.multiply(left, right)
    expected = pa.array([0, -2, 3, 8, 15])
    assert result.equals(expected)

[(59, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""arrow_type"""', 'numerical_arrow_types'], {}), False, 'import pytest\n'), (70, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""arrow_type"""', 'numerical_arrow_types'], {}), False, 'import pytest\n'), (93, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (["('ty', 'values')", 'all_array_types'], {}), False, 'import pytest\n'), (136, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""ordered"""', '[False, True]'], {}), False, 'import pytest\n'), (147, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (["('ty', 'values')", 'all_array_types'], {}), False, 'import pytest\n'), (242, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""typ"""', "['array', 'chunked_array']"], {}), False, 'import pytest\n'), (271, 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""typ"""', "['array', 'chunked_array']"], {}), False, 'import pytest\n'), (48, 'pyarrow.int8', 'pa.int8', ([], {}), True, 'import pyarrow as pa\n'), (49, 'pyarrow.int16', 'pa.int16', ([], {}), True, 'import pyarrow as pa\n'), (50, 'pyarrow.int64', 'pa.int64', ([], {}), True, 'import pyarrow as pa\n'), (51, 'pyarrow.uint8', 'pa.uint8', ([], {}), True, 'import pyarrow as pa\n'), (52, 'pyarrow.uint16', 'pa.uint16', ([], {}), True, 'import pyarrow as pa\n'), (53, 'pyarrow.uint64', 'pa.uint64', ([], {}), True, 'import pyarrow as pa\n'), (54, 'pyarrow.float32', 'pa.float32', ([], {}), True, 'import pyarrow as pa\n'), (55, 'pyarrow.float64', 'pa.float64', ([], {}), True, 'import pyarrow as pa\n'), (61, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (65, 'pyarrow.array', 'pa.array', (['[]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (87, 'pyarrow.chunked_array', 'pa.chunked_array', (['()'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (95, 'pyarrow.array', 'pa.array', (['values'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (110, 'pyarrow.array', 'pa.array', (['[2, 5]'], {}), True, 'import pyarrow as pa\n'), (114, 'pyarrow.array', 'pa.array', (['[2, -1]'], {}), True, 'import pyarrow as pa\n'), (138, 'pyarrow.DictionaryArray.from_arrays', 'pa.DictionaryArray.from_arrays', (['[0, 1, 2, 0, 1, 2]', "['a', 'b', 'c']"], {'ordered': 'ordered'}), True, 'import pyarrow as pa\n'), (149, 'pyarrow.array', 'pa.array', (['values'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (151, 'pyarrow.array', 'pa.array', (['[True, False, False, True, None]'], {}), True, 'import pyarrow as pa\n'), (160, 'pyarrow.array', 'pa.array', (['[0, 1, 0, 1, 0]'], {}), True, 'import pyarrow as pa\n'), (165, 'pyarrow.array', 'pa.array', (['[True, False, True]'], {}), True, 'import pyarrow as pa\n'), (171, 'pyarrow.chunked_array', 'pa.chunked_array', (["[['a', None], ['c', 'd', 'e']]"], {}), True, 'import pyarrow as pa\n'), (172, 'pyarrow.chunked_array', 'pa.chunked_array', (["[['a'], ['e']]"], {}), True, 'import pyarrow as pa\n'), (173, 'pyarrow.chunked_array', 'pa.chunked_array', (["[['a'], [None, 'e']]"], {}), True, 'import pyarrow as pa\n'), (194, 'pyarrow.array', 'pa.array', (['[True, False, None, False, True]'], {}), True, 'import pyarrow as pa\n'), (224, 'pyarrow.chunked_array', 'pa.chunked_array', (["[['a', None], ['c', 'd', 'e']]"], {}), True, 'import pyarrow as pa\n'), (302, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4, None]'], {}), True, 'import pyarrow as pa\n'), (303, 'pyarrow.chunked_array', 'pa.chunked_array', (['[[1, 2, 3], [4, None]]'], {}), True, 'import pyarrow as pa\n'), (304, 'pyarrow.chunked_array', 'pa.chunked_array', (['[[1, 2], [3, 4, None]]'], {}), True, 'import pyarrow as pa\n'), (306, 'pyarrow.chunked_array', 'pa.chunked_array', (['[[True, True, True, True, None]]'], {}), True, 'import pyarrow as pa\n'), (317, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import pyarrow as pa\n'), (318, 'pyarrow.array', 'pa.array', (['[0, -1, 1, 2, 3]'], {}), True, 'import pyarrow as pa\n'), (319, 'pyarrow.compute.add', 'pa.compute.add', (['left', 'right'], {}), True, 'import pyarrow as pa\n'), (320, 'pyarrow.array', 'pa.array', (['[1, 1, 4, 6, 8]'], {}), True, 'import pyarrow as pa\n'), (325, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import pyarrow as pa\n'), (326, 'pyarrow.array', 'pa.array', (['[0, -1, 1, 2, 3]'], {}), True, 'import pyarrow as pa\n'), (327, 'pyarrow.compute.subtract', 'pa.compute.subtract', (['left', 'right'], {}), True, 'import pyarrow as pa\n'), (328, 'pyarrow.array', 'pa.array', (['[1, 3, 2, 2, 2]'], {}), True, 'import pyarrow as pa\n'), (333, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4, 5]'], {}), True, 'import pyarrow as pa\n'), (334, 'pyarrow.array', 'pa.array', (['[0, -1, 1, 2, 3]'], {}), True, 'import pyarrow as pa\n'), (335, 'pyarrow.compute.multiply', 'pa.compute.multiply', (['left', 'right'], {}), True, 'import pyarrow as pa\n'), (336, 'pyarrow.array', 'pa.array', (['[0, -2, 3, 8, 15]'], {}), True, 'import pyarrow as pa\n'), (27, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (28, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (29, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (30, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (31, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (32, 'numpy.arange', 'np.arange', (['(5)'], {}), True, 'import numpy as np\n'), (33, 'numpy.arange', 'np.arange', (['(5)', '(10)'], {}), True, 'import numpy as np\n'), (34, 'numpy.arange', 'np.arange', (['(5)', '(10)'], {}), True, 'import numpy as np\n'), (35, 'numpy.arange', 'np.arange', (['(0)', '(0.5)', '(0.1)'], {}), True, 'import numpy as np\n'), (36, 'numpy.arange', 'np.arange', (['(0)', '(0.5)', '(0.1)'], {}), True, 'import numpy as np\n'), (39, 'pyarrow.binary', 'pa.binary', (['(3)'], {}), True, 'import pyarrow as pa\n'), (63, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (67, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (73, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (78, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (85, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (90, 'pyarrow.compute.sum', 'pa.compute.sum', (['arr'], {}), True, 'import pyarrow as pa\n'), (96, 'pyarrow.int8', 'pa.int8', ([], {}), True, 'import pyarrow as pa\n'), (96, 'pyarrow.int64', 'pa.int64', ([], {}), True, 'import pyarrow as pa\n'), (97, 'pyarrow.array', 'pa.array', (['[0, 4, 2, None]'], {'type': 'indices_type'}), True, 'import pyarrow as pa\n'), (100, 'pyarrow.array', 'pa.array', (['[values[0], values[4], values[2], None]'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (104, 'pyarrow.array', 'pa.array', (['[]'], {'type': 'indices_type'}), True, 'import pyarrow as pa\n'), (107, 'pyarrow.array', 'pa.array', (['[]'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (111, 'pytest.raises', 'pytest.raises', (['IndexError'], {}), False, 'import pytest\n'), (115, 'pytest.raises', 'pytest.raises', (['IndexError'], {}), False, 'import pytest\n'), (124, 'pyarrow.array', 'pa.array', (['[0, 4, 2, None]'], {'type': 'indices_type'}), True, 'import pyarrow as pa\n'), (127, 'pyarrow.array', 'pa.array', (['[0, 4, 2, None]'], {}), True, 'import pyarrow as pa\n'), (130, 'pyarrow.float32', 'pa.float32', ([], {}), True, 'import pyarrow as pa\n'), (130, 'pyarrow.float64', 'pa.float64', ([], {}), True, 'import pyarrow as pa\n'), (131, 'pyarrow.array', 'pa.array', (['[0, 4, 2]'], {'type': 'indices_type'}), True, 'import pyarrow as pa\n'), (140, 'pyarrow.array', 'pa.array', (['[0, 1, 3]'], {}), True, 'import pyarrow as pa\n'), (154, 'pyarrow.array', 'pa.array', (['[values[0], values[3]]'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (157, 'pyarrow.array', 'pa.array', (['[values[0], values[3], None]'], {'type': 'ty'}), True, 'import pyarrow as pa\n'), (161, 'pytest.raises', 'pytest.raises', (['NotImplementedError'], {}), False, 'import pytest\n'), (166, 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""must all be the same length"""'}), False, 'import pytest\n'), (177, 'pyarrow.array', 'pa.array', (['[True, False, None, False, True]'], {}), True, 'import pyarrow as pa\n'), (179, 'pyarrow.chunked_array', 'pa.chunked_array', (['[[True, False, None], [False, True]]'], {}), True, 'import pyarrow as pa\n'), (211, 'pyarrow.array', 'pa.array', (['[True, False, None, False, True]'], {}), True, 'import pyarrow as pa\n'), (213, 'pyarrow.chunked_array', 'pa.chunked_array', (['[[True, False], [None, False, True]]'], {}), True, 'import pyarrow as pa\n'), (231, 'pyarrow.array', 'pa.array', (['[0, 1, 0, 1, 0]'], {}), True, 'import pyarrow as pa\n'), (236, 'pyarrow.array', 'pa.array', (['[True, False, True]'], {}), True, 'import pyarrow as pa\n'), (40, 'pyarrow.int8', 'pa.int8', ([], {}), True, 'import pyarrow as pa\n'), (41, 'pyarrow.int16', 'pa.int16', ([], {}), True, 'import pyarrow as pa\n'), (72, 'pyarrow.array', 'pa.array', (['[1, 2, 3, 4]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (76, 'pyarrow.array', 'pa.array', (['[1, 2]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (76, 'pyarrow.array', 'pa.array', (['[3, 4]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (81, 'pyarrow.array', 'pa.array', (['[1, 2]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (82, 'pyarrow.array', 'pa.array', (['[]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (83, 'pyarrow.array', 'pa.array', (['[3, 4]'], {'type': 'arrow_type'}), True, 'import pyarrow as pa\n'), (132, 'pytest.raises', 'pytest.raises', (['NotImplementedError'], {}), False, 'import pytest\n'), (191, 'pyarrow.array', 'pa.array', (["['a', None, 'c', 'd', 'e']"], {}), True, 'import pyarrow as pa\n'), (196, 'pyarrow.array', 'pa.array', (["['a', 'e']"], {}), True, 'import pyarrow as pa\n'), (200, 'pyarrow.array', 'pa.array', (["['a', None, 'e']"], {}), True, 'import pyarrow as pa\n'), (205, 'pyarrow.array', 'pa.array', (["['a', None, 'c', 'd', 'e']"], {}), True, 'import pyarrow as pa\n'), (206, 'pyarrow.array', 'pa.array', (["['a', 'e']"], {}), True, 'import pyarrow as pa\n'), (207, 'pyarrow.array', 'pa.array', (["['a', None, 'e']"], {}), True, 'import pyarrow as pa\n'), (226, 'pyarrow.array', 'pa.array', (["['a', None, 'c', 'd', 'e']"], {}), True, 'import pyarrow as pa\n'), (227, 'pyarrow.array', 'pa.array', (["['a', None, 'c', 'd', 'e']"], {}), True, 'import pyarrow as pa\n'), (232, 'pytest.raises', 'pytest.raises', (['NotImplementedError'], {}), False, 'import pytest\n'), (237, 'pytest.raises', 'pytest.raises', (['pa.ArrowInvalid'], {'match': '"""must all be the same length"""'}), False, 'import pytest\n'), (245, 'pyarrow.array', 'pa.array', (['values'], {}), True, 'import pyarrow as pa\n'), (247, 'pyarrow.chunked_array', 'pa.chunked_array', (['[values]'], {}), True, 'import pyarrow as pa\n'), (274, 'pyarrow.array', 'pa.array', (['values'], {}), True, 'import pyarrow as pa\n'), (276, 'pyarrow.chunked_array', 'pa.chunked_array', (['[values]'], {}), True, 'import pyarrow as pa\n'), (280, 'pyarrow.array', 'pa.array', (['[2]'], {}), True, 'import pyarrow as pa\n'), (42, 'pyarrow.int8', 'pa.int8', ([], {}), True, 'import pyarrow as pa\n'), (42, 'pyarrow.int8', 'pa.int8', ([], {}), True, 'import pyarrow as pa\n')]