Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for slice inputs to custom sequence return types #591

Merged
merged 7 commits into from
Apr 27, 2022

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented Apr 21, 2022

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 #590

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
@coveralls
Copy link

coveralls commented Apr 21, 2022

Pull Request Test Coverage Report for Build 2235984771

  • 34 of 34 (100.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 97.199%

Files with Coverage Reduction New Missed Lines %
src/shortest_path/all_pairs_dijkstra.rs 1 99.27%
Totals Coverage Status
Change from base Build 2232490412: 0.03%
Covered Lines: 11280
Relevant Lines: 11605

💛 - Coveralls

src/iterators.rs Outdated Show resolved Hide resolved
src/iterators.rs Outdated Show resolved Hide resolved
mtreinish and others added 4 commits April 27, 2022 06:24
Previously if an integer index was passed to `__getitem__`
with a value equal to the negative length of the sequence
we would incorrectly raise an except when instead the first
element should have been returned. This commit fixes the
handling of that edge case.

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
This commit fixes the handling of negative slices in sequence custom
return types. Previouly using a negative step would cause a panic
instead of correctly returning a reversed slice from the container. This
commit corrects this so we can deal with negative slice steps too.
Copy link
Collaborator

@georgios-ts georgios-ts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates.

tests/test_custom_return_types.py Outdated Show resolved Hide resolved
Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
@mtreinish mtreinish added the automerge Queue a approved PR for merging label Apr 27, 2022
@mergify mergify bot merged commit 7edcf9a into Qiskit:main Apr 27, 2022
@mtreinish mtreinish deleted the sequence-slice branch April 27, 2022 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Queue a approved PR for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement slice support for sequence return types
3 participants