Skip to main content

Python Suite research packages logo

gp3sequencespy

Transparent, reproducible sequence analysis in Python.
Audit ordered categorical data, discover recurring structure, compare trajectories, model transitions and latent states, test group differences, and report every analytical choice.

PyPI Python versions CI Docs Quality MIT License DOI

Documentation · Quickstart · Method map · Plot gallery · API reference · v0.1.4


gp3sequencespy is the Python implementation of gp3sequences 0.3.0 for ordered categorical sequences and scanpaths. The frozen R 0.3.0 tarball is the behavioral reference: scientific contracts are preserved and tested explicitly, while deliberate R→Python translations are documented rather than hidden.

The package is designed for research workflows where data preparation, method choice, reproducibility, and interpretation need to remain visible from input to report.

Install

pip install gp3sequencespy==0.1.4

With uv:

uv add gp3sequencespy==0.1.4

Python 3.11–3.14 is supported. Optional extras are available for HMM backends, Arrow/Polars data interoperability, performance helpers, time-varying models, documentation, and development.

pip install "gp3sequencespy[hmm]"
pip install "gp3sequencespy[data]"
pip install "gp3sequencespy[time]"

A 60-second workflow

import pandas as pd
import gp3sequencespy as g

# One row per observed state occurrence.
data = pd.DataFrame(
    {
        "sequence_id": ["s1", "s1", "s1", "s2", "s2", "s2"],
        "sequence_order": [1, 2, 3, 1, 2, 3],
        "state": ["home", "search", "checkout", "home", "product", "checkout"],
    }
)

# Audit and prepare explicitly.
validation = g.validate_sequence_data(
    data,
    "sequence_id",
    "sequence_order",
    "state",
)
prepared = g.prepare_sequence_data(
    data,
    "sequence_id",
    "sequence_order",
    "state",
)

# Compare complete trajectories.
distance = g.compute_sequence_distance(
    prepared.data,
    method="lcs",
    normalise="max_length",
)

# Inspect transition structure.
network = g.create_transition_network(
    prepared.data,
    normalise="from",
)

# Visualise complete paths.
ax = g.plot_sequence_index(prepared.data)

For the complete path from raw long-format data to summaries, motifs, clustering, networks, plots, and analysis auditing, see the Quickstart.

What you can do

Research task Capabilities Start here
Audit & prepare ordering, missing states, duplicate positions, durations, state policies, preparation provenance Validation & preparation
Describe sequences state occupancy, transitions, paths, consensus, representatives Examples
Find recurring structure contiguous motifs, bounded non-contiguous subsequences, motif filtering and visualisation Motif workflow
Compare trajectories Levenshtein, LCS, optimal matching, transition-profile distances, clustering and stability Distances & clustering
Model transitions transition networks, centrality, communities, higher-order transition structure Networks & higher-order models
Fit latent models categorical, multichannel, covariate-dependent and time-varying HMM workflows Latent models
Test group structure design-aware randomization and sequence-group inference Inference & randomization
Visualise & report sequence index, state distributions, distance heatmaps, transition networks, audit trails Plot gallery

Not sure which family fits your question? Use the method map to move from research question → assumptions → method family.

Parity and validation

Version 0.1.4 is a maintenance release preserving the 0.1.2 scientific contracts while strengthening release automation and public documentation.

Validation contract Status
Frozen R public counterparts 81 / 81
Frozen R public signatures audited 81 / 81
Frozen R test_that() blocks translated 130 / 130
Python tests 293
Statement coverage 100%
Branch coverage 100%
Mutation smoke 3 / 3 killed
CI platforms Linux · macOS · Windows
CI Python versions 3.11 · 3.12 · 3.13 · 3.14
Python-native articles 15

The deterministic core, hierarchical/PAM, and time-varying-model cross-language oracle tranches have been executed against frozen R 0.3.0. Remaining deliberate boundaries are recorded in PARITY_EXCEPTIONS.md, with broader parity evidence in PARITY_TEST_MATRIX.md and the online parity guide.

Documentation routes

If you want to… Go to
get from install to first analysis quickly Quickstart
choose a method by research question Method map
copy complete analysis recipes Examples
inspect available figure families Plot gallery
read the full methodological guides Articles
translate from the R package R → Python
browse functions and signatures API reference
document a reproducible analysis Reproducibility · Reporting guide

Reproducibility and release governance

The package treats release and parity evidence as part of the scientific software contract.

Stable releases publish the exact validated GitHub Release wheel and source distribution to PyPI through GitHub OIDC Trusted Publishing. Each publication is subsequently checked against the GitHub Release SHA-256 hashes and with a clean PyPI installation.

Development

uv sync --all-extras --python 3.12
uv run pytest -q

Full quality gate:

uv run pytest -q \
  --cov=gp3sequencespy \
  --cov-branch \
  --cov-report=term-missing \
  --cov-fail-under=100

uv run python scripts/run_mutation_smoke.py

See CONTRIBUTING.md for contribution guidance and SECURITY.md for the security policy.

Citation

If gp3sequencespy contributes to your research, use the repository citation metadata in CITATION.cff and the archived Zenodo record:

DOI: 10.5281/zenodo.22166449

Scientific interpretation guardrail

Sequence structure does not independently establish emotion, cognition, comprehension, personality, intention, deception, diagnosis, or causality. Observational group contrasts are associational unless a valid randomized design supports a causal interpretation.


Documentation · PyPI · Releases · Zenodo

Metadata

Release files for gp3sequencespy 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gp3sequencespy 0.1.4
File Size Uploaded
gp3sequencespy-0.1.4.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for gp3sequencespy 0.1.4
File Interpreter ABI Platform
gp3sequencespy-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 1.5 MB

Release files / gp3sequencespy-0.1.4.tar.gz

Download URL gp3sequencespy-0.1.4.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
0818036719b60a3e5c7b5e015cf844b3572142216ff9c87310687e76b5cc45f4
BLAKE2b-256 checksum
How to use checksums
f6dc3b8ec2ce2a3aaf74f11197a011ded21748c9072a41a8b10ed74e9ce68eb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / gp3sequencespy-0.1.4-py3-none-any.whl

Download URL gp3sequencespy-0.1.4-py3-none-any.whl
Size 94.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a846e534f40143a12f06e0f02ff03fe7394c0f441e5907497dc136364e82410
BLAKE2b-256 checksum
How to use checksums
ea5aa55ec790587cde78c5e9e55b3530f9861fa68af1a93231d118169ed9d45d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page