-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-15321: [Dev][Python] Also numpydoc-validate Cython-generated methods #12698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1f0c7b8
a45a770
05ec1c7
b021998
9a29aa9
dd5c342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,15 +303,22 @@ def lint(ctx, src, fix, iwyu_all, **checks): | |
| sys.exit(1) | ||
|
|
||
|
|
||
| def _flatten_numpydoc_rules(rules): | ||
| flattened = [] | ||
| for rule in rules: | ||
| flattened.extend(filter(None, rule.split(','))) | ||
| return flattened | ||
|
|
||
|
|
||
| @archery.command(short_help="Lint python docstring with NumpyDoc") | ||
| @click.argument('symbols', nargs=-1) | ||
| @click.option("--src", metavar="<arrow_src>", default=None, | ||
| callback=validate_arrow_sources, | ||
| help="Specify Arrow source directory") | ||
| @click.option("--allow-rule", "-a", multiple=True, | ||
| help="Allow only these rules") | ||
| help="Allow only these rules (can be comma-separated)") | ||
|
||
| @click.option("--disallow-rule", "-d", multiple=True, | ||
| help="Disallow these rules") | ||
| help="Disallow these rules (can be comma-separated)") | ||
| def numpydoc(src, symbols, allow_rule, disallow_rule): | ||
| """ | ||
| Pass list of modules or symbols as arguments to restrict the validation. | ||
|
|
@@ -326,8 +333,9 @@ def numpydoc(src, symbols, allow_rule, disallow_rule): | |
| """ | ||
| disallow_rule = disallow_rule or {'GL01', 'SA01', 'EX01', 'ES01'} | ||
| try: | ||
| results = python_numpydoc(symbols, allow_rules=allow_rule, | ||
| disallow_rules=disallow_rule) | ||
| results = python_numpydoc( | ||
| symbols, allow_rules=_flatten_numpydoc_rules(allow_rule), | ||
| disallow_rules=_flatten_numpydoc_rules(disallow_rule)) | ||
| for result in results: | ||
| result.ok() | ||
| except LintValidationException: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -313,6 +313,17 @@ cdef class Function(_Weakrefable): | |
| MemoryPool memory_pool=None): | ||
| """ | ||
| Call the function on the given arguments. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| args : iterable | ||
| The arguments to pass to the function. Accepted types depend | ||
| on the specific function. | ||
| options : FunctionOptions, optional | ||
| Options instance for executing this function. This should have | ||
| the right concrete options type. | ||
| memory_pool : pyarrow.MemoryPool, optional | ||
| If not passed, will allocate memory from the default memory pool. | ||
| """ | ||
| cdef: | ||
| const CFunctionOptions* c_options = NULL | ||
|
|
@@ -2005,8 +2016,8 @@ cdef class Expression(_Weakrefable): | |
| ``|`` (logical or) and ``~`` (logical not). | ||
| Note: python keywords ``and``, ``or`` and ``not`` cannot be used | ||
| to combine expressions. | ||
| - Check whether the expression is contained in a list of values with | ||
| the ``pyarrow.compute.Expression.isin()`` member function. | ||
| - Create expression predicates using Expression methods such as | ||
| ``pyarrow.compute.Expression.isin()``. | ||
|
|
||
| Examples | ||
| -------- | ||
|
|
@@ -2130,21 +2141,76 @@ cdef class Expression(_Weakrefable): | |
| return Expression._call("divide_checked", [self, other]) | ||
|
|
||
| def is_valid(self): | ||
| """Checks whether the expression is not-null (valid)""" | ||
| """ | ||
| Check whether the expression is not-null (valid). | ||
|
|
||
| This creates a new expression equivalent to calling the | ||
| `is_valid` compute function on this expression. | ||
|
|
||
| Returns | ||
| ------- | ||
| is_valid : Expression | ||
|
||
| """ | ||
| return Expression._call("is_valid", [self]) | ||
|
|
||
| def is_null(self, bint nan_is_null=False): | ||
| """Checks whether the expression is null""" | ||
| """ | ||
| Check whether the expression is null. | ||
|
|
||
| This creates a new expression equivalent to calling the | ||
| `is_null` compute function on this expression. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| nan_is_null : boolean, default False | ||
| Whether floating-point NaNs are considered null. | ||
|
|
||
| Returns | ||
| ------- | ||
| is_null : Expression | ||
| """ | ||
| options = NullOptions(nan_is_null=nan_is_null) | ||
| return Expression._call("is_null", [self], options) | ||
|
|
||
| def cast(self, type, bint safe=True): | ||
| """Explicitly change the expression's data type""" | ||
| """ | ||
| Explicitly set or change the expression's data type. | ||
|
|
||
| This creates a new expression equivalent to calling the | ||
| `cast` compute function on this expression. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| type : DataType | ||
| Type to cast array to. | ||
| safe : boolean, default True | ||
| Whether to check for conversion errors such as overflow. | ||
|
|
||
| Returns | ||
| ------- | ||
| cast : Expression | ||
| """ | ||
| options = CastOptions.safe(ensure_type(type)) | ||
| return Expression._call("cast", [self], options) | ||
|
|
||
| def isin(self, values): | ||
| """Checks whether the expression is contained in values""" | ||
| """ | ||
| Check whether the expression is contained in values. | ||
|
|
||
| This creates a new expression equivalent to calling the | ||
| `is_in` compute function on this expression. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| values : Array or iterable | ||
| The values to check for. | ||
|
|
||
| Returns | ||
| ------- | ||
| isin : Expression | ||
| A new expression that, when evaluated, checks whether | ||
| this expression's value is contained in `values`. | ||
| """ | ||
| if not isinstance(values, Array): | ||
| values = lib.array(values) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!