Conversation
…_base_graph_state() Implements issue #120 by adding two new classmethod factory methods to GraphState: 1. from_graph(): Create a GraphState from nodes and edges with arbitrary hashable node identifiers (strings, tuples, etc.). Returns both the created GraphState and a mapping from external node IDs to internal indices. 2. from_base_graph_state(): Create a new GraphState by copying from an existing BaseGraphState instance, with optional control over LocalClifford operator copying. These methods improve usability by enabling cleaner graph construction patterns and allowing bulk initialization instead of adding nodes and edges one at a time. - Comprehensive input validation with clear error messages - Support for arbitrary node types via TypeVar - Preservation of node order for predictable index assignment - Full test coverage with 20 test cases covering various scenarios 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #121 +/- ##
==========================================
+ Coverage 67.58% 68.35% +0.77%
==========================================
Files 21 21
Lines 1968 2035 +67
Branches 300 326 +26
==========================================
+ Hits 1330 1391 +61
- Misses 590 592 +2
- Partials 48 52 +4 🚀 New features to boost your workflow:
|
d1ssk
approved these changes
Oct 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
from_graph()class method for flexible graph initialization with arbitrary node types (strings, tuples, etc.)from_base_graph_state()class method for creating new GraphState instances from existing BaseGraphState objectsTest plan
pytest tests/test_graphstate_bulk_init.py -v- All 20+ tests passpytest- All existing tests still passruff check graphqomb/ tests/- No linting errorsmypy graphqomb/- Type checking passesCloses #120
🤖 Generated with Claude Code