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

Node slice indexing with stop index 0 is broken #1454

Closed
mark-koch opened this issue Aug 21, 2024 · 0 comments · Fixed by #1457
Closed

Node slice indexing with stop index 0 is broken #1454

mark-koch opened this issue Aug 21, 2024 · 0 comments · Fixed by #1457
Assignees
Labels
bug Something isn't working python Pull requests that update Python code

Comments

@mark-koch
Copy link
Contributor

>>> from hugr import Node
>>> n = Node(0, _num_out_ports=1)
>>> list(n[:0])

Expected output is [], but it actually gives [OutPort(Node(0), 0)].

This is because stop index 0 is evaluated as falsy in

stop = index.stop or self._num_out_ports

We should replace this with an explicit check for None.

@mark-koch mark-koch added bug Something isn't working python Pull requests that update Python code labels Aug 21, 2024
@aborgna-q aborgna-q self-assigned this Aug 21, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 21, 2024
Fixes #1454, and other failing cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests that update Python code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants