MCPcopy Create free account
hub / github.com/apache/arrow / test_take

Function test_take

python/pyarrow/tests/test_compute.py:1465–1487  ·  view source on GitHub ↗
(ty, values)

Source from the content-addressed store, hash-verified

1463
1464@pytest.mark.parametrize(('ty', 'values'), all_array_types)
1465def test_take(ty, values):
1466 arr = pa.array(values, type=ty)
1467 for indices_type in [pa.int8(), pa.int64()]:
1468 indices = pa.array([0, 4, 2, None], type=indices_type)
1469 result = arr.take(indices)
1470 result.validate()
1471 expected = pa.array([values[0], values[4], values[2], None], type=ty)
1472 assert result.equals(expected)
1473
1474 # empty indices
1475 indices = pa.array([], type=indices_type)
1476 result = arr.take(indices)
1477 result.validate()
1478 expected = pa.array([], type=ty)
1479 assert result.equals(expected)
1480
1481 indices = pa.array([2, 5])
1482 with pytest.raises(IndexError):
1483 arr.take(indices)
1484
1485 indices = pa.array([2, -1])
1486 with pytest.raises(IndexError):
1487 arr.take(indices)
1488
1489
1490def test_take_indices_types():

Callers

nothing calls this directly

Calls 4

equalsMethod · 0.80
arrayMethod · 0.45
takeMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected