plothero 0.3.0b1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plothero-0.3.0b1/.flake8 +3 -0
- plothero-0.3.0b1/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- plothero-0.3.0b1/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- plothero-0.3.0b1/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- plothero-0.3.0b1/.github/workflows/docs.yml +49 -0
- plothero-0.3.0b1/.github/workflows/release.yml +214 -0
- plothero-0.3.0b1/.gitignore +27 -0
- plothero-0.3.0b1/AGENTS.md +70 -0
- plothero-0.3.0b1/CHANGELOG.md +214 -0
- plothero-0.3.0b1/CLAUDE.md +1 -0
- plothero-0.3.0b1/Cargo.lock +323 -0
- plothero-0.3.0b1/Cargo.toml +17 -0
- plothero-0.3.0b1/LICENSE +201 -0
- plothero-0.3.0b1/PKG-INFO +447 -0
- plothero-0.3.0b1/README.md +405 -0
- plothero-0.3.0b1/docs/api/downsample.md +11 -0
- plothero-0.3.0b1/docs/api/graph-objects.md +23 -0
- plothero-0.3.0b1/docs/api/subplots.md +3 -0
- plothero-0.3.0b1/docs/assets/favicon-rounded.svg +30 -0
- plothero-0.3.0b1/docs/assets/favicon.svg +30 -0
- plothero-0.3.0b1/docs/assets/logo.png +0 -0
- plothero-0.3.0b1/docs/development.md +144 -0
- plothero-0.3.0b1/docs/guide/downsampling.md +170 -0
- plothero-0.3.0b1/docs/guide/figures-and-traces.md +172 -0
- plothero-0.3.0b1/docs/guide/migrating-from-plotly.md +75 -0
- plothero-0.3.0b1/docs/guide/subplots.md +76 -0
- plothero-0.3.0b1/docs/index.md +55 -0
- plothero-0.3.0b1/docs/installation.md +89 -0
- plothero-0.3.0b1/docs/quickstart.md +131 -0
- plothero-0.3.0b1/docs/roadmap.md +6 -0
- plothero-0.3.0b1/docs/stylesheets/extra.css +13 -0
- plothero-0.3.0b1/examples/example.py +52 -0
- plothero-0.3.0b1/examples/lttb.py +46 -0
- plothero-0.3.0b1/examples/m4.py +48 -0
- plothero-0.3.0b1/examples/minmax.py +46 -0
- plothero-0.3.0b1/examples/ppg.py +92 -0
- plothero-0.3.0b1/examples/walkthrough/01_check_install.py +21 -0
- plothero-0.3.0b1/examples/walkthrough/02_overview.py +51 -0
- plothero-0.3.0b1/examples/walkthrough/03_downsampling_methods.py +39 -0
- plothero-0.3.0b1/examples/walkthrough/04_benchmark.py +69 -0
- plothero-0.3.0b1/examples/walkthrough/05_subplots.py +43 -0
- plothero-0.3.0b1/examples/walkthrough/06_bar_profiles.py +26 -0
- plothero-0.3.0b1/examples/walkthrough/07_heatmap.py +32 -0
- plothero-0.3.0b1/examples/walkthrough/08_plotly_style.py +31 -0
- plothero-0.3.0b1/examples/walkthrough/09_export.py +34 -0
- plothero-0.3.0b1/examples/walkthrough/10_detached_show.py +48 -0
- plothero-0.3.0b1/examples/walkthrough/README.md +67 -0
- plothero-0.3.0b1/examples/walkthrough/common.py +37 -0
- plothero-0.3.0b1/mkdocs.yml +76 -0
- plothero-0.3.0b1/plothero/__init__.py +56 -0
- plothero-0.3.0b1/plothero/_viewer.py +326 -0
- plothero-0.3.0b1/plothero/downsample.py +190 -0
- plothero-0.3.0b1/plothero/graph_objects.py +1124 -0
- plothero-0.3.0b1/plothero/subplots.py +179 -0
- plothero-0.3.0b1/pyproject.toml +62 -0
- plothero-0.3.0b1/src/lib.rs +272 -0
- plothero-0.3.0b1/tests/test_downsample.py +141 -0
- plothero-0.3.0b1/tests/test_graph_objects.py +904 -0
- plothero-0.3.0b1/tests/test_subplots.py +226 -0
- plothero-0.3.0b1/tests/test_viewer.py +424 -0
- plothero-0.3.0b1/wrangler.toml +9 -0
plothero-0.3.0b1/.flake8
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS: [e.g. iOS]
|
|
28
|
+
- Browser [e.g. chrome, safari]
|
|
29
|
+
- Version [e.g. 22]
|
|
30
|
+
|
|
31
|
+
**Smartphone (please complete the following information):**
|
|
32
|
+
- Device: [e.g. iPhone6]
|
|
33
|
+
- OS: [e.g. iOS8.1]
|
|
34
|
+
- Browser [e.g. stock browser, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Deploy docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- docs/**
|
|
8
|
+
- mkdocs.yml
|
|
9
|
+
- plothero/**
|
|
10
|
+
- src/**
|
|
11
|
+
- Cargo.toml
|
|
12
|
+
- pyproject.toml
|
|
13
|
+
- wrangler.toml
|
|
14
|
+
- .github/workflows/docs.yml
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
|
|
20
|
+
concurrency:
|
|
21
|
+
group: pages
|
|
22
|
+
cancel-in-progress: true
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
deploy:
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
cache: pip
|
|
34
|
+
|
|
35
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
36
|
+
|
|
37
|
+
- uses: Swatinem/rust-cache@v2
|
|
38
|
+
|
|
39
|
+
- name: Install plothero and docs dependencies
|
|
40
|
+
run: pip install ".[docs]"
|
|
41
|
+
|
|
42
|
+
- name: Build docs
|
|
43
|
+
run: mkdocs build --strict --site-dir site
|
|
44
|
+
|
|
45
|
+
- name: Deploy to Cloudflare Workers (static assets)
|
|
46
|
+
run: npx wrangler deploy
|
|
47
|
+
env:
|
|
48
|
+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
49
|
+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Runs only when a GitHub release is published. Builds abi3 wheels (one per
|
|
4
|
+
# platform, Python 3.9+) and the sdist, tests every wheel from a clean
|
|
5
|
+
# environment, publishes to PyPI, then attaches the files to the release
|
|
6
|
+
# and sets its notes from CHANGELOG.md.
|
|
7
|
+
# Generated with `maturin generate-ci github`, then trimmed.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
release:
|
|
11
|
+
types: [published]
|
|
12
|
+
|
|
13
|
+
permissions: {}
|
|
14
|
+
|
|
15
|
+
concurrency:
|
|
16
|
+
group: release-${{ github.ref }}
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
check:
|
|
20
|
+
name: Check version and changelog
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
permissions:
|
|
23
|
+
contents: read
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v6
|
|
26
|
+
|
|
27
|
+
- name: Compare tag with Cargo.toml and extract release notes
|
|
28
|
+
env:
|
|
29
|
+
TAG: ${{ github.event.release.tag_name }}
|
|
30
|
+
run: |
|
|
31
|
+
version="$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["version"])')"
|
|
32
|
+
if [ "$TAG" != "v$version" ]; then
|
|
33
|
+
echo "::error::Release tag $TAG does not match v$version from Cargo.toml"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
awk -v v="$version" '
|
|
37
|
+
index($0, "## [" v "]") == 1 { found = 1; next }
|
|
38
|
+
found && /^## \[/ { exit }
|
|
39
|
+
found && /^\[[^]]*\]: / { next }
|
|
40
|
+
found { print }
|
|
41
|
+
' CHANGELOG.md > release-notes.md
|
|
42
|
+
if ! grep -q '[^[:space:]]' release-notes.md; then
|
|
43
|
+
echo "::error::CHANGELOG.md has no '## [$version]' section with content"
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
cat release-notes.md
|
|
47
|
+
|
|
48
|
+
- name: Upload release notes
|
|
49
|
+
uses: actions/upload-artifact@v6
|
|
50
|
+
with:
|
|
51
|
+
name: release-notes
|
|
52
|
+
path: release-notes.md
|
|
53
|
+
|
|
54
|
+
build:
|
|
55
|
+
name: Build wheel (${{ matrix.platform.name }})
|
|
56
|
+
needs: check
|
|
57
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
58
|
+
permissions:
|
|
59
|
+
contents: read
|
|
60
|
+
strategy:
|
|
61
|
+
fail-fast: false
|
|
62
|
+
matrix:
|
|
63
|
+
platform:
|
|
64
|
+
- { name: linux-x86_64, runner: ubuntu-latest, target: x86_64 }
|
|
65
|
+
- { name: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64 }
|
|
66
|
+
- { name: macos-x86_64, runner: macos-15-intel, target: x86_64 }
|
|
67
|
+
- { name: macos-arm64, runner: macos-latest, target: aarch64 }
|
|
68
|
+
- { name: windows-x64, runner: windows-latest, target: x64 }
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/checkout@v6
|
|
71
|
+
|
|
72
|
+
- uses: actions/setup-python@v6
|
|
73
|
+
with:
|
|
74
|
+
python-version: "3.12"
|
|
75
|
+
|
|
76
|
+
- name: Build wheel
|
|
77
|
+
uses: PyO3/maturin-action@v1
|
|
78
|
+
with:
|
|
79
|
+
target: ${{ matrix.platform.target }}
|
|
80
|
+
args: --release --out dist
|
|
81
|
+
manylinux: auto
|
|
82
|
+
|
|
83
|
+
- uses: actions/upload-artifact@v6
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-${{ matrix.platform.name }}
|
|
86
|
+
path: dist/*.whl
|
|
87
|
+
if-no-files-found: error
|
|
88
|
+
|
|
89
|
+
sdist:
|
|
90
|
+
name: Build sdist
|
|
91
|
+
needs: check
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
permissions:
|
|
94
|
+
contents: read
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/checkout@v6
|
|
97
|
+
|
|
98
|
+
- name: Build sdist
|
|
99
|
+
uses: PyO3/maturin-action@v1
|
|
100
|
+
with:
|
|
101
|
+
command: sdist
|
|
102
|
+
args: --out dist
|
|
103
|
+
|
|
104
|
+
- uses: actions/upload-artifact@v6
|
|
105
|
+
with:
|
|
106
|
+
name: wheels-sdist
|
|
107
|
+
path: dist/*.tar.gz
|
|
108
|
+
if-no-files-found: error
|
|
109
|
+
|
|
110
|
+
test:
|
|
111
|
+
name: Test wheel (${{ matrix.platform.name }}, Python ${{ matrix.python }})
|
|
112
|
+
needs: build
|
|
113
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
114
|
+
permissions:
|
|
115
|
+
contents: read
|
|
116
|
+
strategy:
|
|
117
|
+
fail-fast: false
|
|
118
|
+
matrix:
|
|
119
|
+
platform:
|
|
120
|
+
- { name: linux-x86_64, runner: ubuntu-latest }
|
|
121
|
+
- { name: linux-aarch64, runner: ubuntu-24.04-arm }
|
|
122
|
+
- { name: macos-x86_64, runner: macos-15-intel }
|
|
123
|
+
- { name: macos-arm64, runner: macos-latest }
|
|
124
|
+
- { name: windows-x64, runner: windows-latest }
|
|
125
|
+
# Oldest supported and newest stable Python.
|
|
126
|
+
python: ["3.9", "3.15"]
|
|
127
|
+
env:
|
|
128
|
+
# Use uv's own CPython builds, not whatever Python the runner image
|
|
129
|
+
# ships (Homebrew, Xcode), so every job tests a clean interpreter.
|
|
130
|
+
UV_PYTHON_PREFERENCE: only-managed
|
|
131
|
+
defaults:
|
|
132
|
+
run:
|
|
133
|
+
shell: bash
|
|
134
|
+
steps:
|
|
135
|
+
- uses: actions/checkout@v6
|
|
136
|
+
|
|
137
|
+
- uses: actions/download-artifact@v7
|
|
138
|
+
with:
|
|
139
|
+
name: wheels-${{ matrix.platform.name }}
|
|
140
|
+
path: dist
|
|
141
|
+
|
|
142
|
+
- uses: astral-sh/setup-uv@v7
|
|
143
|
+
with:
|
|
144
|
+
python-version: ${{ matrix.python }}
|
|
145
|
+
activate-environment: true
|
|
146
|
+
|
|
147
|
+
- name: Install the built wheel
|
|
148
|
+
run: uv pip install dist/*.whl pytest pandas plotly
|
|
149
|
+
|
|
150
|
+
# The repo root contains the plothero/ source tree, so the tests run
|
|
151
|
+
# from a copy outside it to make sure the installed wheel is imported.
|
|
152
|
+
- name: Check the compiled extension
|
|
153
|
+
working-directory: ${{ runner.temp }}
|
|
154
|
+
run: |
|
|
155
|
+
python -c "
|
|
156
|
+
import sys, plothero
|
|
157
|
+
print(sys.version)
|
|
158
|
+
print(plothero.__file__)
|
|
159
|
+
assert 'site-packages' in plothero.__file__, 'plothero was not imported from the wheel'
|
|
160
|
+
assert plothero.rust_available(), 'the Rust extension is not available'
|
|
161
|
+
"
|
|
162
|
+
|
|
163
|
+
- name: Run the test suite
|
|
164
|
+
run: |
|
|
165
|
+
cp -r tests "$RUNNER_TEMP/tests"
|
|
166
|
+
cd "$RUNNER_TEMP"
|
|
167
|
+
python -m pytest tests -p no:cacheprovider
|
|
168
|
+
|
|
169
|
+
publish:
|
|
170
|
+
name: Publish to PyPI
|
|
171
|
+
needs: [check, build, sdist, test]
|
|
172
|
+
runs-on: ubuntu-latest
|
|
173
|
+
environment:
|
|
174
|
+
name: pypi
|
|
175
|
+
url: https://pypi.org/p/plothero
|
|
176
|
+
permissions: {}
|
|
177
|
+
steps:
|
|
178
|
+
- uses: actions/download-artifact@v7
|
|
179
|
+
with:
|
|
180
|
+
pattern: wheels-*
|
|
181
|
+
path: dist
|
|
182
|
+
merge-multiple: true
|
|
183
|
+
|
|
184
|
+
# Uploads with an API token stored in the PYPI_API_TOKEN secret.
|
|
185
|
+
# Attestations need trusted publishing, so they are turned off.
|
|
186
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
187
|
+
with:
|
|
188
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
189
|
+
attestations: false
|
|
190
|
+
|
|
191
|
+
release:
|
|
192
|
+
name: Update GitHub release
|
|
193
|
+
needs: publish
|
|
194
|
+
runs-on: ubuntu-latest
|
|
195
|
+
permissions:
|
|
196
|
+
contents: write
|
|
197
|
+
steps:
|
|
198
|
+
- uses: actions/download-artifact@v7
|
|
199
|
+
with:
|
|
200
|
+
pattern: wheels-*
|
|
201
|
+
path: dist
|
|
202
|
+
merge-multiple: true
|
|
203
|
+
|
|
204
|
+
- uses: actions/download-artifact@v7
|
|
205
|
+
with:
|
|
206
|
+
name: release-notes
|
|
207
|
+
|
|
208
|
+
- name: Attach files and set notes
|
|
209
|
+
env:
|
|
210
|
+
GH_TOKEN: ${{ github.token }}
|
|
211
|
+
TAG: ${{ github.event.release.tag_name }}
|
|
212
|
+
run: |
|
|
213
|
+
gh release upload "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --clobber
|
|
214
|
+
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes-file release-notes.md
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Rust
|
|
2
|
+
/target/
|
|
3
|
+
|
|
4
|
+
# Python
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.so
|
|
8
|
+
*.pyd
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
|
|
16
|
+
# maturin
|
|
17
|
+
wheels/
|
|
18
|
+
|
|
19
|
+
# mkdocs
|
|
20
|
+
/site/
|
|
21
|
+
|
|
22
|
+
# macOS
|
|
23
|
+
.DS_Store
|
|
24
|
+
|
|
25
|
+
# Walkthrough: downloaded dataset and exported figures
|
|
26
|
+
/examples/walkthrough/data/
|
|
27
|
+
/examples/walkthrough/output/
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to coding agents working in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`plothero` is a Plotly-compatible plotting library for heavy signals: Rust core (downsampling), Python API (`plothero.graph_objects` mirrors `plotly.graph_objects`). Traces above a size threshold (default 5,000 points) are automatically decimated with a Rust-accelerated LTTB, Min/Max, or M4 algorithm before being handed to Plotly.js, so multi-million-point signals still pan/zoom smoothly in the browser.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# One-time setup
|
|
13
|
+
python3 -m venv .venv && source .venv/bin/activate
|
|
14
|
+
pip install -e ".[dev]" # maturin, pytest, pandas, plotly
|
|
15
|
+
maturin develop # debug build of the Rust extension (fast compile)
|
|
16
|
+
maturin develop --release # optimized build, use for benchmarking
|
|
17
|
+
|
|
18
|
+
# Tests
|
|
19
|
+
pytest # full suite
|
|
20
|
+
pytest -v
|
|
21
|
+
pytest tests/test_downsample.py # one file
|
|
22
|
+
pytest -k datetime # by keyword
|
|
23
|
+
|
|
24
|
+
# Lint
|
|
25
|
+
flake8 # config in .flake8 (max-line-length 120, E501/E722 ignored)
|
|
26
|
+
|
|
27
|
+
# Docs (MkDocs + Material + mkdocstrings)
|
|
28
|
+
pip install -e ".[docs]"
|
|
29
|
+
mkdocs serve # live preview at http://127.0.0.1:8000
|
|
30
|
+
mkdocs build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
No format command is configured in this repo.
|
|
34
|
+
|
|
35
|
+
Rebuild with `maturin develop` any time `src/lib.rs` changes — Python changes under `plothero/` take effect immediately without a rebuild. If the Rust extension isn't built, the package still imports and works via the pure-Python fallback in `downsample.py` (same results; LTTB ~60x slower, MinMax/M4 about the same speed since their fallbacks are vectorized numpy); check the active backend with `plothero.rust_available()`.
|
|
36
|
+
|
|
37
|
+
API docs under `docs/api/` are generated from docstrings in `plothero/graph_objects.py` and `plothero/downsample.py` — edit the docstrings, not the `.md` files.
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
src/lib.rs Rust: lttb_downsample, minmax_downsample, m4_downsample (PyO3 + numpy), compiled as plothero._core
|
|
43
|
+
plothero/
|
|
44
|
+
├── __init__.py Re-exports the public API
|
|
45
|
+
├── graph_objects.py Plotly-compatible Figure / Scatter / Bar / Heatmap / Layout
|
|
46
|
+
├── subplots.py Plotly-compatible make_subplots (multi-panel figures)
|
|
47
|
+
├── downsample.py Dispatches to plothero._core when available, else pure-Python fallback
|
|
48
|
+
└── _viewer.py Detached viewer process behind Figure.show() (python -m plothero._viewer)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Two layers, one contract: every downsampling algorithm exists twice, once in `src/lib.rs` (Rust, via PyO3) and once in `plothero/downsample.py` (`_lttb_py`/`_minmax_py`/`_m4_py`, pure Python). Both must produce identical output. `downsample.py` tries to import `plothero._core` and sets `RUST_AVAILABLE` accordingly; `lttb_downsample()`/`minmax_downsample()`/`m4_downsample()` branch on that flag. When changing an algorithm (or adding a new one), change both implementations and run the test suite against both backends (before and after `maturin develop`).
|
|
52
|
+
|
|
53
|
+
`graph_objects.py` implements a Plotly-compatible surface, not a Plotly wrapper. `Figure`/`Scatter`/`Bar`/`Heatmap`/`Layout` reimplement enough of the real `plotly.graph_objects` API (including "magic underscore" kwarg expansion, e.g. `xaxis_title=` -> `{"xaxis": {"title": ...}}`, via `NESTED_PREFIXES`/`FLAT_KEYS`) that code written for real Plotly mostly works after swapping the import. Anything not explicitly modeled is passed straight through to the Plotly.js JSON spec. `Scatter` triggers downsampling automatically once `len(x) > downsample_threshold`, calling into `downsample.py`.
|
|
54
|
+
|
|
55
|
+
`subplots.py`'s `make_subplots` builds a `Figure` pre-populated with a grid of axes (row 1 = top, 1-indexed, matching Plotly convention) and reuses `graph_objects._axis_suffix` to map `(row, col)` to Plotly's `xaxis`/`xaxis2`/`xaxis3`/... naming scheme. `Figure.add_trace`/`update_xaxes`/`update_yaxes` accept `row=`/`col=` to route to a specific panel.
|
|
56
|
+
|
|
57
|
+
`Figure.show()` serves the page plus a `/downsample` endpoint (zoom-triggered re-downsampling via `Scatter.resample_range`) through one HTTP handler, `graph_objects._make_request_handler`, used by two hosts. The default host is `plothero/_viewer.py`: `launch()` writes the rendered HTML and each decimated trace's full-resolution arrays (`.npz` plus a JSON manifest, no pickling) to a temp dir, then starts `python -m plothero._viewer <dir>` detached from the parent (new session on POSIX, `DETACHED_PROCESS` on Windows). The child loads the payload, deletes the temp dir, prints its URL on stdout for the parent, and exits once the page's heartbeats and `pagehide` beacon say no tab is left (`PageTracker`). `show(detached=False)` keeps the older in-process host, `_serve_figure_locally`, on a non-daemon thread. Lifecycle timeouts are module constants in `_viewer.py` and keyword arguments of `launch()`, so tests can shorten them.
|
|
58
|
+
|
|
59
|
+
`Scatter`, `Bar`, and `Heatmap` are implemented as trace types. Only `Scatter` is downsampled (line/marker plots, time series with automatic `datetime64`/`DatetimeIndex` handling); `Bar` and `Heatmap` pass their data through as-is.
|
|
60
|
+
|
|
61
|
+
## Git contract
|
|
62
|
+
- Commit messages follow **Conventional Commits**.
|
|
63
|
+
- Signed commits: yes.
|
|
64
|
+
- Co-Authored-By trailer: no.
|
|
65
|
+
- **Integration:** direct-to-main, **fast-forward only**. No merge commits on `main`.
|
|
66
|
+
|
|
67
|
+
## Documentation contract
|
|
68
|
+
* Update the README.md when major changes have been applied
|
|
69
|
+
* Update the documentation in docs folder
|
|
70
|
+
* Update the `CHANGELOG.md` for the next release
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.3.0-beta.1] - 2026-10-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `Bar` and `Heatmap` trace types in `plothero.graph_objects`, with
|
|
15
|
+
`Figure.add_bar`/`Figure.add_heatmap` shortcuts. Both support
|
|
16
|
+
magic-underscore kwargs, passthrough of unmodeled keywords, and
|
|
17
|
+
`row=`/`col=` placement in `make_subplots` figures. They are never
|
|
18
|
+
downsampled. `add_trace` and dict-based construction dispatch on `"type"`.
|
|
19
|
+
- Project logo in the README and on the docs home page, plus a header logo
|
|
20
|
+
and favicon for the docs website (assets in `docs/assets/`).
|
|
21
|
+
- Docs website colors now match the logo (blue `#2f5fb3`, orange `#ffaa00`).
|
|
22
|
+
- `examples/walkthrough/`: a series of scripts that go through every feature
|
|
23
|
+
on a real 2-million-sample signal (UCI household power dataset), from
|
|
24
|
+
building the Rust extension to interactive zoom. New `examples` extra
|
|
25
|
+
(`pip install -e ".[examples]"`) for their dependencies.
|
|
26
|
+
- Release workflow (`.github/workflows/release.yml`): publishing a GitHub
|
|
27
|
+
release builds wheels for Linux (x86_64, aarch64), macOS (x86_64,
|
|
28
|
+
arm64), and Windows (x64) plus the sdist, tests every wheel with Python
|
|
29
|
+
3.9 and the newest stable Python, publishes to PyPI with an API token
|
|
30
|
+
stored in the `PYPI_API_TOKEN` repository secret, and attaches the files
|
|
31
|
+
to the release with the matching `CHANGELOG.md` section as notes.
|
|
32
|
+
- `Figure.show(detached=False)` keyword-only opt-out that serves the figure
|
|
33
|
+
from a thread inside the calling process, as `show()` did before.
|
|
34
|
+
- `examples/walkthrough/10_detached_show.py`: plots the household power
|
|
35
|
+
dataset with the detached `show()`, keeps processing, then plots the
|
|
36
|
+
result with `show(detached=False)`. The walkthrough README now explains
|
|
37
|
+
that the scripts finish while their plots stay usable.
|
|
38
|
+
- `examples/ppg.py`: a synthetic PPG signal (6 million samples at 64 Hz,
|
|
39
|
+
about a day) built from a two-harmonic sawtooth pulse, a DC offset,
|
|
40
|
+
slow heart rate variability, respiratory wander and modulation, drift,
|
|
41
|
+
and noise, plotted once per downsampling method (`MINMAX`, `LTTB`, `M4`)
|
|
42
|
+
with the detached `show()`.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- Docs website moved to https://plothero.matteoserafino.com.
|
|
47
|
+
- The compiled extension is built against the stable Python ABI
|
|
48
|
+
(`abi3-py39`), so a single wheel per platform supports Python 3.9 and
|
|
49
|
+
every newer version, including releases that come out after the wheel
|
|
50
|
+
was built.
|
|
51
|
+
- `Figure.show()` now serves the figure from a separate background viewer
|
|
52
|
+
process (`plothero._viewer`) and returns immediately, so a script that
|
|
53
|
+
processes data and then plots it exits normally while the figure stays
|
|
54
|
+
open and zoom re-downsampling keeps working. The viewer exits on its own
|
|
55
|
+
shortly after the last browser tab showing the figure is closed, or if
|
|
56
|
+
no browser connects within about two minutes. Trace data is handed over
|
|
57
|
+
through a temporary `.npz` file that the viewer deletes as soon as it has
|
|
58
|
+
loaded it. If the viewer cannot be started, `show()` warns and falls back
|
|
59
|
+
to the in-process server.
|
|
60
|
+
- Migrating from Plotly guide: `fig.show()` moved from "What behaves the
|
|
61
|
+
same" to "What's different", covering the background viewer process,
|
|
62
|
+
`detached=False`, and Plotly's unsupported `show()` arguments.
|
|
63
|
+
- The `/downsample` endpoint now answers `400` for a trace that is not a
|
|
64
|
+
downsampled `Scatter` (for example a `Bar`), instead of dropping the
|
|
65
|
+
connection.
|
|
66
|
+
- Project logo now has a transparent background, so it blends with the docs
|
|
67
|
+
website theme.
|
|
68
|
+
- Downsampling guide: new "Choosing a method" section on the trade-offs
|
|
69
|
+
between `LTTB`, `MINMAX`, and `M4`.
|
|
70
|
+
- Corrected the Rust vs pure-Python speed claim in the README, docs, and
|
|
71
|
+
`AGENTS.md`: only LTTB's fallback is much slower (about 60×); `MINMAX` and
|
|
72
|
+
`M4` run at about the same speed.
|
|
73
|
+
- Documentation snippets (README, docs website, and docstrings) now use
|
|
74
|
+
`import plothero as ph` (`ph.Figure`, `ph.Scatter`, `ph.make_subplots`,
|
|
75
|
+
...). The migration guide still documents the
|
|
76
|
+
`import plothero.graph_objects as go` drop-in swap for existing Plotly code
|
|
77
|
+
([#11](https://github.com/matteo-serafino/plothero/issues/11)).
|
|
78
|
+
- Package metadata for PyPI: author, keywords, classifiers (including
|
|
79
|
+
`Development Status :: 4 - Beta`), and a link to the documentation
|
|
80
|
+
website. The README logo and its documentation link use absolute URLs,
|
|
81
|
+
so they render on PyPI.
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
|
|
85
|
+
- Zooming into a decimated trace on a datetime x-axis now reloads
|
|
86
|
+
full-resolution data when the two range bounds reported by Plotly.js use
|
|
87
|
+
different string precision (e.g. `2026-01-01` vs `2026-01-01 00:10:00.5`).
|
|
88
|
+
`Scatter.resample_range` parses each bound on its own as ISO-8601, so
|
|
89
|
+
`/downsample` no longer answers 400 for these ranges.
|
|
90
|
+
- The first zoom on a datetime x-axis no longer stalls while pandas is
|
|
91
|
+
imported. The range bounds Plotly.js reports are parsed with numpy, so
|
|
92
|
+
the viewer never imports pandas for them. In a fresh environment on macOS
|
|
93
|
+
that import took 6 to 11 seconds
|
|
94
|
+
([#18](https://github.com/matteo-serafino/plothero/issues/18)).
|
|
95
|
+
- Zooming far out on a datetime x-axis, until the range reaches a year
|
|
96
|
+
before 1677 or after 2262, now reloads the data in view. These bounds
|
|
97
|
+
are converted exactly instead of through `datetime64[ns]`, whose range
|
|
98
|
+
they exceed. Before, the `/downsample` request failed without a response.
|
|
99
|
+
The endpoint also answers `400` instead of dropping the connection if a
|
|
100
|
+
bound still cannot be converted.
|
|
101
|
+
- `show()` no longer waits for a reverse DNS lookup of `127.0.0.1` when it
|
|
102
|
+
starts the figure server. The standard library's `HTTPServer` performs
|
|
103
|
+
this lookup, and where reverse DNS is slow it delayed `show()` by tens of
|
|
104
|
+
seconds ([#18](https://github.com/matteo-serafino/plothero/issues/18)).
|
|
105
|
+
- The detached viewer now counts its "no browser connected" timeout from
|
|
106
|
+
the moment it reports its URL, not from its start. A slow startup could
|
|
107
|
+
otherwise use up the whole timeout, so the viewer exited right after
|
|
108
|
+
`show()` returned and the page failed to load
|
|
109
|
+
([#18](https://github.com/matteo-serafino/plothero/issues/18)).
|
|
110
|
+
|
|
111
|
+
## [0.2.0] - 2026-08-16
|
|
112
|
+
|
|
113
|
+
### Added
|
|
114
|
+
|
|
115
|
+
- `DownsampleMethod.M4`: a third decimation algorithm alongside `MINMAX` and
|
|
116
|
+
`LTTB`. Like `MINMAX`, it keeps each bucket's min and max sample (so
|
|
117
|
+
peaks/troughs survive decimation), but also keeps the bucket's first and
|
|
118
|
+
last sample — up to 4 points per bucket instead of 2, deduplicated in
|
|
119
|
+
chronological order. Implemented in both `src/lib.rs` (Rust) and
|
|
120
|
+
`plothero/downsample.py` (`_m4_py`, pure-Python fallback), with the same
|
|
121
|
+
Rust/Python dispatch as the existing algorithms. Wired into
|
|
122
|
+
`Scatter.downsample()` and `Scatter.resample_range()` (so it also works
|
|
123
|
+
with `Figure.show()`'s dynamic zoom resampling), and exported as
|
|
124
|
+
`plothero.m4_downsample()` for standalone use.
|
|
125
|
+
- `Figure.show()` now re-downsamples zoomed-in regions on the fly. Panning
|
|
126
|
+
or zooming into a decimated trace calls back to the local server for
|
|
127
|
+
fresh, full-resolution data restricted to the visible x-range, instead of
|
|
128
|
+
just interpolating the original fixed-size decimation — so the detail you
|
|
129
|
+
see when zoomed in is the real signal, not a decimation artifact. Only
|
|
130
|
+
active for `Figure.show()`; static exports (`to_html()`/`write_html()`)
|
|
131
|
+
are unaffected since there's no server to call back into.
|
|
132
|
+
- The dynamic-resample server's thread is no longer a daemon, so it now
|
|
133
|
+
keeps the Python process itself alive for as long as it runs. Previously,
|
|
134
|
+
a plain script's process would exit within moments of `show()`
|
|
135
|
+
returning — long before you got a chance to zoom — silently killing the
|
|
136
|
+
server and making every zoom/pan fall back to the low-resolution
|
|
137
|
+
overview already embedded in the page. `show()` now also prints a
|
|
138
|
+
one-line note whenever a trace was actually downsampled, since the
|
|
139
|
+
process staying alive (until Ctrl+C) is otherwise easy to miss. Has no
|
|
140
|
+
effect in a notebook/REPL, whose process was already going to stay alive
|
|
141
|
+
on its own. `_serve_figure_locally()` (internal) now returns
|
|
142
|
+
`(url, server)` instead of just `url`, so callers can `server.shutdown()`
|
|
143
|
+
it early if needed.
|
|
144
|
+
|
|
145
|
+
### Fixed
|
|
146
|
+
|
|
147
|
+
- `Figure.show()` now fills the browser viewport by default (matching real
|
|
148
|
+
Plotly's `default_width`/`default_height="100%"` behavior), instead of
|
|
149
|
+
being pinned to a fixed 600px-tall box. Explicit `layout.width`/
|
|
150
|
+
`layout.height` are still respected; the `to_html(full_html=False)`
|
|
151
|
+
fragment path (Jupyter/embedding) keeps its previous fixed-height default.
|
|
152
|
+
- Zooming into a decimated trace via `Figure.show()` no longer permanently
|
|
153
|
+
loses the original full-range data. The original decimated x/y arrays are
|
|
154
|
+
now cached client-side at page load, and resetting/zooming back out
|
|
155
|
+
(double-click, "reset axes") restores them instead of being stuck on
|
|
156
|
+
whatever the last zoomed-in `/downsample` fetch narrowed the trace to.
|
|
157
|
+
- Zooming into a decimated trace requested only as many points as the
|
|
158
|
+
trace's static `downsample_threshold` (e.g. 5,000), which is sized for
|
|
159
|
+
the *full* 60-second view — nowhere near enough to reproduce the dense,
|
|
160
|
+
overlapping-line look of noisy raw data once you're zoomed into a
|
|
161
|
+
narrow window with far more real samples to spare. The zoomed-in fetch
|
|
162
|
+
now requests a much larger, fixed point budget (20,000) independent of
|
|
163
|
+
the static threshold, so zooming in visibly recovers real detail instead
|
|
164
|
+
of showing the same low-density decimation just stretched out.
|
|
165
|
+
- `to_numeric()`'s string/object-array datetime fallback assumed
|
|
166
|
+
`pandas.to_datetime` always returns nanosecond-resolution timestamps;
|
|
167
|
+
pandas >= 2.0 can return coarser resolution (e.g. microseconds)
|
|
168
|
+
depending on the input, which silently produced a 1000x unit error.
|
|
169
|
+
|
|
170
|
+
### Changed
|
|
171
|
+
|
|
172
|
+
- `Figure.show()` no longer writes a temp HTML file to disk. It now serves
|
|
173
|
+
the figure from an in-memory local HTTP server (`http://127.0.0.1:<port>`)
|
|
174
|
+
and opens that URL in the browser, so reloading the page still works.
|
|
175
|
+
|
|
176
|
+
### Documentation
|
|
177
|
+
|
|
178
|
+
- Document how to install the Rust toolchain (`rustc` + `cargo`) via rustup,
|
|
179
|
+
including the `maturin develop` error to expect when it's missing, in the
|
|
180
|
+
README and `docs/installation.md`.
|
|
181
|
+
|
|
182
|
+
## [0.1.0] - 2026-08-14
|
|
183
|
+
|
|
184
|
+
### Added
|
|
185
|
+
|
|
186
|
+
- `plothero.graph_objects`: a Plotly-compatible `Figure`, `Scatter`, and
|
|
187
|
+
`Layout`. It mirrors `plotly.graph_objects` closely enough that most
|
|
188
|
+
existing `plotly` code works after swapping the import, including
|
|
189
|
+
Plotly's "magic underscore" kwarg expansion (`xaxis_title=`,
|
|
190
|
+
`line_color=`, ...) and automatic `datetime64`/`DatetimeIndex` handling
|
|
191
|
+
for `x`.
|
|
192
|
+
- Rust-accelerated downsampling core (`plothero._core`, built with PyO3):
|
|
193
|
+
LTTB (`lttb_downsample`) and Min/Max (`minmax_downsample`) algorithms.
|
|
194
|
+
`Scatter` traces above `downsample_threshold` (default 5,000 points) are
|
|
195
|
+
decimated automatically before being handed to Plotly.js, keeping
|
|
196
|
+
multi-million-point signals interactive in the browser.
|
|
197
|
+
- Pure-Python fallback implementations of both downsampling algorithms.
|
|
198
|
+
These run automatically when the compiled Rust extension isn't
|
|
199
|
+
available, with identical output at roughly 10-50x slower on large
|
|
200
|
+
arrays. The active backend is queryable via `plothero.rust_available()`.
|
|
201
|
+
- `plothero.subplots.make_subplots` for multi-panel figures, with
|
|
202
|
+
`row`/`col`-addressed `add_trace`/`update_xaxes`/`update_yaxes`, plus
|
|
203
|
+
`shared_xaxes`/`shared_yaxes`, `horizontal_spacing`/`vertical_spacing`,
|
|
204
|
+
`column_widths`/`row_heights`, and `subplot_titles`, mirroring
|
|
205
|
+
`plotly.subplots.make_subplots`.
|
|
206
|
+
- `Figure.to_html()`, `write_html()`, `show()`, `to_dict()`, `to_json()`,
|
|
207
|
+
and Jupyter inline rendering via `_repr_html_`.
|
|
208
|
+
- `Figure.to_plotly_figure()` to convert to a real `plotly.graph_objects.Figure`.
|
|
209
|
+
- Documentation site built with MkDocs, Material, and mkdocstrings, deployed
|
|
210
|
+
to Cloudflare Pages.
|
|
211
|
+
|
|
212
|
+
[0.3.0-beta.1]: https://github.com/matteo-serafino/plothero/releases/tag/v0.3.0-beta.1
|
|
213
|
+
[0.2.0]: https://github.com/matteo-serafino/plothero/releases/tag/v0.2.0
|
|
214
|
+
[0.1.0]: https://github.com/matteo-serafino/plothero/releases/tag/v0.1.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|