Skip to content

API reference / Analyses

tsdive.Profile dataclass

Profile(
    window: Window,
    stats: WindowStats,
    *,
    flatline: FlatlineVerdict | None = None,
)

One archive window, its statistics, and an optional flatline verdict.

Holds objects, not text: render is the only place the report lines are produced, and it is the same renderer the CLI prints. to_dict returns the document tsdive profile --json prints, like the to_dict of every other analysis result.

Methods:

Name Description
render

The report tsdive profile prints for this window, without colour.

to_dict

The document tsdive profile --json prints, ready for json.dumps.

Attributes:

Name Type Description
window Window
stats WindowStats
flatline FlatlineVerdict | None
identity TagIdentity
meta TagMeta
physics DataPhysics
frame DataFrame

window instance-attribute

window: Window

stats instance-attribute

stats: WindowStats

_ instance-attribute

_: KW_ONLY

flatline class-attribute instance-attribute

flatline: FlatlineVerdict | None = None

identity property

identity: TagIdentity

meta property

meta: TagMeta

physics property

physics: DataPhysics

frame property

frame: DataFrame

render

render() -> str

The report tsdive profile prints for this window, without colour.

Examples:

>>> import tsdive
>>> p = tsdive.profile("data/demo/fic101_demo.parquet",
...                    "2024-03-30T20:00:00Z/2024-03-31T06:00:00Z")
>>> for line in p.render().splitlines()[:2]:
...     print(line)
demo:FIC101.PV  FIC-101 flow
coverage 0.933   GOOD 561/562   censored yes   gaps 1

to_dict

to_dict() -> dict[str, object]

The document tsdive profile --json prints, ready for json.dumps.

Built by the same function the CLI calls, so the two are equal key for key. The command adds result_kind and tsdive_version in front.

Examples:

>>> import tsdive
>>> p = tsdive.profile("data/demo/fic101_demo.parquet",
...                    "2024-03-30T20:00:00Z/2024-03-31T06:00:00Z")
>>> doc = p.to_dict()
>>> doc["tag"], doc["range"]["censored"], doc["quality"]["counts"]["GOOD"]
('demo:FIC101.PV', True, 561)