Skip to content

Commit c377071

Browse files
Corrected dimensions for ENR states after ptrace
1 parent 7b44c2b commit c377071

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

tutorials-v4/miscellaneous/excitation-number-restricted-states-jc-chain.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ def ENR_ptrace(rho, sel, excitations):
244244
state2idx2[tuple(np.asarray(state2).take(sel))],
245245
] += rho.data[state2idx[state], state2idx[state2]]
246246

247-
return Qobj(rhout)
247+
new_dims = np.asarray(drho).take(sel).tolist()
248+
return Qobj(rhout, dims=[new_dims, new_dims], shape=[nstates2, nstates2])
248249
```
249250

250251
```python

tutorials-v5/miscellaneous/excitation-number-restricted-states-jc-chain.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ from qutip import (
7272
Qobj,
7373
about,
7474
)
75+
from qutip.core.energy_restricted import EnrSpace
7576

7677
%matplotlib inline
7778
```
@@ -245,7 +246,8 @@ def ENR_ptrace(rho, sel, excitations):
245246
state2idx2[tuple(np.asarray(state2).take(sel))],
246247
] += rho[state2idx[state], state2idx[state2]]
247248

248-
return Qobj(rhout)
249+
new_dims = np.asarray(drho).take(sel).tolist()
250+
return Qobj(rhout, dims=[EnrSpace(new_dims, excite)] * 2)
249251
```
250252

251253
```python

0 commit comments

Comments
 (0)