Skip to content

Commit 47e3e8c

Browse files
committed
Adding option class in FunctionDocs of vector_swizzle.cc
1 parent fd8f27a commit 47e3e8c

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

cpp/src/arrow/compute/kernels/vector_swizzle.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace {
3232

3333
const FunctionDoc inverse_permutation_doc(
3434
"Return the inverse permutation of the given indices",
35-
"For the `i`-th `index` in `indices`, the `index`-th output is `i`", {"indices"});
35+
"For the `i`-th `index` in `indices`, the `index`-th output is `i`", {"indices"},
36+
"InversePermutationOptions");
3637

3738
const InversePermutationOptions* GetDefaultInversePermutationOptions() {
3839
static const auto kDefaultInversePermutationOptions =
@@ -332,7 +333,7 @@ void RegisterVectorInversePermutation(FunctionRegistry* registry) {
332333
const FunctionDoc scatter_doc(
333334
"Scatter the values into specified positions according to the indices",
334335
"Place the `i`-th value at the position specified by the `i`-th index",
335-
{"values", "indices"});
336+
{"values", "indices"}, "ScatterOptions");
336337

337338
const ScatterOptions* GetDefaultScatterOptions() {
338339
static const auto kDefaultScatterOptions = ScatterOptions::Defaults();

python/pyarrow/tests/test_compute.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
import pyarrow as pa
4242
import pyarrow.compute as pc
43-
from pyarrow.lib import ArrowNotImplementedError
43+
from pyarrow.lib import ArrowNotImplementedError, ArrowIndexError
4444

4545
try:
4646
import pyarrow.substrait as pas
@@ -202,7 +202,7 @@ def test_option_class_equality(request):
202202
pc.WeekOptions(week_starts_monday=True, count_from_zero=False,
203203
first_week_is_fully_in_year=False),
204204
pc.ZeroFillOptions(4, "0"),
205-
pc.InversePermutationOptions(-1, output_type=pa.int32()),
205+
pc.InversePermutationOptions(output_type=pa.int32()),
206206
]
207207
# Timezone database might not be installed on Windows or Emscripten
208208
if request.config.pyarrow.is_enabled["timezone_data"]:
@@ -1596,19 +1596,14 @@ def test_inverse_permutation():
15961596
arr = pa.chunked_array([
15971597
arr0, [9, 7, 5, 3, 1], [0], [2, 4, 6], [8], arr0,
15981598
])
1599-
result = pc.inverse_permutation(arr)
1600-
print(result)
16011599
expected = pa.chunked_array([[5, 4, 6, 3, 7, 2, 8, 1, 9, 0]], type=pa.int32())
1602-
assert result.equals(expected)
1600+
assert pc.inverse_permutation(arr).equals(expected)
16031601

1604-
# `inverse_permutation` kernel currently does not accept options
1605-
options = pc.InversePermutationOptions(max_index=4, output_type=pa.int64())
1606-
print(options)
1607-
with pytest.raises(TypeError, match="an unexpected keyword argument \'options\'"):
1608-
pc.inverse_permutation(arr, options=options)
1602+
options = pc.InversePermutationOptions(max_index=9, output_type=pa.int32())
1603+
assert pc.inverse_permutation(arr, options=options).equals(expected)
1604+
assert pc.inverse_permutation(arr, max_index=-1).equals(expected)
16091605

1610-
# `inverse_permutation` kernel currently won't accept max_index
1611-
with pytest.raises(TypeError, match="an unexpected keyword argument \'max_index\'"):
1606+
with pytest.raises(ArrowIndexError, match="Index out of bounds: 9"):
16121607
pc.inverse_permutation(arr, max_index=4)
16131608

16141609

@@ -1620,13 +1615,11 @@ def test_scatter():
16201615
result = pc.scatter(values, indices)
16211616
assert result.equals(expected)
16221617

1623-
# `scatter` kernel currently does not accept options
1624-
options = pc.ScatterOptions(max_index=4)
1625-
with pytest.raises(TypeError, match="unexpected keyword argument \'options\'"):
1626-
pc.scatter(values, indices, options=options)
1618+
options = pc.ScatterOptions(max_index=-1)
1619+
assert pc.scatter(values, indices, options=options).equals(expected)
1620+
assert pc.scatter(values, indices, max_index=9).equals(expected)
16271621

1628-
# `scatter` kernel currently won't accept max_index
1629-
with pytest.raises(TypeError, match="unexpected keyword argument \'max_index\'"):
1622+
with pytest.raises(ArrowIndexError, match="Index out of bounds: 9"):
16301623
pc.scatter(values, indices, max_index=4)
16311624

16321625

0 commit comments

Comments
 (0)