scistackplotdb 0.2.5__tar.gz → 0.3.1__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.
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/PKG-INFO +6 -6
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/load.py +4 -44
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/source.py +1 -103
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/.gitignore +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/README.md +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/pyproject.toml +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/__init__.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/bundle_section.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/designs.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/endpoint.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/hierarchy.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/presets.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/saved.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/text_fields.py +0 -0
- {scistackplotdb-0.2.5 → scistackplotdb-0.3.1}/src/scistackplotdb/variants.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: scistackplotdb
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: scidb-backed plotting: load variables into long tables and plot them with scistackplot
|
|
5
5
|
Author: SciStack Contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
18
18
|
Classifier: Typing :: Typed
|
|
19
19
|
Requires-Python: >=3.10
|
|
20
|
-
Requires-Dist: sciduckdb==0.
|
|
21
|
-
Requires-Dist: scifor==0.
|
|
22
|
-
Requires-Dist: scistack-db==0.
|
|
23
|
-
Requires-Dist: scistacklog==0.
|
|
24
|
-
Requires-Dist: scistackplot==0.
|
|
20
|
+
Requires-Dist: sciduckdb==0.3.1
|
|
21
|
+
Requires-Dist: scifor==0.3.1
|
|
22
|
+
Requires-Dist: scistack-db==0.3.1
|
|
23
|
+
Requires-Dist: scistacklog==0.3.1
|
|
24
|
+
Requires-Dist: scistackplot==0.3.1
|
|
25
25
|
Provides-Extra: dev
|
|
26
26
|
Requires-Dist: matplotlib>=3.6; extra == 'dev'
|
|
27
27
|
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
@@ -24,7 +24,7 @@ import numpy as np
|
|
|
24
24
|
import pandas as pd
|
|
25
25
|
from sciduckdb import merge_tz_columns, stored_tz_companions, tz_column_name
|
|
26
26
|
from scistacklog import Log
|
|
27
|
-
from scistackplot import CODE_FACTOR_PREFIX, RUN_FACTOR_PREFIX
|
|
27
|
+
from scistackplot import CODE_FACTOR_PREFIX, RUN_FACTOR_PREFIX
|
|
28
28
|
from scistackplot.text.framesize import format_extent, frame_extent
|
|
29
29
|
from scistackplot.model.shape import Shape, classify_value
|
|
30
30
|
from scistackplot.model.table import natural_sort_key
|
|
@@ -98,11 +98,6 @@ class VariableFrame:
|
|
|
98
98
|
#: Name of the per-row "this is my location's newest code version" flag, or
|
|
99
99
|
#: None when the variable holds only one version. See :data:`LATEST_COLUMN`.
|
|
100
100
|
latest_column: str | None = None
|
|
101
|
-
#: Data columns stored as ``row_list`` ("combine rows": one element per
|
|
102
|
-
#: source row, sciduckdb.row_lists). Their cells arrive as arrays; the
|
|
103
|
-
#: source splits them into rows with a ``Row`` factor
|
|
104
|
-
#: (scistackplot.reduce.rows), never plots them as 1-D series.
|
|
105
|
-
row_list_columns: list[str] = field(default_factory=list)
|
|
106
101
|
|
|
107
102
|
@property
|
|
108
103
|
def value_column(self) -> str:
|
|
@@ -273,13 +268,7 @@ def sample_value(db, variable: str) -> Any:
|
|
|
273
268
|
columns = data_columns_for(db, variable)
|
|
274
269
|
if not columns:
|
|
275
270
|
return None
|
|
276
|
-
|
|
277
|
-
# A row list's cell is its source rows, not a series: classify by one
|
|
278
|
-
# ELEMENT, the shape the source turns it into (rows + a Row factor).
|
|
279
|
-
if value is not None and _row_list_columns(db, variable, columns[:1]):
|
|
280
|
-
elements = element_values(pd.Series([value], dtype=object)).dropna()
|
|
281
|
-
value = elements.iloc[0] if len(elements) else None
|
|
282
|
-
return value
|
|
271
|
+
return db.record_store.sample_cell(variable, columns[0])
|
|
283
272
|
|
|
284
273
|
|
|
285
274
|
def sample_column_value(db, variable: str, column: str) -> Any:
|
|
@@ -308,18 +297,13 @@ def field_shapes(db, variable: str) -> dict[str, Shape]:
|
|
|
308
297
|
a "(text)" entry that then says it has no text fields.
|
|
309
298
|
"""
|
|
310
299
|
types = data_column_types_for(db, variable)
|
|
311
|
-
row_lists = set(_row_list_columns(db, variable, list(types)))
|
|
312
300
|
shapes: dict[str, Shape] = {}
|
|
313
301
|
with Log.timer(f"field_shapes({variable})", layer=LAYER, extra=f"{len(types)} column(s)"):
|
|
314
302
|
for column, data_type in types.items():
|
|
315
|
-
if is_container_type(data_type)
|
|
303
|
+
if is_container_type(data_type):
|
|
316
304
|
shapes[column] = Shape.SERIES_1D
|
|
317
305
|
continue
|
|
318
|
-
|
|
319
|
-
if value is not None and column in row_lists:
|
|
320
|
-
elements = element_values(pd.Series([value], dtype=object)).dropna()
|
|
321
|
-
value = elements.iloc[0] if len(elements) else None
|
|
322
|
-
shapes[column] = classify_value(value)
|
|
306
|
+
shapes[column] = classify_value(sample_column_value(db, variable, column))
|
|
323
307
|
return shapes
|
|
324
308
|
|
|
325
309
|
|
|
@@ -441,28 +425,6 @@ def _key_text(value: Any) -> "str | None":
|
|
|
441
425
|
return str(value)
|
|
442
426
|
|
|
443
427
|
|
|
444
|
-
def _row_list_columns(db, variable: str, columns) -> list[str]:
|
|
445
|
-
"""Which columns are row lists (sciduckdb.row_lists: rows combined by
|
|
446
|
-
``on_duplicate="combine"``). This reader selects the stored cells as they
|
|
447
|
-
are, so EVERY cell of such a column is an array (``[7]``, ``[5, 12]``).
|
|
448
|
-
The source splits them into rows with a ``Row`` factor
|
|
449
|
-
(scistackplot.reduce.rows) — they are observations, not a 1-D series. This
|
|
450
|
-
replaced the "read as 1-D" decision of
|
|
451
|
-
.claude/plan-combine-duplicate-locations.md §6 on 2026-10-30
|
|
452
|
-
(.claude/plan-row-list-plots.md)."""
|
|
453
|
-
from sciduckdb import is_row_list_meta
|
|
454
|
-
|
|
455
|
-
stored = (db.get_dtype_meta(variable) or {}).get("columns", {})
|
|
456
|
-
row_lists = [c for c in columns if is_row_list_meta(stored.get(c))]
|
|
457
|
-
if row_lists:
|
|
458
|
-
Log.debug(
|
|
459
|
-
"variable %r: row-list column(s) %s (combined rows) — split into "
|
|
460
|
-
"one row per element by the source",
|
|
461
|
-
variable, row_lists, layer=LAYER,
|
|
462
|
-
)
|
|
463
|
-
return row_lists
|
|
464
|
-
|
|
465
|
-
|
|
466
428
|
def load_variable(
|
|
467
429
|
db, variable: str, *, with_variants: bool = True, include_data: bool = True
|
|
468
430
|
) -> VariableFrame:
|
|
@@ -487,7 +449,6 @@ def load_variable(
|
|
|
487
449
|
keys = schema_keys(db)
|
|
488
450
|
column_types = data_column_types_for(db, variable)
|
|
489
451
|
columns = list(column_types)
|
|
490
|
-
row_list_columns = _row_list_columns(db, variable, columns)
|
|
491
452
|
if not columns:
|
|
492
453
|
Log.warn("variable %r has no data columns", variable, layer=LAYER)
|
|
493
454
|
return VariableFrame(name=variable, frame=pd.DataFrame())
|
|
@@ -581,7 +542,6 @@ def load_variable(
|
|
|
581
542
|
variant_columns=variant_columns,
|
|
582
543
|
variant_axes=variant_axes,
|
|
583
544
|
latest_column=latest_column,
|
|
584
|
-
row_list_columns=[c for c in row_list_columns if c in columns],
|
|
585
545
|
)
|
|
586
546
|
|
|
587
547
|
|
|
@@ -21,11 +21,8 @@ from scistackplot import (
|
|
|
21
21
|
Shape,
|
|
22
22
|
classify_column,
|
|
23
23
|
classify_value,
|
|
24
|
-
element_values,
|
|
25
|
-
explode_row_lists,
|
|
26
24
|
is_plottable,
|
|
27
25
|
natural_sort_key,
|
|
28
|
-
row_origin,
|
|
29
26
|
)
|
|
30
27
|
from scistackplot.reduce.categorical import MAX_CATEGORY_LEVELS
|
|
31
28
|
from scistackplot.sources.dedup import SingleFlight
|
|
@@ -656,8 +653,6 @@ class ScidbSource(BaseSource):
|
|
|
656
653
|
primary = self._variable_frame(base_variable(measures[0]))
|
|
657
654
|
own = self._own_column_groups(primary, factor_variables)
|
|
658
655
|
field_columns: list[str] = []
|
|
659
|
-
row_column: str | None = None
|
|
660
|
-
row_info: dict | None = None
|
|
661
656
|
|
|
662
657
|
if x_measure is None:
|
|
663
658
|
if len(primary.data_columns) > 1:
|
|
@@ -668,20 +663,9 @@ class ScidbSource(BaseSource):
|
|
|
668
663
|
text=text_only,
|
|
669
664
|
)
|
|
670
665
|
field_columns = [field_factor]
|
|
671
|
-
melted = set(frame[field_factor].unique())
|
|
672
|
-
row_fields = [c for c in primary.row_list_columns if c in melted]
|
|
673
666
|
else:
|
|
674
667
|
frame = self._named_frame(primary, measures[0])
|
|
675
668
|
field_factor = None
|
|
676
|
-
row_fields = (
|
|
677
|
-
[measures[0]]
|
|
678
|
-
if primary.value_column in primary.row_list_columns
|
|
679
|
-
else []
|
|
680
|
-
)
|
|
681
|
-
if row_fields:
|
|
682
|
-
frame, row_column, row_info = self._split_row_lists(
|
|
683
|
-
primary.name, frame, measures[0], row_fields, field_factor
|
|
684
|
-
)
|
|
685
669
|
levels = primary.levels
|
|
686
670
|
variant_columns = list(primary.variant_columns)
|
|
687
671
|
variant_axes = list(primary.variant_axes)
|
|
@@ -692,22 +676,6 @@ class ScidbSource(BaseSource):
|
|
|
692
676
|
else:
|
|
693
677
|
secondary = self._variable_frame(x_measure)
|
|
694
678
|
pair = (measures[0], x_measure)
|
|
695
|
-
combined = [
|
|
696
|
-
name
|
|
697
|
-
for name, vf in zip(pair, (primary, secondary), strict=True)
|
|
698
|
-
if vf.row_list_columns
|
|
699
|
-
]
|
|
700
|
-
if combined:
|
|
701
|
-
# Not split here: pairing one x per y row needs the two
|
|
702
|
-
# variables' rows to line up, and nothing says row i of one
|
|
703
|
-
# is row i of the other. Said, not silent.
|
|
704
|
-
Log.warn(
|
|
705
|
-
"%s hold combined rows (row lists); an x-y plot reads "
|
|
706
|
-
"them as 1-D arrays — plot each on its own to see one "
|
|
707
|
-
"point per source row",
|
|
708
|
-
combined,
|
|
709
|
-
layer=LAYER,
|
|
710
|
-
)
|
|
711
679
|
multi = [
|
|
712
680
|
name
|
|
713
681
|
for name, frame in zip(pair, (primary, secondary), strict=True)
|
|
@@ -766,13 +734,6 @@ class ScidbSource(BaseSource):
|
|
|
766
734
|
factors.extend(c for c in field_columns if c in frame.columns)
|
|
767
735
|
factor_origins = {axis["column"]: axis for axis in variant_axes}
|
|
768
736
|
factor_depths = dict(group_depths)
|
|
769
|
-
if row_column is not None and row_info is not None:
|
|
770
|
-
factors.append(row_column)
|
|
771
|
-
factor_origins[row_column] = row_info
|
|
772
|
-
# Pinned by every schema key the record sits under plus itself:
|
|
773
|
-
# one level below the variable's own, so the scalar default
|
|
774
|
-
# groups it (one mark per source row) and iterates the rest.
|
|
775
|
-
factor_depths[row_column] = len(levels) + 1
|
|
776
737
|
|
|
777
738
|
level_order = {
|
|
778
739
|
name: self._level_order(name, frame, is_field=name in field_columns)
|
|
@@ -1227,17 +1188,6 @@ class ScidbSource(BaseSource):
|
|
|
1227
1188
|
``spec.measures`` stop naming a real variable.
|
|
1228
1189
|
"""
|
|
1229
1190
|
frames = [self._variable_frame(name) for name in measures]
|
|
1230
|
-
combined = [f.name for f in frames if f.row_list_columns]
|
|
1231
|
-
if combined:
|
|
1232
|
-
# Splitting is per variable, and stacked variables share one
|
|
1233
|
-
# value column; not done here yet. Said, not silent.
|
|
1234
|
-
Log.warn(
|
|
1235
|
-
"%s hold combined rows (row lists); stacked with other "
|
|
1236
|
-
"variables they are read as 1-D arrays — plot each on its own "
|
|
1237
|
-
"to see one point per source row",
|
|
1238
|
-
combined,
|
|
1239
|
-
layer=LAYER,
|
|
1240
|
-
)
|
|
1241
1191
|
|
|
1242
1192
|
# Dict/struct variables stack too, provided they carry the SAME fields:
|
|
1243
1193
|
# RawEMG and FilteredEMG, both keyed by muscle, are the archetypal
|
|
@@ -1538,17 +1488,10 @@ class ScidbSource(BaseSource):
|
|
|
1538
1488
|
carried = [c for c in (carry or []) if c in frame.columns]
|
|
1539
1489
|
usable, skipped = [], []
|
|
1540
1490
|
texts: list[str] = []
|
|
1541
|
-
row_lists = set(variable_frame.row_list_columns)
|
|
1542
1491
|
for column in variable_frame.data_columns:
|
|
1543
1492
|
if column in carried:
|
|
1544
1493
|
continue
|
|
1545
|
-
|
|
1546
|
-
# after the melt): a VARCHAR row list is text and joins the text
|
|
1547
|
-
# fields, instead of melting in as a "1-D" column.
|
|
1548
|
-
values = (
|
|
1549
|
-
element_values(frame[column]) if column in row_lists else frame[column]
|
|
1550
|
-
)
|
|
1551
|
-
shape = classify_column(values)
|
|
1494
|
+
shape = classify_column(frame[column])
|
|
1552
1495
|
if shape is Shape.CATEGORICAL:
|
|
1553
1496
|
texts.append(column)
|
|
1554
1497
|
elif is_plottable(shape):
|
|
@@ -1647,51 +1590,6 @@ class ScidbSource(BaseSource):
|
|
|
1647
1590
|
)
|
|
1648
1591
|
return melted, field_factor
|
|
1649
1592
|
|
|
1650
|
-
def _split_row_lists(
|
|
1651
|
-
self,
|
|
1652
|
-
variable: str,
|
|
1653
|
-
frame,
|
|
1654
|
-
measure: str,
|
|
1655
|
-
row_fields: list[str],
|
|
1656
|
-
field_factor: str | None,
|
|
1657
|
-
):
|
|
1658
|
-
"""``(frame, row column or None, its origin or None)`` — every
|
|
1659
|
-
row-list cell split into one row per element (scistackplot.reduce.rows,
|
|
1660
|
-
the one owner of the reshape; codegen mirrors it from the origin).
|
|
1661
|
-
|
|
1662
|
-
The Row factor is kept only when some cell held two or more rows: a
|
|
1663
|
-
one-level factor is a constant (synthetic-factors.md invariant 6).
|
|
1664
|
-
The cells are unwrapped either way, so ``[v]`` reads as ``v``."""
|
|
1665
|
-
with Log.timer(
|
|
1666
|
-
f"split_row_lists({variable})",
|
|
1667
|
-
layer=LAYER,
|
|
1668
|
-
extra=f"{len(row_fields)} field(s)",
|
|
1669
|
-
):
|
|
1670
|
-
split = explode_row_lists(
|
|
1671
|
-
frame, measure, row_fields, field_factor=field_factor
|
|
1672
|
-
)
|
|
1673
|
-
Log.info(
|
|
1674
|
-
"split row-list field(s) %s of %r: %d cell(s), %d -> %d row(s), "
|
|
1675
|
-
"at most %d per cell; %s",
|
|
1676
|
-
row_fields,
|
|
1677
|
-
variable,
|
|
1678
|
-
split.cells,
|
|
1679
|
-
split.rows_in,
|
|
1680
|
-
split.rows_out,
|
|
1681
|
-
split.max_rows,
|
|
1682
|
-
f"factor {split.row_factor!r}"
|
|
1683
|
-
if split.row_factor
|
|
1684
|
-
else "no cell held two rows, so no Row factor",
|
|
1685
|
-
layer=LAYER,
|
|
1686
|
-
)
|
|
1687
|
-
if split.row_factor is None:
|
|
1688
|
-
return split.frame, None, None
|
|
1689
|
-
return (
|
|
1690
|
-
split.frame,
|
|
1691
|
-
split.row_factor,
|
|
1692
|
-
row_origin(row_fields, field_factor),
|
|
1693
|
-
)
|
|
1694
|
-
|
|
1695
1593
|
def _named_frame(self, variable_frame, measure: str):
|
|
1696
1594
|
"""The variable's frame with its data column renamed to the measure."""
|
|
1697
1595
|
return variable_frame.frame.rename(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|