From bcd5472777f0c5f396cf2f074046ddfaacd0bdc4 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Thu, 12 Nov 2026 15:38:20 +0100 Subject: [PATCH 1/2] style: switch to panache markdown formatting --- .panache.toml | 14 ++++++++++++++ .pre-commit-config.yaml | 4 ++++ .vscode/extensions.json | 1 + .vscode/settings.json | 7 +++++-- README.md | 2 +- biome.jsonc | 1 + docs/how-to-dask.md | 8 ++++---- docs/index.md | 1 - 8 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .panache.toml diff --git a/.panache.toml b/.panache.toml new file mode 100644 index 00000000..9dfd77fe --- /dev/null +++ b/.panache.toml @@ -0,0 +1,14 @@ +#:schema https://panache.bz/panache.schema.json +flavor = "myst" + +[format] +wrap = "preserve" +smart-punctuation = "unicode" +tab-stops = "preserve" + +# MyST syntax extensions from `myst_enable_extensions` in `docs/conf.py` +[extensions] +tex-math-dollars = true # amsmath, dollarmath +myst-colon-fence = true # colon_fence +definition-lists = true # deflist +raw-html = true # html_admonition, html_image diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83e97f9f..6e1196c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,10 @@ repos: hooks: - id: biome-format exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually. + - repo: https://github.com/jolars/panache-pre-commit + rev: v3.18.0 + hooks: + - id: panache-format - repo: https://github.com/tox-dev/pyproject-fmt rev: v2.30.6 hooks: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index caaeb4f7..3e5224e3 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -14,5 +14,6 @@ "editorconfig.editorconfig", "charliermarsh.ruff", "biomejs.biome", + "jolars.panache", ], } diff --git a/.vscode/settings.json b/.vscode/settings.json index d5246cc9..e35a441d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "[python][json][jsonc]": { + "[python][json][jsonc][yaml][markdown]": { "editor.formatOnSave": true, }, "[python]": { @@ -9,8 +9,11 @@ "source.organizeImports": "always", }, }, - "[json][jsonc]": { + "[json][jsonc][yaml]": { "editor.defaultFormatter": "biomejs.biome", }, + "[markdown]": { + "editor.defaultFormatter": "jolars.panache", + }, "python.analysis.typeCheckingMode": "basic", } diff --git a/README.md b/README.md index f2ab9d37..16795987 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,6 @@ If you like scverse® and want to support our mission, please consider making a +> diff --git a/biome.jsonc b/biome.jsonc index 9f8f2208..0464f278 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -2,6 +2,7 @@ "$schema": "https://biomejs.dev/schemas/2.2.0/schema.json", "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }, "formatter": { "useEditorconfig": true }, + "markdown": { "formatter": { "enabled": false } }, // handled by panache "overrides": [ { "includes": ["./.vscode/*.json", "**/*.jsonc"], diff --git a/docs/how-to-dask.md b/docs/how-to-dask.md index 2626b4a9..60a6085c 100644 --- a/docs/how-to-dask.md +++ b/docs/how-to-dask.md @@ -25,7 +25,7 @@ Then if you do something like matrix multiplication, you will need double or eve ### How do I read my data into a `dask` array? {func}`anndata.experimental.read_elem_lazy` or {func}`anndata.experimental.read_lazy` can help you if you already have data on-disk that was written to the `anndata` file format. -If you use {func}`dask.array.to_zarr`, the data _cannot_ be read in using `anndata`'s functionality as `anndata` will look for its {doc}`specified file format metadata `. +If you use {func}`dask.array.to_zarr`, the data *cannot* be read in using `anndata`’s functionality as `anndata` will look for its {doc}`specified file format metadata `. If you need to implement custom io, generally we found that using {func}`dask.array.map_blocks` provides a nice way. See [our custom h5 io code] for an example. @@ -44,7 +44,7 @@ If you need to implement the function yourself, see the next point. ### Custom block-wise array operations Sometimes you may want to do an operation on a an array that is implemented nowhere. -Generally, we have found {func}`dask.array.map_blocks` to be versatile enough that most operations can be expressed on it. Click on the link to see `dask`'s own tutorial about the function. +Generally, we have found {func}`dask.array.map_blocks` to be versatile enough that most operations can be expressed on it. Click on the link to see `dask`’s own tutorial about the function. Take this (simplified) example of calculating a gram matrix from {func}`scanpy.pp.pca` for sparse-in-dask: @@ -68,7 +68,7 @@ These are the summed together to produce a single `(n_vars,n_vars)` matrix, whic Because `dask` does not implement matrix multiplication for sparse-in-dask, we do it ourselves. We use `map_blocks` over a CSR sparse-in-dask array where the chunking looks something like `(chunk_size, n_vars)`. -When we compute the individual block's gram matrix, we add an axis via `[None, ...]` so that we can sum over that axis i.e., the `da.map_blocks` call produces a `(n_obs // chunk_size, n_vars, n_vars)` sized-matrix which is summed over the first dimension. +When we compute the individual block’s gram matrix, we add an axis via `[None, ...]` so that we can sum over that axis i.e., the `da.map_blocks` call produces a `(n_obs // chunk_size, n_vars, n_vars)` sized-matrix which is summed over the first dimension. However, to make this work, we need to be very specific about how `da.map_blocks` expects its result to look like, done via `new_axis` and `chunks`. `new_axis` indicates that we are adding a single new axis at the front. The `chunks` argument specifies that the output of `da.map_blocks` should have `x.blocks.size` number of `(1, n_vars, n_vars)` matrixes. @@ -85,7 +85,7 @@ This loads the entire dataset into memory while keeping the representation as a Thus, lazy computation still works but only necessitates a single read into memory. The catch is that you need to have enough memory to use `persist`, but if you do it greatly speeds up the computation. -### I'm out of memory, what now? +### I’m out of memory, what now? You can always reduce the number of workers you use, which will cause more memory to be allocated per worker. Some algorithms may have limitations with loading all data onto a single node; see {issue}`dask/dask-ml#985` for an example. diff --git a/docs/index.md b/docs/index.md index 4e6e7146..50810cbf 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,4 @@ ```{include} ../README.md - ``` ```{toctree} From 1eaeec5c9fd2ad2ee8212b9c1d50f0eaa53d5a2e Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Thu, 12 Nov 2026 16:59:12 +0100 Subject: [PATCH 2/2] style: use scverse_doc MyST extensions in panache config --- .panache.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.panache.toml b/.panache.toml index 9dfd77fe..cd9509d6 100644 --- a/.panache.toml +++ b/.panache.toml @@ -6,9 +6,9 @@ wrap = "preserve" smart-punctuation = "unicode" tab-stops = "preserve" -# MyST syntax extensions from `myst_enable_extensions` in `docs/conf.py` +# MyST syntax extensions from `scverse_doc.config.MYST_ENABLE_EXTENSIONS` [extensions] -tex-math-dollars = true # amsmath, dollarmath myst-colon-fence = true # colon_fence definition-lists = true # deflist -raw-html = true # html_admonition, html_image +tex-math-dollars = true # dollarmath, amsmath +raw-html = true # html_image, html_admonition