Skip to content

Address return value type for single-element access #125

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

Merged
merged 3 commits into from
Feb 21, 2021

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Feb 15, 2021

This PR seeks to address the issue discussed in gh-123 concerning single-element access by always returning an array, including when accessing a single element. This aligns with accelerator array libraries which always return arrays.

Resolved: the PR includes a TODO for the type hint for __getitem__, where key may be one of either int, <array>, slice, or selection tuple.

@rgommers
Copy link
Member

rgommers commented Feb 15, 2021

The PR includes a TODO for the type hint for __getitem__, where key may be one of either int, <array>, slice, or selection tuple. Not clear to me how we want to communicate the type hint in this case.

How about Union[int, Tuple[int, ...], slice, <array>]?

@kgryte
Copy link
Contributor Author

kgryte commented Feb 16, 2021

Updated this PR to include the type annotation for the index key.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @kgryte

@rgommers rgommers merged commit dde04ac into main Feb 21, 2021
@rgommers rgommers deleted the indexing-return-value branch February 21, 2021 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants