In stimflow/_chunk/_chunk_reflow_test.py, the existing test test_from_auto_rewrite_xyz tests creating an N-to-1
reflow chunk where Logical $X$ and $Z$ inputs combine into a $Y$ output:
def test_from_auto_rewrite_xyz():
result = stimflow.ChunkReflow.from_auto_rewrite(
inputs=[stimflow.PauliMap({"X": [2, 3]}), stimflow.PauliMap({"Z": [2, 3]})],
out2in={stimflow.PauliMap({"Y": [2, 3]}): "auto"},
)
assert result == stimflow.ChunkReflow(
out2in={
stimflow.PauliMap({"Y": [2, 3]}): [stimflow.PauliMap({"X": [2, 3]}), stimflow.PauliMap({"Z": [2, 3]})]
}
)
If you add result.verify() to the end of test_from_auto_rewrite_xyz, it crashes with:
ValueError: not enough values to unpack (expected 2, got 1)
The issue come ChunkReflow.verify() (around line 299), .verify() asserts:
if len(self.out2in) != len(self.removed_inputs):
...
raise ValueError("\n".join(msg))
on top, there is a small bug, when len(self.out2in) != len(self.removed_inputs) fails and verify() attempts to format the exception message, lines 301 and 305 execute:
for ps, obs in self.out2in:
msg.append(f" {ps}, obs={obs}")
it's missing a .items() and this lead to the Value Error instead of the actual helpful message about the size of the out2in and removed inputs
In$X$ and $Z$ inputs combine into a $Y$ output:
stimflow/_chunk/_chunk_reflow_test.py, the existing testtest_from_auto_rewrite_xyztests creating an N-to-1reflow chunk where Logical
If you add result.verify() to the end of
test_from_auto_rewrite_xyz, it crashes with:The issue come
ChunkReflow.verify()(around line 299),.verify()asserts:on top, there is a small bug, when
len(self.out2in) != len(self.removed_inputs)fails andverify()attempts to format the exception message, lines 301 and 305 execute:it's missing a
.items()and this lead to the Value Error instead of the actual helpful message about the size of the out2in and removed inputs