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:按局部极值数量控制窗口长度。
  • DynamicWindowFilter / ExtremaWindowFilter:适合流式、逐 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.1.tar.gz (61.2 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.1-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.1.tar.gz.

File metadata

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

File hashes

Hashes for polars_fluxbar-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b1c0fc4e6e7e44be55b4e71ccd22d9a6069ceee2feb65e800a2e590f9eb2fd6f
MD5 2312b53a2e8e364f4eec9904a0b7f868
BLAKE2b-256 86e083ca422bce71717d33d902ad35af6582aefa811e0f10b60db8765a0e906f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_fluxbar-0.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 38174950d9aa24927080fe09c4f92fdad75d2b763ac26512d4eb44d1bf737ae2
MD5 9ccc7b6bb4efe3fdf5af148d74ca36d3
BLAKE2b-256 454c4078b70ba219c8c97a7b44bbffb8a4ecf523cc5f777ecaf11113bc59b15f

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