Skip to content

Add transition table feature to changelog - #48

Merged
bjmorgan merged 10 commits into
mainfrom
update-changelog-transition-table
Mar 19, 2026
Merged

Add transition table feature to changelog#48
bjmorgan merged 10 commits into
mainfrom
update-changelog-transition-table

Conversation

@bjmorgan

@bjmorgan bjmorgan commented Mar 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add changelog entry for transition_counts_by_site(), transition_counts_by_label(), transition_probabilities_by_site(), transition_probabilities_by_label(), and TransitionTable under v1.7.0
  • Add test for unlabelled site transitioning to an invalid destination index

Use key=str to satisfy type checker when sorting sets of int | str keys.
key=str would sort integers lexicographically (1, 10, 2). Since keys
are homogeneous at runtime, sorted() works correctly; the type checker
just cannot prove it from the union type.
- TransitionTable is now Generic[TableKey] where TableKey is
  constrained to int or str, eliminating union types and type: ignore
  comments throughout the class.
- Add @overload signatures to transition_counts() and
  transition_probabilities() so callers get precise return types.
- Extract _normalise_counts() and _validate_destination() helpers to
  reduce duplication in trajectory.py.
Replace transition_counts(by=...) and transition_probabilities(by=...)
with four explicit methods:

- transition_counts_by_site()
- transition_counts_by_label()
- transition_probabilities_by_site()
- transition_probabilities_by_label()

Each method has a precise return type (TransitionTable[int] or
TransitionTable[str]) with no overloads, casts, or unions needed.
Remove the now-unnecessary TransitionValidationTestCase (no by
parameter to validate).
- Update changelog to reference the actual method names
  (transition_counts_by_site, transition_counts_by_label, etc.)
- Add test for unlabelled site transitioning to an invalid index,
  covering the _validate_destination call at trajectory.py:254-255

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the transition table functionality across the codebase, including API changes in Trajectory, improved typing for TransitionTable, test updates, and a changelog entry documenting the feature.

Changes:

  • Refactors Trajectory transition aggregation into explicit *_by_site() / *_by_label() methods and adds shared helpers for validation + normalisation.
  • Makes TransitionTable generic over key type (int/str) and updates associated type annotations.
  • Updates unit tests and the changelog to reflect the new transition table APIs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_trajectory.py Updates tests to call the new transition_*_by_site/_by_label APIs; adds a new invalid-destination test.
site_analysis/transition_table.py Introduces TransitionTable[TableKey] generics and updates method type hints accordingly.
site_analysis/trajectory.py Replaces by=... parameter APIs with explicit per-site/per-label methods; adds helper methods for validation and normalisation.
site_analysis/site_collection.py Adds a -> None return annotation to __init__.
CHANGELOG.md Adds entries describing the transition table APIs and exports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
Comment thread CHANGELOG.md
Comment thread tests/test_trajectory.py Outdated
Comment thread site_analysis/trajectory.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the project to reflect and test the finalized “transition table” API introduced in v1.7.0, including new Trajectory transition aggregation methods and the TransitionTable data structure.

Changes:

  • Updates trajectory transition tests to use transition_counts_by_site/_by_label and transition_probabilities_by_site/_by_label, and adds a new regression test for invalid destination indices from an unlabelled source site.
  • Improves typing of TransitionTable by making it generic over its key type (int or str).
  • Adds v1.7.0 changelog entries documenting the new APIs and TransitionTable export.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_trajectory.py Renames test call sites to the new *_by_site/_by_label APIs; adds coverage for invalid destination handling in label aggregation.
site_analysis/transition_table.py Makes TransitionTable generic over key type and simplifies get() typing.
site_analysis/trajectory.py Replaces the prior by=-parameter API with explicit per-site/per-label methods and shared validation/normalisation helpers.
site_analysis/site_collection.py Adds an explicit -> None return annotation to __init__.
CHANGELOG.md Documents the new transition-table-related APIs under v1.7.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bjmorgan
bjmorgan merged commit bd4733d into main Mar 19, 2026
10 checks passed
@bjmorgan
bjmorgan deleted the update-changelog-transition-table branch March 19, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants