You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by jo...@apache.org on 2021/12/15 12:32:42 UTC
[arrow] branch master updated: ARROW-14766: [Python] Mark compute function arguments positional-only
This is an automated email from the ASF dual-hosted git repository.
jorisvandenbossche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new a5b4ff7 ARROW-14766: [Python] Mark compute function arguments positional-only
a5b4ff7 is described below
commit a5b4ff7d08da2039bb234ac990fd9b77166562f9
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Wed Dec 15 13:30:52 2021 +0100
ARROW-14766: [Python] Mark compute function arguments positional-only
Indicate to the user, in the generated function signature, that the given arguments cannot be passed by name.
Before:
```
Signature: pc.add(x, y, *, memory_pool=None)
Docstring:
Add the arguments element-wise.
[...]
```
After:
```
Signature: pc.add(x, y, /, *, memory_pool=None)
Docstring:
Add the arguments element-wise.
[...]
```
Closes #11951 from pitrou/ARROW-1476-compute-positional-only
Authored-by: Antoine Pitrou <an...@python.org>
Signed-off-by: Joris Van den Bossche <jo...@gmail.com>
---
python/pyarrow/compute.py | 2 +-
python/pyarrow/tests/test_compute.py | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/python/pyarrow/compute.py b/python/pyarrow/compute.py
index 9dac606..ce51f63 100644
--- a/python/pyarrow/compute.py
+++ b/python/pyarrow/compute.py
@@ -209,7 +209,7 @@ def _make_signature(arg_names, var_arg_names, option_class):
from inspect import Parameter
params = []
for name in arg_names:
- params.append(Parameter(name, Parameter.POSITIONAL_OR_KEYWORD))
+ params.append(Parameter(name, Parameter.POSITIONAL_ONLY))
for name in var_arg_names:
params.append(Parameter(name, Parameter.VAR_POSITIONAL))
params.append(Parameter("memory_pool", Parameter.KEYWORD_ONLY,
diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py
index 9110a3a..0b4ac65 100644
--- a/python/pyarrow/tests/test_compute.py
+++ b/python/pyarrow/tests/test_compute.py
@@ -695,12 +695,12 @@ def test_generated_signatures():
# The self-documentation provided by signatures should show acceptable
# options and their default values.
sig = inspect.signature(pc.add)
- assert str(sig) == "(x, y, *, memory_pool=None)"
+ assert str(sig) == "(x, y, /, *, memory_pool=None)"
sig = inspect.signature(pc.min_max)
- assert str(sig) == ("(array, *, memory_pool=None, "
+ assert str(sig) == ("(array, /, *, memory_pool=None, "
"options=None, skip_nulls=True, min_count=1)")
sig = inspect.signature(pc.quantile)
- assert str(sig) == ("(array, *, memory_pool=None, "
+ assert str(sig) == ("(array, /, *, memory_pool=None, "
"options=None, q=0.5, interpolation='linear', "
"skip_nulls=True, min_count=0)")
sig = inspect.signature(pc.binary_join_element_wise)