Skip to content

Commit 5390017

Browse files
Merge pull request #663 from Blosc/b2view-plotting
B2view plotting and other improvements
2 parents 96d39fd + dc71431 commit 5390017

26 files changed

Lines changed: 3364 additions & 148 deletions

.github/workflows/cibuildwheels.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,62 @@ jobs:
127127
./wheelhouse/*.tar.gz
128128
129129
130+
build_wheels_wasm:
131+
name: Build WASM/Pyodide wheels for ${{ matrix.p_ver }}
132+
runs-on: ubuntu-latest
133+
env:
134+
CIBW_BUILD: ${{ matrix.cibw_build }}
135+
# WASM/Pyodide has no SIMD/runtime CPU detection; disable optimised paths
136+
CMAKE_ARGS: "-DWITH_ZLIB_OPTIM=OFF -DWITH_OPTIM=OFF -DWITH_RUNTIME_CPU_DETECTION=OFF"
137+
CIBW_TEST_COMMAND: "pytest {project}/tests"
138+
# Pin the Pyodide version explicitly per target for reproducible builds.
139+
# cp313 stays on 0.29.3 (the version wasm.yml proves good): 0.29.4, the
140+
# cibuildwheel 4.1 default, regresses SChunk get_slice on WASM.
141+
CIBW_PYODIDE_VERSION: ${{ matrix.pyodide_version }}
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
include:
146+
# Python 3.13 -> pyemscripten_2025_0
147+
- p_ver: "3.13"
148+
cibw_build: "cp313-*"
149+
pyodide_version: "0.29.3"
150+
artifact_name: "wasm-pyodide-cp313"
151+
# Python 3.14 -> pyemscripten_2026_0
152+
- p_ver: "3.14"
153+
cibw_build: "cp314-*"
154+
pyodide_version: "314.0.0"
155+
artifact_name: "wasm-pyodide-cp314"
156+
steps:
157+
- name: Checkout repo
158+
uses: actions/checkout@v6
159+
160+
- name: Set up Python
161+
uses: actions/setup-python@v6
162+
with:
163+
python-version: '3.x'
164+
165+
- name: Install dependencies
166+
run: |
167+
sudo apt-get update
168+
sudo apt-get install -y cmake
169+
170+
- name: Install cibuildwheel
171+
run: pip install "cibuildwheel==4.1.*"
172+
173+
- name: Build wheels
174+
# Testing is performed automatically by cibuildwheel (via node).
175+
# platform=pyodide can only be set via the CLI flag, not an env var.
176+
run: cibuildwheel --platform pyodide
177+
178+
- uses: actions/upload-artifact@v7
179+
with:
180+
name: ${{ matrix.artifact_name }}
181+
path: ./wheelhouse/*.whl
182+
183+
130184
upload_pypi:
131-
needs: [ build_wheels]
185+
needs: [ build_wheels, build_wheels_wasm ]
132186
runs-on: ubuntu-latest
133187
# Only upload wheels when tagging (typically a release)
134188
if: startsWith(github.event.ref, 'refs/tags')

RELEASE_NOTES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@
44

55
XXX version-specific blurb XXX
66

7+
### CTable display
8+
9+
- **`CTable.to_string()` now renders the whole table by default** (every row and
10+
every column), like `pandas`' `DataFrame.to_string()`. New `max_rows` and
11+
`max_width` parameters truncate on demand. *Behaviour change*: previously
12+
`to_string()` returned the truncated view; code that relied on that should
13+
pass `max_rows=`/`max_width=` (or use `str()`).
14+
- **The `[N rows x M columns]` dimensions footer now follows pandas**: omitted by
15+
`to_string()` (pass `show_dimensions=True` to force it), and shown by
16+
`str`/`repr`/`print` only when the view is actually truncated. Previously it
17+
was always appended.
18+
- **`repr(ctable)` now shows the same truncated table as `str(ctable)`**
19+
(pandas/polars convention), instead of the one-line `CTable<…>` summary. The
20+
compact summary remains available via `ctable.info`.
21+
- **New display options** in `set_printoptions`: `display_width` controls the
22+
column-fitting width budget (`None` = auto-detect terminal, `-1` = show all
23+
columns, positive int = fixed budget), and `display_rows` now accepts `-1` to
24+
show all rows (`0` still shows none).
25+
- **New `blosc2.printoptions(...)` context manager** temporarily sets the display
26+
options and restores them on exit, e.g.
27+
`with blosc2.printoptions(display_rows=-1, display_width=-1): print(t)`.
28+
29+
### CTable I/O
30+
31+
- **`CTable.to_csv()` now accepts no path**, returning the CSV as a string like
32+
`pandas`' `DataFrame.to_csv()`. Passing a path still writes the file (and
33+
returns `None`); the returned string is byte-for-byte the same as the file.
34+
735
## Changes from 4.4.3 to 4.4.5
836

937
Note: 4.4.4 was skipped due to a failure during the release process.

doc/getting_started/b2view.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ metadata and vlmeta of the selected node, and a paged view of the data
88
itself — NDArrays of any dimensionality as well as CTables.
99

1010
``b2view`` is installed with python-blosc2; no extra dependencies are
11-
needed.
11+
needed, including the in-terminal braille plot (the ``p`` key). Only the
12+
high-resolution image view (the ``h`` key) needs the ``hires`` extra —
13+
``pip install "blosc2[hires]"``. See :doc:`installation` for the list of
14+
extras.
1215

1316
Step 1 — Create a sample store
1417
------------------------------

doc/getting_started/installation.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,38 @@ Conda
1616
1717
conda install -c conda-forge python-blosc2
1818
19+
Optional features (extras)
20+
++++++++++++++++++++++++++
21+
22+
The base install already includes everything needed for compression, the
23+
array machinery, and the :doc:`b2view <b2view>` terminal browser. A few
24+
heavier, feature-specific dependencies are kept out of it and grouped
25+
into *extras* that you opt into with the ``blosc2[extra]`` syntax:
26+
27+
.. list-table::
28+
:header-rows: 1
29+
:widths: 18 82
30+
31+
* - Extra
32+
- Adds
33+
* - ``hires``
34+
- The high-resolution image view in b2view (the ``h`` key), which
35+
renders a real ``matplotlib`` image in the terminal
36+
(``textual-image``, ``matplotlib``). The lightweight braille plot
37+
(the ``p`` key) is built in and needs no extra.
38+
* - ``parquet``
39+
- The ``parquet-to-blosc2`` converter (``pyarrow``); see
40+
:doc:`parquet_to_blosc2`.
41+
42+
Install one or more extras by listing them in brackets (quote the
43+
argument in shells like ``zsh`` that treat brackets specially):
44+
45+
.. code-block:: console
46+
47+
pip install "blosc2[hires]" # b2view high-res view (h key)
48+
pip install "blosc2[parquet]" # the Parquet converter
49+
pip install "blosc2[hires,parquet]" # both at once
50+
1951
Source code
2052
+++++++++++
2153

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ dependencies = [
4040
"requests",
4141
"rich",
4242
"textual",
43+
"textual-plotext",
4344
"threadpoolctl; platform_machine != 'wasm32'",
4445
]
4546
version = "4.4.6.dev0"
@@ -52,6 +53,11 @@ documentation = "https://www.blosc.org/python-blosc2/python-blosc2.html"
5253

5354
[project.optional-dependencies]
5455
parquet = ["pyarrow"]
56+
# The b2view TUI and its in-terminal braille plot (the 'p' key) are core deps,
57+
# so they work out of the box. This extra only adds the high-res 'h' view,
58+
# which renders a real matplotlib image (kitty/iTerm2/sixel, or half-cells
59+
# elsewhere) — matplotlib is the heavy part, hence the opt-in.
60+
hires = ["textual-image", "matplotlib"]
5561

5662
[project.scripts]
5763
parquet-to-blosc2 = "blosc2.cli.parquet_to_blosc2:main"

src/blosc2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ def _raise(exc):
642642
get_null_policy,
643643
get_printoptions,
644644
null_policy,
645+
printoptions,
645646
set_printoptions,
646647
)
647648
from .groupby import CTableGroupBy, group_reduce
@@ -1075,5 +1076,6 @@ def _raise(exc):
10751076
"get_null_policy",
10761077
"get_printoptions",
10771078
"null_policy",
1079+
"printoptions",
10781080
"set_printoptions",
10791081
]

0 commit comments

Comments
 (0)