kosiew commented on code in PR #1411:
URL: 
https://github.com/apache/datafusion-python/pull/1411#discussion_r2903514166


##########
python/datafusion/conftest.py:
##########


Review Comment:
   Could this live in a repo-level or `python/`-level `conftest.py` instead of 
inside the package?
   
   The new pytest fixture is test-only infrastructure, but it now lives under 
`python/datafusion/`, which is the shipped package tree. 
   That makes the package layout less cohesive and couples the runtime module 
directory to pytest-specific setup. 
   
   A higher-level `conftest.py` would still support doctests while keeping test 
wiring out of the library package.



##########
python/datafusion/functions.py:
##########
@@ -491,16 +491,28 @@ def abs(arg: Expr) -> Expr:
 def acos(arg: Expr) -> Expr:

Review Comment:
   I think it would be helpful to extract shared example setup, or align the 
example style with existing docstrings.
   
      Most of the new examples duplicate the same `SessionContext` / 
`from_pydict` / `select` / `collect_column` flow with only the function name 
and literal changing. That is fine for a few functions, but the repetition will 
get expensive as more scalar helpers gain examples. 
   It would be worth standardizing on a small doctest helper namespace or a 
more consistent public-facing import style so future additions do not 
copy-paste boilerplate across dozens of docstrings.



##########
python/datafusion/functions.py:
##########
@@ -510,27 +522,74 @@ def ascii(arg: Expr) -> Expr:
 
 
 def asin(arg: Expr) -> Expr:
-    """Returns the arc sine or inverse sine of a number."""
+    """Returns the arc sine or inverse sine of a number.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [0.0]})
+    >>> result = df.select(dfn.functions.asin(dfn.col("a")).alias("asin"))
+    >>> result.collect_column("asin")[0].as_py()
+    0.0
+    """
     return Expr(f.asin(arg.expr))
 
 
 def asinh(arg: Expr) -> Expr:
-    """Returns inverse hyperbolic sine."""
+    """Returns inverse hyperbolic sine.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [0.0]})
+    >>> result = df.select(dfn.functions.asinh(dfn.col("a")).alias("asinh"))
+    >>> result.collect_column("asinh")[0].as_py()
+    0.0
+    """
     return Expr(f.asinh(arg.expr))
 
 
 def atan(arg: Expr) -> Expr:
-    """Returns inverse tangent of a number."""
+    """Returns inverse tangent of a number.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [0.0]})
+    >>> result = df.select(dfn.functions.atan(dfn.col("a")).alias("atan"))
+    >>> result.collect_column("atan")[0].as_py()
+    0.0
+    """
     return Expr(f.atan(arg.expr))
 
 
 def atanh(arg: Expr) -> Expr:
-    """Returns inverse hyperbolic tangent."""
+    """Returns inverse hyperbolic tangent.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"a": [0.0]})
+    >>> result = df.select(dfn.functions.atanh(dfn.col("a")).alias("atanh"))
+    >>> result.collect_column("atanh")[0].as_py()
+    0.0
+    """
     return Expr(f.atanh(arg.expr))
 
 
 def atan2(y: Expr, x: Expr) -> Expr:
-    """Returns inverse tangent of a division given in the argument."""
+    """Returns inverse tangent of a division given in the argument.
+
+    Examples:
+    ---------
+    >>> ctx = dfn.SessionContext()
+    >>> df = ctx.from_pydict({"y": [0.0], "x": [1.0]})
+    >>> result = df.select(
+    ...     dfn.functions.atan2(dfn.col("y"), dfn.col("x")).alias("atan2"))
+    >>> result = result

Review Comment:
   result = result?



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to