-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support diff() inside over() in cudf-polars
#23497
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
dad01b7
e7ec0ff
33b0774
53838bd
5e38adf
4355dcb
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 |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ | |
|
|
||
|
|
||
| _WINDOW_ONLY_UNARY_FUNCTIONS = frozenset( | ||
| {"rank", "fill_null_with_strategy", "cum_sum", "shift", "shift_and_fill"} | ||
| {"rank", "fill_null_with_strategy", "cum_sum", "diff", "shift", "shift_and_fill"} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: ruff check \
python/cudf_polars/cudf_polars/dsl/utils/aggregations.py \
python/cudf_polars/cudf_polars/dsl/expressions/rolling.py \
python/cudf_polars/tests/expressions/test_rolling.py \
python/cudf_polars/cudf_polars/streaming/utils.py \
python/cudf_polars/tests/streaming/test_rolling.py \
python/cudf_polars/tests/streaming/test_spmd.py
ruff format --check \
python/cudf_polars/cudf_polars/dsl/utils/aggregations.py \
python/cudf_polars/cudf_polars/dsl/expressions/rolling.py \
python/cudf_polars/tests/expressions/test_rolling.py \
python/cudf_polars/cudf_polars/streaming/utils.py \
python/cudf_polars/tests/streaming/test_rolling.py \
python/cudf_polars/tests/streaming/test_spmd.pyRepository: rapidsai/cudf Length of output: 6062 🏁 Script executed: #!/bin/bash
set -u
printf '%s\n' '--- changed-file summary ---'
git diff --stat
printf '%s\n' '--- Ruff configuration ---'
rg -n --hidden --glob 'pyproject.toml' --glob 'ruff.toml' --glob '.ruff.toml' \
'^\[tool\.ruff|select|extend-select|ignore|line-length|target-version' .
printf '%s\n' '--- cited locations ---'
for f in \
python/cudf_polars/cudf_polars/dsl/utils/aggregations.py \
python/cudf_polars/cudf_polars/dsl/expressions/rolling.py \
python/cudf_polars/tests/expressions/test_rolling.py \
python/cudf_polars/cudf_polars/streaming/utils.py \
python/cudf_polars/tests/streaming/test_rolling.py \
python/cudf_polars/tests/streaming/test_spmd.py
do
echo "### $f"
case "$f" in
*/aggregations.py) sed -n '24,36p' "$f" ;;
*/expressions/rolling.py) sed -n '370,382p' "$f" ;;
*/tests/expressions/test_rolling.py) sed -n '470,495p' "$f" ;;
*/streaming/utils.py) sed -n '126,138p' "$f" ;;
*/tests/streaming/test_rolling.py) sed -n '60,88p' "$f" ;;
*/tests/streaming/test_spmd.py) sed -n '498,508p' "$f" ;;
esac
done
printf '%s\n' '--- Ruff check with independent status ---'
ruff check \
python/cudf_polars/cudf_polars/dsl/utils/aggregations.py \
python/cudf_polars/cudf_polars/dsl/expressions/rolling.py \
python/cudf_polars/tests/expressions/test_rolling.py \
python/cudf_polars/cudf_polars/streaming/utils.py \
python/cudf_polars/tests/streaming/test_rolling.py \
python/cudf_polars/tests/streaming/test_spmd.py
check_status=$?
echo "ruff check exit status: $check_status"
printf '%s\n' '--- Ruff format check with independent status ---'
ruff format --check \
python/cudf_polars/cudf_polars/dsl/utils/aggregations.py \
python/cudf_polars/cudf_polars/dsl/expressions/rolling.py \
python/cudf_polars/tests/expressions/test_rolling.py \
python/cudf_polars/cudf_polars/streaming/utils.py \
python/cudf_polars/tests/streaming/test_rolling.py \
python/cudf_polars/tests/streaming/test_spmd.py
format_status=$?
echo "ruff format --check exit status: $format_status"
exit 0Repository: rapidsai/cudf Length of output: 16136 Fix the six RUF036 errors in 📍 Affects 6 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| ) | ||
|
|
||
|
|
||
|
|
@@ -123,17 +123,21 @@ def decompose_single_agg( | |
| raise NotImplementedError( | ||
| f"{agg.name} over a window does not support nested fixed-size rolling" | ||
| ) | ||
| if agg.name in {"shift", "shift_and_fill"}: | ||
| if agg.name in {"diff", "shift", "shift_and_fill"}: | ||
| if not isinstance(agg.children[1], expr.Literal): | ||
| raise NotImplementedError( | ||
| "shift over a window only supports a literal offset" | ||
| f"{agg.name} over a window only supports a literal offset" | ||
| ) | ||
| if agg.name == "shift_and_fill" and not isinstance( | ||
| agg.children[2], expr.Literal | ||
| ): | ||
| raise NotImplementedError( | ||
| "shift over a window only supports a literal fill_value" | ||
| ) | ||
| if agg.name == "diff" and agg.options[0] != "ignore": | ||
| raise NotImplementedError( | ||
| "diff over a window only supports null_behavior='ignore'" | ||
| ) | ||
| if agg.name == "fill_null_with_strategy" and ( | ||
| strategy := agg.options[0] | ||
| ) not in {"forward", "backward"}: | ||
|
|
||
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.
comment: If we wanted to support
polars.Expr.pct_changewithover, would that implementation go here?xref https://github.com/rapidsai/cudf/pull/23225/changes for the pylibcudf APIs used to implement pct_change
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.
Yes, exactly. I'd expect
pct_change().over(...)to fit here, I think. Instead ofvalue - shifted, we would just want(value / shifted) - 1for "pct_change".