Skip to main content

Exact time axes and time-indexed streams for Python

Project description

ChronoSeq

CI

ChronoSeq is a Python library for time-indexed streams of sampled data. It provides exact integer-nanosecond timestamps, rational sampling rates, regular and irregular time axes, nearest-sample lookup, and half-open time-window slicing. Data may be stored in memory, a file, a database, a video container, an external API, or any custom backend.

ChronoSeq has no time-zone, calendar, or wall-clock semantics. Timestamps are exact integer nanosecond offsets on a user-defined timeline.

Installation

pip install chronoseq

Core model

ChronoSeq has three main concepts:

  • TimeAxis: converts between timestamps and integer sample indices.
  • Reader: reads values by integer sample index.
  • Stream: combines a TimeAxis and Reader into a time-queryable stream.

The common constructors are concise:

from fractions import Fraction

from chronoseq import Rate, Stream, timestamp

frames = Stream.regular(
    start=timestamp(0),
    rate=Rate(30),
    values=[f"frame_{i:03d}" for i in range(300)],
)

# Rate(n, d) means n / d hertz, i.e. samples per second.
# For example, Rate(30000, 1001) is an exact 29.97 fps-style rate.
# Decimal rates can be represented exactly with Fraction.
rate_2856 = Rate(Fraction("28.56"))

frame = frames.nearest(timestamp("0.101"))

print(frame.index)
print(frame.time)
print(frame.value)

For irregular sampled data:

from chronoseq import Rate, Stream, timestamp

speed = Stream.irregular(
    timestamps=[
        timestamp("0.000"),
        timestamp("0.047"),
        timestamp("0.101"),
        timestamp("0.153"),
    ],
    values=[10.0, 10.3, 10.8, 11.1],
)

sample = speed.nearest(timestamp("0.100"))

More documentation

  • docs/semantics.md: formal timestamp, lookup, window, and reader rules.
  • docs/custom_readers.md: custom backend and stream extension patterns.
  • docs/performance.md: complexity notes, batching guidance, and benchmark snapshots.
  • samples/: dependency-free usage patterns.
  • benchmarks/: local benchmark scripts for large regular and irregular axes.

Licence

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chronoseq-0.4.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chronoseq-0.4.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file chronoseq-0.4.0.tar.gz.

File metadata

  • Download URL: chronoseq-0.4.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for chronoseq-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1fb5dbbfeae1298e391465e235aab8b02c5f3317c37b4c7508d6b757ebc320ca
MD5 1d6de28d3740ef63da79c378bd7db12d
BLAKE2b-256 f0f1c82c973545003f5ab812b68fbeb713fcc63eeb1e104bcb5306242b3ef6b4

See more details on using hashes here.

File details

Details for the file chronoseq-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: chronoseq-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for chronoseq-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1d75834a3c1004c27c2d86ba80ec7ec6231bb47c66b7ad6e0923e08a9830d58
MD5 c898afc69464a28580a4a1da4b33fef4
BLAKE2b-256 e70047f84c29f83e27db55ea10fbdac34dde1c417493f964b5ba6f03673017c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page