rmnskb commented on code in PR #48619:
URL: https://github.com/apache/arrow/pull/48619#discussion_r2682901489
##########
docs/source/python/compute.rst:
##########
@@ -45,14 +47,14 @@ Many compute functions support both array (chunked or not)
and scalar inputs, but some will mandate either. For example,
``sort_indices`` requires its first and only input to be an array.
-Below are a few simple examples::
+Below are a few simple examples:
+
+.. code-block:: python
- >>> import pyarrow as pa
- >>> import pyarrow.compute as pc
Review Comment:
Did you decide to opt out from the explicit imports? Does the documentation
still compile?
##########
docs/source/python/compute.rst:
##########
@@ -420,42 +411,33 @@ output type need to be defined. Using
:func:`pyarrow.compute.register_scalar_fun
.. code-block:: python
- import numpy as np
-
- import pyarrow as pa
- import pyarrow.compute as pc
-
- function_name = "numpy_gcd"
- function_docs = {
- "summary": "Calculates the greatest common divisor",
- "description":
- "Given 'x' and 'y' find the greatest number that divides\n"
- "evenly into both x and y."
- }
-
- input_types = {
- "x" : pa.int64(),
- "y" : pa.int64()
- }
-
- output_type = pa.int64()
-
- def to_np(val):
- if isinstance(val, pa.Scalar):
- return val.as_py()
- else:
- return np.array(val)
-
- def gcd_numpy(ctx, x, y):
- np_x = to_np(x)
- np_y = to_np(y)
- return pa.array(np.gcd(np_x, np_y))
-
- pc.register_scalar_function(gcd_numpy,
- function_name,
- function_docs,
- input_types,
- output_type)
+ >>> import numpy as np
+ >>> function_name = "numpy_gcd"
+ >>> function_docs = {
+ ... "summary": "Calculates the greatest common divisor",
+ ... "description":
+ ... "Given 'x' and 'y' find the greatest number that divides\n"
+ ... "evenly into both x and y."
+ ... }
+ >>> input_types = {
+ ... "x" : pa.int64(),
+ ... "y" : pa.int64()
+ ... }
+ >>> output_type = pa.int64()
+ >>> def to_np(val):
+ ... if isinstance(val, pa.Scalar):
+ ... return val.as_py()
+ ... else:
+ ... return np.array(val)
+ >>> def gcd_numpy(ctx, x, y):
Review Comment:
Probably a nitpick, but why no blank lines between the function definitions?
:thinking:
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]