Skip to content

Commit c62d687

Browse files
committed
Documentation updates to make the formatting more consistent with the rest of the site and to correct some errors when building the rst files using autoapi
1 parent 8e1d5eb commit c62d687

File tree

2 files changed

+41
-52
lines changed

2 files changed

+41
-52
lines changed

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
autoapi_member_order = "groupwise"
7272
suppress_warnings = ["autoapi.python_import_resolution"]
7373
autoapi_python_class_content = "both"
74+
autoapi_keep_files = False # set to True for debugging generated files
7475

7576

7677
def autoapi_skip_member_fn(app, what, name, obj, skip, options) -> bool: # noqa: ARG001

python/datafusion/user_defined.py

Lines changed: 40 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,18 @@ def udf(
134134
def udf(*args: Any, **kwargs: Any): # noqa: D417
135135
"""Create a new User-Defined Function (UDF).
136136
137-
This class can be used both as a **function** and as a **decorator**.
137+
This class can be used both as either a function or a decorator.
138138
139139
Usage:
140-
- **As a function**: Call `udf(func, input_types, return_type, volatility,
141-
name)`.
142-
- **As a decorator**: Use `@udf(input_types, return_type, volatility,
143-
name)`. In this case, do **not** pass `func` explicitly.
140+
- As a function: ``udf(func, input_types, return_type, volatility, name)``.
141+
- As a decorator: ``@udf(input_types, return_type, volatility, name)``.
142+
When used a decorator, do **not** pass ``func`` explicitly.
144143
145144
Args:
146-
func (Callable, optional): **Only needed when calling as a function.**
147-
Skip this argument when using `udf` as a decorator.
145+
func (Callable, optional): Only needed when calling as a function.
146+
Skip this argument when using ``udf`` as a decorator.
148147
input_types (list[pa.DataType]): The data types of the arguments
149-
to `func`. This list must be of the same length as the number of
148+
to ``func``. This list must be of the same length as the number of
150149
arguments.
151150
return_type (_R): The data type of the return value from the function.
152151
volatility (Volatility | str): See `Volatility` for allowed values.
@@ -156,21 +155,18 @@ def udf(*args: Any, **kwargs: Any): # noqa: D417
156155
A user-defined function that can be used in SQL expressions,
157156
data aggregation, or window function calls.
158157
159-
Example:
160-
**Using `udf` as a function:**
161-
```
158+
Example: Using ``udf`` as a function::
159+
162160
def double_func(x):
163161
return x * 2
164162
double_udf = udf(double_func, [pa.int32()], pa.int32(),
165163
"volatile", "double_it")
166-
```
167164
168-
**Using `udf` as a decorator:**
169-
```
165+
Example: Using ``udf`` as a decorator::
166+
170167
@udf([pa.int32()], pa.int32(), "volatile", "double_it")
171168
def double_udf(x):
172169
return x * 2
173-
```
174170
"""
175171

176172
def _function(
@@ -306,24 +302,22 @@ def udaf(
306302
def udaf(*args: Any, **kwargs: Any): # noqa: D417
307303
"""Create a new User-Defined Aggregate Function (UDAF).
308304
309-
This class allows you to define an **aggregate function** that can be used in
305+
This class allows you to define an aggregate function that can be used in
310306
data aggregation or window function calls.
311307
312308
Usage:
313-
- **As a function**: Call `udaf(accum, input_types, return_type, state_type,
314-
volatility, name)`.
315-
- **As a decorator**: Use `@udaf(input_types, return_type, state_type,
316-
volatility, name)`.
317-
When using `udaf` as a decorator, **do not pass `accum` explicitly**.
318-
319-
**Function example:**
320-
321-
If your `:py:class:Accumulator` can be instantiated with no arguments, you
322-
can simply pass it's type as `accum`. If you need to pass additional
323-
arguments to it's constructor, you can define a lambda or a factory method.
324-
During runtime the `:py:class:Accumulator` will be constructed for every
325-
instance in which this UDAF is used. The following examples are all valid.
326-
```
309+
- As a function: ``udaf(accum, input_types, return_type, state_type, volatility, name)``.
310+
- As a decorator: ``@udaf(input_types, return_type, state_type, volatility, name)``.
311+
When using ``udaf`` as a decorator, do not pass ``accum`` explicitly.
312+
313+
Function example:
314+
315+
If your :py:class:`Accumulator` can be instantiated with no arguments, you
316+
can simply pass it's type as `accum`. If you need to pass additional
317+
arguments to it's constructor, you can define a lambda or a factory method.
318+
During runtime the :py:class:`Accumulator` will be constructed for every
319+
instance in which this UDAF is used. The following examples are all valid::
320+
327321
import pyarrow as pa
328322
import pyarrow.compute as pc
329323
@@ -352,18 +346,16 @@ def sum_bias_10() -> Summarize:
352346
"immutable")
353347
udaf3 = udaf(lambda: Summarize(20.0), pa.float64(), pa.float64(),
354348
[pa.float64()], "immutable")
355-
```
356349
357-
**Decorator example:**
358-
```
350+
Decorator example:::
351+
359352
@udaf(pa.float64(), pa.float64(), [pa.float64()], "immutable")
360353
def udf4() -> Summarize:
361354
return Summarize(10.0)
362-
```
363355
364356
Args:
365-
accum: The accumulator python function. **Only needed when calling as a
366-
function. Skip this argument when using `udaf` as a decorator.**
357+
accum: The accumulator python function. Only needed when calling as a
358+
function. Skip this argument when using ``udaf`` as a decorator.
367359
input_types: The data types of the arguments to ``accum``.
368360
return_type: The data type of the return value.
369361
state_type: The data types of the intermediate accumulation.
@@ -373,7 +365,7 @@ def udf4() -> Summarize:
373365
Returns:
374366
A user-defined aggregate function, which can be used in either data
375367
aggregation or window function calls.
376-
"""
368+
""" # noqa: E501 W505
377369

378370
def _function(
379371
accum: Callable[[], Accumulator],
@@ -644,17 +636,15 @@ def udwf(
644636
def udwf(*args: Any, **kwargs: Any): # noqa: D417
645637
"""Create a new User-Defined Window Function (UDWF).
646638
647-
This class can be used both as a **function** and as a **decorator**.
639+
This class can be used both as either a function or a decorator.
648640
649641
Usage:
650-
- **As a function**: Call `udwf(func, input_types, return_type, volatility,
651-
name)`.
652-
- **As a decorator**: Use `@udwf(input_types, return_type, volatility,
653-
name)`. When using `udwf` as a decorator, **do not pass `func`
654-
explicitly**.
655-
656-
**Function example:**
657-
```
642+
- As a function: ``udwf(func, input_types, return_type, volatility, name)``.
643+
- As a decorator: ``@udwf(input_types, return_type, volatility, name)``.
644+
When using ``udwf`` as a decorator, do not pass ``func`` explicitly.
645+
646+
Function example::
647+
658648
import pyarrow as pa
659649
660650
class BiasedNumbers(WindowEvaluator):
@@ -672,18 +662,16 @@ def bias_10() -> BiasedNumbers:
672662
udwf2 = udwf(bias_10, pa.int64(), pa.int64(), "immutable")
673663
udwf3 = udwf(lambda: BiasedNumbers(20), pa.int64(), pa.int64(), "immutable")
674664
675-
```
676665
677-
**Decorator example:**
678-
```
666+
Decorator example::
667+
679668
@udwf(pa.int64(), pa.int64(), "immutable")
680669
def biased_numbers() -> BiasedNumbers:
681670
return BiasedNumbers(10)
682-
```
683671
684672
Args:
685-
func: **Only needed when calling as a function. Skip this argument when
686-
using `udwf` as a decorator.**
673+
func: Only needed when calling as a function. Skip this argument when
674+
using ``udwf`` as a decorator.
687675
input_types: The data types of the arguments.
688676
return_type: The data type of the return value.
689677
volatility: See :py:class:`Volatility` for allowed values.

0 commit comments

Comments
 (0)