Skip to main content

Polars plugin expressions and stream processors for flux-controlled dynamic windows.

Project description

polars-fluxbar

PyPI

polars-fluxbar 是一个面向 Polars 的 Python/Rust 扩展,提供由“通量”、 局部极值数量或非零条件值数量控制的动态窗口统计能力,同时包含可在 Python 中逐行调用的流式处理器。

功能特性

  • dynamic_window_stat / dynamic_window_stat_pipe:按累计条件值控制窗口长度。
  • extrema_window_stat / extrema_window_stat_pipe:按局部极值数量控制窗口长度。
  • nonzero_window_stat / nonzero_window_stat_pipe:按 cond != 0 的数量控制窗口长度,零值行保留在窗口内参与目标值统计。
  • DynamicWindowFilter / ExtremaWindowFilter / NonZeroWindowFilter:适合流式、逐 tick 或 REPL 调试的 Python 调用接口。
  • Stat:统一描述 avgsummaxminquantilerankargmaxargmin 等统计项。
  • distribution_sample:按行生成确定性的分布采样结果,支持静态参数和来自列的参数。

安装

开发阶段建议先构建本地扩展:

uv sync --group dev
uv run maturin develop --release

完成构建后即可在当前虚拟环境中导入:

import polars as pl
from polars_fluxbar import Stat
from polars_fluxbar.expr import dynamic_window_stat_pipe

df = pl.DataFrame(
    {
        "volume": [1.0, 2.0, 1.0, 3.0],
        "close": [10.0, 11.0, 9.5, 12.0],
    }
)

out = (
    df.lazy()
    .pipe(
        dynamic_window_stat_pipe,
        period=3.0,
        stats=[Stat.avg(), Stat.max(), "count"],
        cond_col="volume",
        target_col="close",
        prefix="dyn_",
    )
    .collect()
)

print(out)

更多可直接运行的示例见 examples/demo_fluxbar.py

开发

常用检查命令:

uv run maturin develop --release
uv run pytest tests
cargo clippy --all-targets --all-features

构建发布产物:

uv run maturin build --release --sdist --compatibility pypi

发布脚本

仓库提供 scripts/gitee_release.py,用于构建/发布 PyPI 包,并将产物镜像到 Gitee Release。 发布前需要配置 .env 或环境变量,至少包含:

  • PYPI_API_TOKEN
  • GITEE_TOKEN

脚本只要求这两个变量存在,可以通过 .env 或执行前指定。子进程仍会继承完整环境, 以便 MSVC、Rust、uv 等构建工具正常工作。项目版本、Gitee 仓库地址、tag、release 名称和目标提交会从 pyproject.tomlCargo.toml 与 git remote 中自动推导。

许可

本项目使用 MIT License,详见 LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_fluxbar-0.1.2.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polars_fluxbar-0.1.2-cp313-cp313-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file polars_fluxbar-0.1.2.tar.gz.

File metadata

  • Download URL: polars_fluxbar-0.1.2.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for polars_fluxbar-0.1.2.tar.gz
Algorithm Hash digest
SHA256 37a3e2687f41b2f5c3f06ad7a1714120c6f12e860a69c0f51095a4946a85f65f
MD5 09a0606a7a3c95b86590c722ac916bd8
BLAKE2b-256 864799c236c90bfed8c887d821f11afe1add94b0185c2312dbf2323a4ef47451

See more details on using hashes here.

File details

Details for the file polars_fluxbar-0.1.2-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for polars_fluxbar-0.1.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a91dfe8b8e8658006814b75a80fbdf9585b572e659420cdf556b75b573b22b4e
MD5 4a44ecd99e32beb707a7d68954ab1b91
BLAKE2b-256 48b96d51a04957f1a31269a0b062e33794d137cdc9885427bb337e11418911ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page