Commit 408741c
* switch order of if-clauses
`len(value) == 1` is the simplest case, and is also the case where the problematic clause `len(value) == size` fails.
This commit switches the order, so we check for `len(value) == 1` first.
This ensures that when the `len(value) == size` clause runs, we know that `size != 1`, avoiding the bug in Qiskit#13623.
* add test
* Simplify `value.phase` broadcasting
Here, `phase` should be a 1D array. `np.vstack()` docs say explicitly output will be at least 2D, so we should not use that to create `phase`.
The intent of using `np.vstack()` was essentially to broadcast `phase` to properly add to `self.phase`. But, this happens automatically and correctly if we just add as-is. So this commit simplifies the code accordingly.
* Verify that `phase` is 1D in `from_symplectic()`
Verifying the input arg `phase`, since otherwise `from_symplectic()` will silently create PauliLists with malformed `phase` attributes (i.e. not 1D).
Zero-dimensional is OK (e.g. `phase` defaults to `0`) since that can broadcast per the shape of the `z` and `x` arrays.
* remove vestigial line
* lint
* release note
* Update releasenotes/notes/fix-paulilist-length1-phase-688d0e3a64ec9a9f.yaml
Co-authored-by: Jake Lishman <[email protected]>
---------
Co-authored-by: Jake Lishman <[email protected]>
1 parent 682cf3b commit 408741c
File tree
3 files changed
+23
-8
lines changed- qiskit/quantum_info/operators/symplectic
- releasenotes/notes
- test/python/quantum_info/operators/symplectic
3 files changed
+23
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
| 454 | + | |
460 | 455 | | |
461 | 456 | | |
462 | 457 | | |
463 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
464 | 462 | | |
465 | 463 | | |
466 | 464 | | |
| |||
471 | 469 | | |
472 | 470 | | |
473 | 471 | | |
474 | | - | |
| 472 | + | |
475 | 473 | | |
476 | 474 | | |
477 | 475 | | |
| |||
1131 | 1129 | | |
1132 | 1130 | | |
1133 | 1131 | | |
| 1132 | + | |
| 1133 | + | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1560 | 1560 | | |
1561 | 1561 | | |
1562 | 1562 | | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
1563 | 1572 | | |
1564 | 1573 | | |
1565 | 1574 | | |
| |||
0 commit comments