Skip to content

Commit

Permalink
docs: Pre-compute plugin_path before defining plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Sep 1, 2024
1 parent 4dc90a9 commit 5f85c36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions docs/user-guide/expressions/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ import polars as pl
from polars.plugins import register_plugin_function
from polars._typing import IntoExpr

PLUGIN_PATH = Path(__file__).parent

def pig_latinnify(expr: IntoExpr) -> pl.Expr:
"""Pig-latinnify expression."""
return register_plugin_function(
plugin_path=Path(__file__).parent,
plugin_path=PLUGIN_PATH,
function_name="pig_latinnify",
args=expr,
is_elementwise=True,
Expand Down Expand Up @@ -190,7 +191,7 @@ def append_args(
This example shows how arguments other than `Series` can be used.
"""
return register_plugin_function(
plugin_path=Path(__file__).parent,
plugin_path=PLUGIN_PATH,
function_name="append_kwargs",
args=expr,
kwargs={
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/series/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def kde(
**kwargs: Unpack[EncodeKwds],
) -> alt.Chart:
"""
Draw kernel dentity estimate plot.
Draw kernel density estimate plot.
Polars does not implement plotting logic itself but instead defers to
`Altair <https://altair-viz.github.io/>`_.
Expand Down

0 comments on commit 5f85c36

Please sign in to comment.