-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
partial_trace
when not removing subsystems (#7613)
* Fix `partial_trace` when not removing subsystems There were places, such as in `quantum_info.partial_trace` where an `OpShape` output of `OpShape.remove` was mutated. In cases where nothing was removed from the `OpShape`, it returned itself, and consequently caused lingering issues with the object that owned the shape. This ensures a copy is always produced, and adds in a special case to handle `DensityMatrix` with nothing traced out. * Check qargs not shape equality Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0fc885b
commit 570a5f0
Showing
4 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
releasenotes/notes/fix-partial_trace-no-systems-0dc2df3007942eb6.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
fixes: | ||
- | | ||
If :func:`.quantum_info.partial_trace` is asked to trace out *no* subsystems, | ||
it will now correctly return the | ||
:class:`.DensityMatrix` of the input state with all dimensions remaining | ||
rather than throwing an error. |
This file contains 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