forked from Qiskit/rustworkx
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for slice inputs to custom sequence return types
This commit adds support for dealing with slice inputs to custom sequence return types such as NodeIndices. Previously, if a slice was requested from a custom return type it would have raised a TypeError. With this commit now it will return a new container object with a copy of the data from the requested slice. Fixes Qiskit#590
- Loading branch information
Showing
3 changed files
with
91 additions
and
10 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
releasenotes/notes/slices-for-sequences-a3b31c70f5d896b4.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,21 @@ | ||
--- | ||
fixes: | ||
- | | ||
The custom sequence return classes: | ||
* :class:`~.BFSSSuccessors` | ||
* :class:`~.NodeIndices` | ||
* :class:`~.EdgeList` | ||
* :class:`~WeightedEdgeList` | ||
* :class:`~EdgeIndices` | ||
* :class:`~Chains` | ||
now correctly handle slice inputs to ``__getitem__``. Previously if you | ||
tried to access a slice from one of these objects it would raise a | ||
``TypeError. For example, if you had a :class:`~.NodeIndices` object named | ||
``nodes`` containing ``[0, 1, 3, 4, 5]`` if you did something like:: | ||
nodes[0:3] | ||
it would return a new :class:`~.NodeIndices` object containing ``[0, 1, 3]`` | ||
Fixed `#590 <https://github.com/Qiskit/retworkx/issues/590>`__ |
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