Metadata-Version: 2.4
Name: holoviz-utils
Version: 0.6.0
Summary: A Python package for HoloViz utilities
Author-email: Bert Coerver <b.coerver@mailbox.org>
License-Expression: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: holoviews
Requires-Dist: pandas
Requires-Dist: param
Requires-Dist: panel
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: pytest-xdist>=3.0; extra == "dev"
Requires-Dist: ipython>=8.0; extra == "dev"
Requires-Dist: ipykernel>=6.0; extra == "dev"
Dynamic: license-file

# holoviz-utils

A Python package for HoloViz utilities.

## Installation

```bash
pip install -e .
```

For development:

```bash
pip install -e ".[dev]"
```

## Usage

```python
import holoviz_utils
```

## Caption templates

`DataPresentation` renders the `__doc__` of its components — and its
`title` / `introduction` / `conclusion` params — as live captions. Any
`{...}` token is substituted against current parameter values and re-rendered
automatically whenever a referenced value changes.

A token is `{[func(]param[keys][:fmt])}` (only `param` is required):

- `param` — a parameter name, resolved on the presentation or any reachable
  sub-object (a `DataCombiner`, a layer, a colormap, …).
- `[keys]` — index/key lookups. A **quoted** key (`['label']`) is literal; an
  **unquoted** key (`[highlight_name]`) is another param ref whose *value* is
  used as the key — this is how you turn a code into a display name.
- `func(...)` — an optional whitelisted function (`len`, `sum`, `min`, `max`,
  `abs`, `round`, `sorted`, `int`, `float`, `str`, `bool`).
- `:fmt` — an optional Python format spec (`:0.1f`, `:,`, `%Y-%m-%d`, …).

A token that resolves to `None` renders as `unknown`.

```python
# highlight_name == "Q"; cmap_var_styles == {"Q": {"label": "Discharge (m³/s)"}, ...}
dgl.__doc__ = (
    "Time-series for the {cmap_var_styles[highlight_name]['label']} at the "
    "{click_state['properties']['S6_SB_NAME']} sub-basin."
)
# -> "Time-series for the Discharge (m³/s) at the <name> sub-basin."

"{len(subbasins)} sub-basins selected"   # -> "3 sub-basins selected"
"mean = {max(scores['a']):0.2f}"          # -> "mean = 12.34"
```

To add a `code -> display` mapping, just expose it as a parameter and reference
`{table[code_param]['field']}` — no derived params or manual watchers needed.
See `DataPresentation.update_doc` for the full reference.

## Development

Run tests:

```bash
pytest
```

## License

MIT
