Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions changelog.d/ITL-1304.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Changed

- The preview tells a plain tag from a data-tag (ITL-1304). A data-tag (one column that is
both a tag and the data column of the same name) is still shown once, among the tags, in
tag order, but with its own mark. In the notebook (HTML) preview the marks compose
(developer, November 21, 2026): a tag's header is bold in the accent colour (as before),
a data column's header is now underlined (at normal weight), and a data-tag's header has
both. The hidden column groups keep their look when shown: system tags are marked as
tags, as before; source-info, context, content-hash and meta (`__`) columns stay
unmarked. In the text preview a data-tag's name starts with `+` (a plain tag's with `*`;
data columns stay unmarked). The legend line names exactly the marks shown (of the
columns Polars renders, when it leaves some out of a wide table): "bold = tag;
underlined = data; bold underlined = data-tag (a tag that is also data)" in a notebook,
"* = tag; + = data-tag (tag and data)" as text, each part only when such a column is
shown. It holds for every view: `head()`, `tail()`, `sort_by_tags()`, `run()`, the
notebook preview and the text form, of a source, a stream, an operator or function pod
result and a job node, loaded jobs included. A `StreamView` has two new fields,
`data_tag_columns` and `data_columns`, taken from the stream's `keys()`. Only the
display is marked: the view's `table`, `as_table()`, the data frames and every schema,
hash and stored form are unchanged.
26 changes: 24 additions & 2 deletions docs/concepts/data-tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,30 @@ not a declared tag is an error. A source built with all its tags plain is exactl
source v0.3 built: same columns, same hashes.

The column is stored once: `as_table()` shows it once, and every row's tag and data hold
the same value. The notebook preview shows it once, among the tags, marked as a tag
([Working in notebooks](notebooks.md#a-stream-at-the-end-of-a-cell)).
the same value. The preview shows it once, among the tags, marked as a data-tag. In a
notebook the marks compose: a tag's header is bold in an accent colour, a data column's is
underlined, and a data-tag's has both. As text a data-tag's name starts with `+` (a plain
tag's with `*`; a data column's is unmarked). The legend line names the marks shown
([Working in notebooks](notebooks.md#a-stream-at-the-end-of-a-cell)). Only the display is
marked: the view's table and `as_table()` keep the plain names.

```python
mixed = op.sources.DictSource(
rows, tag_columns=["unit", "time"], tag_only_columns=["time"], source_id="spikes"
)
print(mixed.head())
# DictSource[spikes] — all 2 rows
# * = tag; + = data-tag (tag and data)
# shape: (2, 3)
# ┌───────┬───────┬──────┐
# │ +unit ┆ *time ┆ amp │
# │ --- ┆ --- ┆ --- │
# │ i64 ┆ i64 ┆ f64 │
# ╞═══════╪═══════╪══════╡
# │ 1 ┆ 10 ┆ 0.5 │
# │ 2 ┆ 20 ┆ 0.25 │
# └───────┴───────┴──────┘
```

Data-tags come first among the data columns, in tag order, then the other data columns in
their table order. Every stream, operator result and row follows this order, whatever the
Expand Down
43 changes: 37 additions & 6 deletions docs/concepts/notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ What it shows ([Looking at data](streams.md#looking-at-data) states each rule in
here `first 10 of 64 rows, sorted by tags`. A source that reads only part of its table
says so, as a [SpiralDB source](sources.md) does ("10 rows read, sorted by tags, of about
63,349").
- **Tag columns** come first and are marked: in a notebook their headers are bold (in an
accent colour), a vertical rule separates them from the data columns and a line under the
header says "bold = tag". A [data-tag](data-tags.md) is one column: the notebook preview
shows it once, among the tags, marked as a tag.
- **Tag columns** come first and are marked, and so are data columns: in a notebook a tag's
header is bold (in an accent colour), a data column's is underlined, a vertical rule
separates the tags from the data columns, and a line under the header names the marks,
"bold = tag; underlined = data". A [data-tag](data-tags.md) is one column, a tag that is
also data: the preview shows it once, among the tags, with both marks (bold, in the
accent colour, and underlined), and the line adds
"bold underlined = data-tag (a tag that is also data)". The line names only the marks
shown: the tags of `units` are all plain. (The pictures were taken before data headers
were underlined.) When `columns` asks for the hidden column groups, system tags are
marked as tags and the source-info, context, content-hash and meta columns are left unmarked.
- **Large cells** are summarised (an array as `ndarray float64 (2, 3)`, bytes as
`bytes (300 B)`, long text and long lists shortened); `head().table` keeps the full values.

Expand All @@ -83,8 +89,9 @@ what is held or stored, or make a bounded table read), never call your code (a f
predicate, a side effect) and never write to a database. So a job node shown before the job
has run has no rows: its header says `not run`, and the table shows its columns only.

In a terminal, `print(stream.head())` prints the same preview as text. There, each tag
column's name starts with `*` ("* = tag"):
In a terminal, `print(stream.head())` prints the same preview as text. There, each plain tag
column's name starts with `*` ("* = tag"), and each data-tag's with `+`
("+ = data-tag (tag and data)"):

```python
print(units.head(3))
Expand Down Expand Up @@ -112,6 +119,30 @@ print(job.nodes["rates"].head())
# └─────────────┴──────────┴────────┴───────┴─────────┘
```

The same table read with `probe` and `unit` as data-tags (only `subject_id` and `session`
kept plain) marks the two kinds of tag apart:

```python
units_by_probe = CSVSource(
str(data_dir / "units.csv"),
tag_columns=["subject_id", "session", "probe", "unit"],
tag_only_columns=["subject_id", "session"],
source_id="units",
)
print(units_by_probe.head(2))
# CSVSource[units] — first 2 of 64 rows
# * = tag; + = data-tag (tag and data)
# shape: (2, 7)
# ┌─────────────┬──────────┬────────┬───────┬────────┬──────────┬──────────┐
# │ *subject_id ┆ *session ┆ +probe ┆ +unit ┆ region ┆ depth_um ┆ n_spikes │
# │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
# │ str ┆ str ┆ str ┆ i64 ┆ str ┆ i64 ┆ i64 │
# ╞═════════════╪══════════╪════════╪═══════╪════════╪══════════╪══════════╡
# │ mouse_01 ┆ s1 ┆ imec0 ┆ 0 ┆ V1 ┆ 1580 ┆ 149 │
# │ mouse_01 ┆ s1 ┆ imec0 ┆ 1 ┆ V1 ┆ 2560 ┆ 326 │
# └─────────────┴──────────┴────────┴───────┴────────┴──────────┴──────────┘
```

(`head()` does not sort, so its header does not say `sorted by tags`; the preview asks for
the sorted head.) What each kind of object shows before and after it is computed (a source,
a computed stream, a job node, a side-effect node) is the table "What each kind of object
Expand Down
14 changes: 10 additions & 4 deletions docs/concepts/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,16 @@ the stream's results: each row is computed once and every read yields the same r
feeds the stream. An upstream finishing its first computation during the read is not a change;
a `clear_cache()` upstream between the reads is, and the next read starts again.

The display marks the tag columns, which come first: in a notebook their headers are bold
(in an accent colour), a vertical rule separates them from the data columns and a line under
the header says "bold = tag"; as text, each tag column's name starts with `*` ("* = tag").
Only the display is marked: the view's table and `as_table()` keep the plain names.
The display marks each column's role, with the tag columns first, in tag order. In a
notebook the marks compose: a tag's header is bold (in an accent colour), a data column's is
underlined, and a [data-tag](data-tags.md), a tag that is also data, has both; a vertical
rule separates the tags from the data columns, and a line under the header names each mark
shown ("bold = tag; underlined = data; bold underlined = data-tag (a tag that is also
data)"). A data-tag is one column, shown once, among the tags. When `columns` asks for the hidden
column groups, system tags are marked as tags, and the source-info, context,
content-hash and meta (`__`) columns are left unmarked. As text, a plain tag's name starts with `*` ("* = tag") and a data-tag's
with `+` ("+ = data-tag (tag and data)"); a data column's is unmarked. Only the display is
marked: the view's table and `as_table()` keep the plain names.

In the preview, large cells are summarised (an array as `ndarray float64 (2, 3)`, bytes as
`bytes (300 B)`, long text and long lists shortened); `head().table` keeps the full values.
Expand Down
Loading
Loading